@uploadcare/file-uploader 1.33.2 → 1.34.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 (67) hide show
  1. package/dist/abstract/loadFileUploaderFrom.js +2 -2
  2. package/dist/env.js +3 -3
  3. package/dist/index.css +2 -2
  4. package/dist/index.d.ts +277 -105
  5. package/dist/index.js +5 -5
  6. package/dist/index.layered.css +2 -2
  7. package/dist/index.ssr.js +3 -1
  8. package/dist/locales/file-uploader/ar.js +2 -2
  9. package/dist/locales/file-uploader/az.js +2 -2
  10. package/dist/locales/file-uploader/ca.js +2 -2
  11. package/dist/locales/file-uploader/cs.js +2 -2
  12. package/dist/locales/file-uploader/da.js +2 -2
  13. package/dist/locales/file-uploader/de.js +2 -2
  14. package/dist/locales/file-uploader/el.js +2 -2
  15. package/dist/locales/file-uploader/en.js +2 -2
  16. package/dist/locales/file-uploader/es.js +2 -2
  17. package/dist/locales/file-uploader/et.js +2 -2
  18. package/dist/locales/file-uploader/fi.js +2 -2
  19. package/dist/locales/file-uploader/fr.js +2 -2
  20. package/dist/locales/file-uploader/he.js +2 -2
  21. package/dist/locales/file-uploader/hy.js +2 -2
  22. package/dist/locales/file-uploader/is.js +2 -2
  23. package/dist/locales/file-uploader/it.js +2 -2
  24. package/dist/locales/file-uploader/ja.js +2 -2
  25. package/dist/locales/file-uploader/ka.js +2 -2
  26. package/dist/locales/file-uploader/kk.js +2 -2
  27. package/dist/locales/file-uploader/ko.js +2 -2
  28. package/dist/locales/file-uploader/lv.js +2 -2
  29. package/dist/locales/file-uploader/nb.js +2 -2
  30. package/dist/locales/file-uploader/nl.js +2 -2
  31. package/dist/locales/file-uploader/pl.js +2 -2
  32. package/dist/locales/file-uploader/pt.js +2 -2
  33. package/dist/locales/file-uploader/ro.js +2 -2
  34. package/dist/locales/file-uploader/ru.js +2 -2
  35. package/dist/locales/file-uploader/sk.js +2 -2
  36. package/dist/locales/file-uploader/sr.js +2 -2
  37. package/dist/locales/file-uploader/sv.js +2 -2
  38. package/dist/locales/file-uploader/tr.js +2 -2
  39. package/dist/locales/file-uploader/uk.js +2 -2
  40. package/dist/locales/file-uploader/vi.js +2 -2
  41. package/dist/locales/file-uploader/zh-TW.js +2 -2
  42. package/dist/locales/file-uploader/zh.js +2 -2
  43. package/package.json +8 -7
  44. package/types/jsx.d.ts +29 -1
  45. package/web/file-uploader.iife.min.d.ts +277 -105
  46. package/web/file-uploader.iife.min.js +4 -4
  47. package/web/file-uploader.min.d.ts +277 -105
  48. package/web/file-uploader.min.js +4 -4
  49. package/web/uc-basic.layered.min.css +2 -2
  50. package/web/uc-basic.min.css +2 -2
  51. package/web/uc-cloud-image-editor.layered.min.css +2 -2
  52. package/web/uc-cloud-image-editor.min.css +2 -2
  53. package/web/uc-cloud-image-editor.min.d.ts +159 -10
  54. package/web/uc-cloud-image-editor.min.js +4 -4
  55. package/web/uc-file-uploader-inline.layered.min.css +2 -2
  56. package/web/uc-file-uploader-inline.min.css +2 -2
  57. package/web/uc-file-uploader-inline.min.d.ts +277 -105
  58. package/web/uc-file-uploader-inline.min.js +4 -4
  59. package/web/uc-file-uploader-minimal.layered.min.css +2 -2
  60. package/web/uc-file-uploader-minimal.min.css +2 -2
  61. package/web/uc-file-uploader-minimal.min.d.ts +277 -105
  62. package/web/uc-file-uploader-minimal.min.js +4 -4
  63. package/web/uc-file-uploader-regular.layered.min.css +2 -2
  64. package/web/uc-file-uploader-regular.min.css +2 -2
  65. package/web/uc-file-uploader-regular.min.d.ts +277 -105
  66. package/web/uc-file-uploader-regular.min.js +4 -4
  67. package/web/uc-img.min.js +3 -3
@@ -2,8 +2,8 @@ import { LitElement, PropertyValues, TemplateResult, nothing } from 'lit';
2
2
  import * as lit_html from 'lit-html';
3
3
  import * as lit_html_directives_ref_js from 'lit-html/directives/ref.js';
4
4
  import * as _uploadcare_upload_client from '@uploadcare/upload-client';
5
- import { UploadcareFile, FileFromOptions, Metadata, Tags, UploadError, NetworkError, UploadcareGroup, Queue } from '@uploadcare/upload-client';
6
- export { Metadata, NetworkError, Tags, UploadError, UploadcareError, UploadcareFile, UploadcareGroup } from '@uploadcare/upload-client';
5
+ import { UploadcareFile, Metadata, Tags, AuthToken, FileFromOptions, UploadError, AuthTokenResolverError, NetworkError, UploadcareGroup, Queue } from '@uploadcare/upload-client';
6
+ export { AuthToken, AuthTokenResolverError, Metadata, NetworkError, Tags, UploadError, UploadcareError, UploadcareFile, UploadcareGroup } from '@uploadcare/upload-client';
7
7
  import { Ref } from 'lit/directives/ref.js';
8
8
  import { TelemetryRequest } from '@uploadcare/quality-insights';
9
9
 
@@ -252,21 +252,6 @@ declare class RouterHooksLayer extends SharedInstance {
252
252
  navigateAfterFileAdd(): void;
253
253
  }
254
254
 
255
- declare class A11y implements ISharedInstance {
256
- private _destroyKeyUX;
257
- private readonly _scopedWindow;
258
- constructor();
259
- registerBlock(scope: LitBlock): void;
260
- destroy(): void;
261
- }
262
-
263
- declare class LocaleManager extends SharedInstance {
264
- private _localeName;
265
- constructor(sharedInstancesBag: SharedInstancesBag);
266
- private _applyOverrides;
267
- private _applyPluginLocales;
268
- }
269
-
270
255
  /**
271
256
  * Custom configuration options registration system for plugins
272
257
  */
@@ -327,8 +312,6 @@ declare class CustomConfigRegistry {
327
312
  interface CustomConfig {
328
313
  }
329
314
 
330
- declare function buildOutputCollectionState<TCollectionStatus extends OutputCollectionStatus, TGroupFlag extends GroupFlag = 'maybe-has-group'>(bag: SharedInstancesBag): OutputCollectionState<TCollectionStatus, TGroupFlag>;
331
-
332
315
  declare class TypedData<T extends Record<string, unknown>> {
333
316
  private _ctxId;
334
317
  private _data;
@@ -341,6 +324,91 @@ declare class TypedData<T extends Record<string, unknown>> {
341
324
  destroy(): void;
342
325
  }
343
326
 
327
+ interface UploadEntryData extends Record<string, unknown> {
328
+ file: File | null;
329
+ externalUrl: string | null;
330
+ fileName: string | null;
331
+ fileSize: number | null;
332
+ lastModified: number;
333
+ uploadProgress: number;
334
+ uuid: string | null;
335
+ isImage: boolean;
336
+ mimeType: string | null;
337
+ ctxName: string | null;
338
+ cdnUrl: string | null;
339
+ cdnUrlModifiers: string | null;
340
+ fileInfo: UploadcareFile | null;
341
+ isUploading: boolean;
342
+ abortController: AbortController | null;
343
+ thumbUrl: string | null;
344
+ silent: boolean;
345
+ source: string | null;
346
+ fullPath: string | null;
347
+ metadata: Metadata | null;
348
+ tags: Tags | null;
349
+ errors: OutputErrorFile[];
350
+ uploadError: Error | null;
351
+ isRemoved: boolean;
352
+ isQueuedForUploading: boolean;
353
+ isValidationPending: boolean;
354
+ isQueuedForValidation: boolean;
355
+ }
356
+ type UploadEntryTypedData = TypedData<UploadEntryData>;
357
+ type UploadEntryKeys = keyof UploadEntryData;
358
+
359
+ declare class PluginRegistry {
360
+ private _sources;
361
+ private _activities;
362
+ private _fileActions;
363
+ private _fileHooks;
364
+ private _icons;
365
+ private _l10n;
366
+ readonly config: CustomConfigRegistry;
367
+ /**
368
+ * Notify consumers (LocaleManager, SourceListController, …) that the registry
369
+ * changed so they re-apply the new state. Coalesces a synchronous burst of
370
+ * registrations — a plugin's setup() typically registers an icon, a source,
371
+ * several l10n maps, … in one tick — into a single, deferred notification.
372
+ * Registrations can also happen lazily, long after setup() ran (e.g. a locale's
373
+ * strings loaded when `localeName` changes), which is why this exists.
374
+ */
375
+ private readonly _scheduleNotify;
376
+ constructor(onChange?: () => void);
377
+ /** Drop any pending notification (call on teardown). */
378
+ destroy(): void;
379
+ private _own;
380
+ addSource(pluginId: string, item: PluginSourceRegistration): void;
381
+ addActivity(pluginId: string, item: PluginActivityRegistration): void;
382
+ addFileAction(pluginId: string, item: PluginFileActionRegistration): void;
383
+ addFileHook(pluginId: string, item: PluginFileHookRegistration): void;
384
+ addIcon(pluginId: string, item: PluginIconRegistration): void;
385
+ addL10n(pluginId: string, item: PluginL10nRegistration): void;
386
+ addConfig<T>(pluginId: string, definition: CustomConfigDefinition<T>): void;
387
+ purge(pluginId: string): void;
388
+ snapshot(): PluginRegistrySnapshot;
389
+ }
390
+
391
+ declare class PluginManager extends SharedInstance {
392
+ private _plugins;
393
+ private _subscribers;
394
+ private _pluginsUpdate;
395
+ private _lazyPluginLoader;
396
+ readonly registry: PluginRegistry;
397
+ get configRegistry(): CustomConfigRegistry;
398
+ constructor(sharedInstancesBag: SharedInstancesBag);
399
+ pluginsReady(): Promise<void>;
400
+ onPluginsChange(callback: Unsubscriber): Unsubscriber;
401
+ private _syncPlugins;
402
+ private _registerPlugin;
403
+ private _unregisterPlugin;
404
+ snapshot(): PluginRegistrySnapshot;
405
+ runOnAddHooks(entry: UploadEntryTypedData): Promise<void>;
406
+ destroy(): void;
407
+ private _notifySubscribers;
408
+ }
409
+
410
+ declare function buildOutputCollectionState<TCollectionStatus extends OutputCollectionStatus, TGroupFlag extends GroupFlag = 'maybe-has-group'>(bag: SharedInstancesBag): OutputCollectionState<TCollectionStatus, TGroupFlag>;
411
+
344
412
  type FuncFileValidator = (outputEntry: OutputFileEntry, api: UploaderPublicApi, options?: {
345
413
  signal?: AbortSignal;
346
414
  }) => undefined | OutputErrorFile | Promise<undefined | OutputErrorFile>;
@@ -1351,6 +1419,12 @@ type ApiAddFileCommonOptions = {
1351
1419
  declare class UploaderPublicApi extends SharedInstance {
1352
1420
  private _l10n;
1353
1421
  get _uploadCollection(): TypedCollection<UploadEntryData>;
1422
+ /**
1423
+ * The failure of the last group creation, for the validator that reports it.
1424
+ * Underscored like `_uploadCollection`: internal, but a validator has no
1425
+ * other way to reach the context.
1426
+ */
1427
+ get _groupError(): Error | null;
1354
1428
  get cfg(): Readonly<ConfigType>;
1355
1429
  get l10n(): (str: string, variables?: Record<string, string | number>) => string;
1356
1430
  /**
@@ -1391,6 +1465,26 @@ declare class UploaderPublicApi extends SharedInstance {
1391
1465
  private _pluginsReady;
1392
1466
  setCurrentActivity: <T extends ActivityType>(activityType: T, ...params: T extends keyof ActivityParamsMap ? [ActivityParamsMap[T]] extends [never] ? [] : [ActivityParamsMap[T]] : []) => void;
1393
1467
  on: <T extends EventKey>(type: T, handler: (payload: EventPayload[T]) => void) => (() => void);
1468
+ /**
1469
+ * The auth token as `@uploadcare/upload-client` receives it: the configured
1470
+ * string, or a resolver whose result the uploader already caches.
1471
+ *
1472
+ * Forward this rather than `cfg.authToken` when something else has to
1473
+ * authenticate with the same token — a plugin, say — so it shares this cache
1474
+ * instead of calling your token endpoint again.
1475
+ */
1476
+ getAuthToken: () => AuthToken | undefined;
1477
+ /**
1478
+ * Drop the cached auth token, so the next request asks `authToken` for a new
1479
+ * one.
1480
+ *
1481
+ * Assigning a different function to `authToken` does not do this: a new
1482
+ * function identity is taken to be the same function, which is what lets a
1483
+ * React component pass an inline resolver without refetching on every render.
1484
+ * Call this when the change is real — the signed-in user changed, say — or
1485
+ * rely on short-lived tokens.
1486
+ */
1487
+ invalidateAuthToken: () => void;
1394
1488
  getCurrentActivity: () => ActivityType;
1395
1489
  historyBack: () => void;
1396
1490
  setModalState: (opened: boolean) => void;
@@ -1439,6 +1533,7 @@ declare class LitUploaderBlock extends LitActivityBlock {
1439
1533
  '*collectionErrors': OutputErrorCollection[];
1440
1534
  '*collectionState': OutputCollectionState | null;
1441
1535
  '*groupInfo': _uploadcare_upload_client.UploadcareGroup | null;
1536
+ '*groupError': Error | null;
1442
1537
  '*uploadTrigger': Set<string>;
1443
1538
  '*currentActivity': null;
1444
1539
  '*currentActivityParams': {};
@@ -1453,11 +1548,26 @@ declare class LitUploaderBlock extends LitActivityBlock {
1453
1548
  get api(): UploaderPublicApi;
1454
1549
  get uploadCollection(): TypedCollection<UploadEntryData>;
1455
1550
  get secureUploadsManager(): SecureUploadsManager;
1551
+ get authTokenManager(): AuthTokenManager;
1456
1552
  disconnectedCallback(): void;
1457
1553
  connectedCallback(): void;
1458
1554
  private _initCtxOwner;
1459
1555
  private _observeUploadCollection;
1460
1556
  private _unobserveUploadCollection;
1557
+ /** Bumped whenever the collection changes; see `_flushOutputItems`. */
1558
+ private _groupGeneration;
1559
+ /**
1560
+ * Creates the group for `collectionState` and reports the outcome, whichever
1561
+ * it is. Never rejects: the caller does not wait for the group, so a
1562
+ * rejection would have nowhere to go.
1563
+ *
1564
+ * A request cannot be cancelled once the API has it, so both outcomes are
1565
+ * dropped when the collection has moved on — a group of files that are no
1566
+ * longer the collection is neither its group nor its error. That is what the
1567
+ * generation tracks; `*collectionState` cannot, since it is republished on a
1568
+ * flush rather than on every change, and is still the same object at the
1569
+ * moment a mid-flight response lands.
1570
+ */
1461
1571
  private _createGroup;
1462
1572
  private _flushOutputItems;
1463
1573
  private _handleCollectionUpdate;
@@ -1606,11 +1716,67 @@ declare global {
1606
1716
  }
1607
1717
 
1608
1718
  /**
1609
- * Config keys that can't be passed as attribute (because they are object or function)
1719
+ * How a built-in config key relates to its DOM attribute — the same idea as a
1720
+ * plugin's {@link CustomConfigDefinition.attribute}, declared for built-ins.
1721
+ *
1722
+ * Both default to `true`; a key only appears here to opt out of something.
1723
+ * - `attribute: false` — property only, no attribute representation at all
1724
+ * (the value is an object or a function).
1725
+ * - `reflect: false` — readable from an attribute, but the value is never
1726
+ * written back to one.
1610
1727
  */
1611
- declare const complexConfigKeys: readonly ["metadata", "tags", "plugins", "localeDefinitionOverride", "secureUploadsSignatureResolver", "secureDeliveryProxyUrlResolver", "iconHrefResolver", "fileValidators", "collectionValidators", "mediaRecorderOptions"];
1728
+ type ConfigAttributeBehavior = {
1729
+ attribute?: boolean;
1730
+ reflect?: boolean;
1731
+ };
1732
+ declare const configAttributeBehavior: {
1733
+ readonly metadata: {
1734
+ readonly attribute: false;
1735
+ };
1736
+ readonly tags: {
1737
+ readonly attribute: false;
1738
+ };
1739
+ readonly plugins: {
1740
+ readonly attribute: false;
1741
+ };
1742
+ readonly localeDefinitionOverride: {
1743
+ readonly attribute: false;
1744
+ };
1745
+ readonly secureUploadsSignatureResolver: {
1746
+ readonly attribute: false;
1747
+ };
1748
+ readonly secureDeliveryProxyUrlResolver: {
1749
+ readonly attribute: false;
1750
+ };
1751
+ readonly iconHrefResolver: {
1752
+ readonly attribute: false;
1753
+ };
1754
+ readonly fileValidators: {
1755
+ readonly attribute: false;
1756
+ };
1757
+ readonly collectionValidators: {
1758
+ readonly attribute: false;
1759
+ };
1760
+ readonly mediaRecorderOptions: {
1761
+ readonly attribute: false;
1762
+ };
1763
+ /**
1764
+ * Settable either way: the attribute carries a plain token, the property also
1765
+ * accepts a resolver. Never reflected — a resolver has no attribute form, and
1766
+ * a bearer credential is not something to mirror into the DOM unasked.
1767
+ */
1768
+ readonly authToken: {
1769
+ readonly reflect: false;
1770
+ };
1771
+ };
1772
+ /** Keys of the descriptor whose `field` is declared as `Value`. */
1773
+ type KeysWithBehavior<Field extends keyof ConfigAttributeBehavior, Value extends boolean> = {
1774
+ [K in keyof typeof configAttributeBehavior]: (typeof configAttributeBehavior)[K] extends Record<Field, Value> ? K : never;
1775
+ }[keyof typeof configAttributeBehavior];
1776
+ /** Keys the descriptor marks as having no attribute representation at all. */
1777
+ type PropertyOnlyConfigKey = KeysWithBehavior<'attribute', false>;
1612
1778
  declare class Config extends LitBlock {
1613
- attributesMeta: Partial<ConfigPlainType> & {
1779
+ attributesMeta: Partial<AttributeConfigType> & {
1614
1780
  'ctx-name': string;
1615
1781
  };
1616
1782
  init$: LitBlock["init$"] & ConfigType;
@@ -1642,6 +1808,8 @@ declare class Config extends LitBlock {
1642
1808
  * Get attribute names for a config key (kebab-case and lowercase)
1643
1809
  */
1644
1810
  private _getAttributeNames;
1811
+ /** Whether this key's value is written back to the DOM as an attribute. */
1812
+ private _isReflectedToAttribute;
1645
1813
  private _flushValueToAttribute;
1646
1814
  private _flushValueToState;
1647
1815
  private _setValue;
@@ -2231,6 +2399,12 @@ type ConfigType = {
2231
2399
  * Resolver for secure uploads signature.
2232
2400
  */
2233
2401
  secureUploadsSignatureResolver: SecureUploadsSignatureResolver | null;
2402
+ /**
2403
+ * JWT for the Upload API `Authorization: Bearer <token>` scheme. Accepts a plain token or a resolver function; the
2404
+ * resolver is called before every request, so long-running uploads can supply a fresh token mid-flight. Takes
2405
+ * precedence over `secureSignature`/`secureExpire` and `secureUploadsSignatureResolver`.
2406
+ */
2407
+ authToken: AuthToken | null;
2234
2408
  /**
2235
2409
  * Resolver for secure delivery proxy URL.
2236
2410
  */
@@ -2307,9 +2481,32 @@ type ConfigType = {
2307
2481
  dynamicButtonViewMode: DynamicButtonMode;
2308
2482
  dynamicButtonShowFirstIcon: boolean;
2309
2483
  };
2310
- type ConfigComplexType = Pick<ConfigType, (typeof complexConfigKeys)[number]>;
2311
- type ConfigPlainType = Omit<ConfigType, keyof ConfigComplexType>;
2312
- type ConfigAttributesType = KebabCaseKeys<ConfigPlainType> & LowerCaseKeys<ConfigPlainType>;
2484
+ /** Options with no attribute representation: settable only as a DOM property. */
2485
+ type PropertyOnlyConfigType = Pick<ConfigType, PropertyOnlyConfigKey>;
2486
+ /** Options settable via an attribute (as well as as a property). */
2487
+ type AttributeConfigType = Omit<ConfigType, PropertyOnlyConfigKey>;
2488
+ /**
2489
+ * @deprecated Renamed to {@link PropertyOnlyConfigType}. Kept as an alias so
2490
+ * existing imports keep compiling.
2491
+ */
2492
+ type ConfigComplexType = PropertyOnlyConfigType;
2493
+ /**
2494
+ * @deprecated Renamed to {@link AttributeConfigType}. Kept as an alias so
2495
+ * existing imports keep compiling.
2496
+ */
2497
+ type ConfigPlainType = AttributeConfigType;
2498
+ /**
2499
+ * A DOM attribute can only ever carry a primitive, so an option whose value type
2500
+ * also admits an object or a function (`authToken` accepts a token *or* a
2501
+ * resolver) exposes only the primitive half here. Without this, JSX would
2502
+ * type-accept a function and silently stringify it into the DOM. For options
2503
+ * that are already primitive this is the identity.
2504
+ */
2505
+ type AttributeValue<T> = Extract<T, string | number | boolean | null | undefined>;
2506
+ type ConfigAttributeValues = {
2507
+ [K in keyof AttributeConfigType]: AttributeValue<AttributeConfigType[K]>;
2508
+ };
2509
+ type ConfigAttributesType = KebabCaseKeys<ConfigAttributeValues> & LowerCaseKeys<ConfigAttributeValues>;
2313
2510
  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;
2314
2511
  type KebabCaseKeys<T extends Record<string, unknown>> = {
2315
2512
  [Key in keyof T as KebabCase$1<Key & string>]: T[Key];
@@ -2320,8 +2517,8 @@ type LowerCaseKeys<T extends Record<string, unknown>> = {
2320
2517
  };
2321
2518
  type OutputFileStatus = 'idle' | 'uploading' | 'success' | 'failed' | 'removed';
2322
2519
  type OutputCustomErrorType = 'CUSTOM_ERROR';
2323
- type OutputFileErrorType = OutputCustomErrorType | 'NOT_AN_IMAGE' | 'FORBIDDEN_FILE_TYPE' | 'FILE_SIZE_EXCEEDED' | 'UPLOAD_ERROR' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
2324
- type OutputCollectionErrorType = OutputCustomErrorType | 'SOME_FILES_HAS_ERRORS' | 'TOO_MANY_FILES' | 'TOO_FEW_FILES';
2520
+ type OutputFileErrorType = OutputCustomErrorType | 'NOT_AN_IMAGE' | 'FORBIDDEN_FILE_TYPE' | 'FILE_SIZE_EXCEEDED' | 'UPLOAD_ERROR' | 'AUTH_TOKEN_ERROR' | 'NETWORK_ERROR' | 'UNKNOWN_ERROR';
2521
+ type OutputCollectionErrorType = OutputCustomErrorType | 'SOME_FILES_HAS_ERRORS' | 'GROUP_ERROR' | 'TOO_MANY_FILES' | 'TOO_FEW_FILES';
2325
2522
  type OutputFileErrorPayload = {
2326
2523
  entry: OutputFileEntry;
2327
2524
  };
@@ -2332,6 +2529,9 @@ type OutputErrorTypePayload = {
2332
2529
  SOME_FILES_HAS_ERRORS: {
2333
2530
  [k: string]: never;
2334
2531
  };
2532
+ GROUP_ERROR: {
2533
+ error: Error;
2534
+ };
2335
2535
  TOO_MANY_FILES: {
2336
2536
  min: number;
2337
2537
  max: number;
@@ -2345,6 +2545,9 @@ type OutputErrorTypePayload = {
2345
2545
  UPLOAD_ERROR: OutputFileErrorPayload & {
2346
2546
  error: UploadError;
2347
2547
  };
2548
+ AUTH_TOKEN_ERROR: OutputFileErrorPayload & {
2549
+ error: AuthTokenResolverError;
2550
+ };
2348
2551
  NETWORK_ERROR: OutputFileErrorPayload & {
2349
2552
  error: NetworkError;
2350
2553
  };
@@ -2648,87 +2851,47 @@ type EventMap = {
2648
2851
  [T in keyof EventPayload]: CustomEvent<EventPayload[T]>;
2649
2852
  };
2650
2853
 
2651
- interface UploadEntryData extends Record<string, unknown> {
2652
- file: File | null;
2653
- externalUrl: string | null;
2654
- fileName: string | null;
2655
- fileSize: number | null;
2656
- lastModified: number;
2657
- uploadProgress: number;
2658
- uuid: string | null;
2659
- isImage: boolean;
2660
- mimeType: string | null;
2661
- ctxName: string | null;
2662
- cdnUrl: string | null;
2663
- cdnUrlModifiers: string | null;
2664
- fileInfo: UploadcareFile | null;
2665
- isUploading: boolean;
2666
- abortController: AbortController | null;
2667
- thumbUrl: string | null;
2668
- silent: boolean;
2669
- source: string | null;
2670
- fullPath: string | null;
2671
- metadata: Metadata | null;
2672
- tags: Tags | null;
2673
- errors: OutputErrorFile[];
2674
- uploadError: Error | null;
2675
- isRemoved: boolean;
2676
- isQueuedForUploading: boolean;
2677
- isValidationPending: boolean;
2678
- isQueuedForValidation: boolean;
2854
+ /**
2855
+ * Owns the one long-lived token cache for this uploader context.
2856
+ *
2857
+ * `authToken` may be a resolver, and `@uploadcare/upload-client` calls it
2858
+ * before every authenticated request — so without a cache each upload, each
2859
+ * readiness poll and each multipart start/complete would hit the app's token
2860
+ * endpoint again. (Multipart chunks go to presigned storage URLs and carry no
2861
+ * token, so they are not part of that count.)
2862
+ */
2863
+ declare class AuthTokenManager extends SharedInstance {
2864
+ private _cache;
2865
+ /**
2866
+ * One function, the same one for the life of this manager, that reads the
2867
+ * configured resolver when it is called rather than capturing it.
2868
+ *
2869
+ * That stability is the point: whoever we hand this to can keep it, and it
2870
+ * still follows later changes to `authToken`. Returning the cache's own
2871
+ * `getToken` instead would mean re-reading it after every config change to
2872
+ * stay current, which is a rule nothing enforces.
2873
+ */
2874
+ private readonly _resolveAuthToken;
2875
+ /** The value to hand `@uploadcare/upload-client` as `authToken`. */
2876
+ getAuthToken(): AuthToken | undefined;
2877
+ /** Drop the cached token, e.g. once the signed-in user changes. */
2878
+ invalidate(): void;
2879
+ destroy(): void;
2679
2880
  }
2680
- type UploadEntryTypedData = TypedData<UploadEntryData>;
2681
- type UploadEntryKeys = keyof UploadEntryData;
2682
2881
 
2683
- declare class PluginRegistry {
2684
- private _sources;
2685
- private _activities;
2686
- private _fileActions;
2687
- private _fileHooks;
2688
- private _icons;
2689
- private _l10n;
2690
- readonly config: CustomConfigRegistry;
2691
- /**
2692
- * Notify consumers (LocaleManager, SourceListController, …) that the registry
2693
- * changed so they re-apply the new state. Coalesces a synchronous burst of
2694
- * registrations — a plugin's setup() typically registers an icon, a source,
2695
- * several l10n maps, … in one tick — into a single, deferred notification.
2696
- * Registrations can also happen lazily, long after setup() ran (e.g. a locale's
2697
- * strings loaded when `localeName` changes), which is why this exists.
2698
- */
2699
- private readonly _scheduleNotify;
2700
- constructor(onChange?: () => void);
2701
- /** Drop any pending notification (call on teardown). */
2882
+ declare class A11y implements ISharedInstance {
2883
+ private _destroyKeyUX;
2884
+ private readonly _scopedWindow;
2885
+ constructor();
2886
+ registerBlock(scope: LitBlock): void;
2702
2887
  destroy(): void;
2703
- private _own;
2704
- addSource(pluginId: string, item: PluginSourceRegistration): void;
2705
- addActivity(pluginId: string, item: PluginActivityRegistration): void;
2706
- addFileAction(pluginId: string, item: PluginFileActionRegistration): void;
2707
- addFileHook(pluginId: string, item: PluginFileHookRegistration): void;
2708
- addIcon(pluginId: string, item: PluginIconRegistration): void;
2709
- addL10n(pluginId: string, item: PluginL10nRegistration): void;
2710
- addConfig<T>(pluginId: string, definition: CustomConfigDefinition<T>): void;
2711
- purge(pluginId: string): void;
2712
- snapshot(): PluginRegistrySnapshot;
2713
2888
  }
2714
2889
 
2715
- declare class PluginManager extends SharedInstance {
2716
- private _plugins;
2717
- private _subscribers;
2718
- private _pluginsUpdate;
2719
- private _lazyPluginLoader;
2720
- readonly registry: PluginRegistry;
2721
- get configRegistry(): CustomConfigRegistry;
2890
+ declare class LocaleManager extends SharedInstance {
2891
+ private _localeName;
2722
2892
  constructor(sharedInstancesBag: SharedInstancesBag);
2723
- pluginsReady(): Promise<void>;
2724
- onPluginsChange(callback: Unsubscriber): Unsubscriber;
2725
- private _syncPlugins;
2726
- private _registerPlugin;
2727
- private _unregisterPlugin;
2728
- snapshot(): PluginRegistrySnapshot;
2729
- runOnAddHooks(entry: UploadEntryTypedData): Promise<void>;
2730
- destroy(): void;
2731
- private _notifySubscribers;
2893
+ private _applyOverrides;
2894
+ private _applyPluginLocales;
2732
2895
  }
2733
2896
 
2734
2897
  type CommonEventType = InternalEventKey | EventKey;
@@ -2795,6 +2958,7 @@ declare const instanceKeyMap: {
2795
2958
  eventEmitter: "*eventEmitter";
2796
2959
  uploadCollection: "*uploadCollection";
2797
2960
  secureUploadsManager: "*secureUploadsManager";
2961
+ authTokenManager: "*authTokenManager";
2798
2962
  api: "*publicApi";
2799
2963
  validationManager: "*validationManager";
2800
2964
  };
@@ -2816,6 +2980,7 @@ declare const createSharedInstancesBag: (getCtx: () => PubSub<SharedState>) => {
2816
2980
  readonly eventEmitter: EventEmitter;
2817
2981
  readonly uploadCollection: TypedCollection<UploadEntryData>;
2818
2982
  readonly secureUploadsManager: SecureUploadsManager;
2983
+ readonly authTokenManager: AuthTokenManager;
2819
2984
  readonly api: UploaderPublicApi;
2820
2985
  readonly validationManager: ValidationManager;
2821
2986
  when<TName extends InstanceName>(name: TName, callback: (instance: NonNullable<InstanceTypeMap[TName]>) => void): () => void;
@@ -2871,6 +3036,8 @@ type UploaderBlockCtxState = ActivityBlockCtxState & {
2871
3036
  '*collectionErrors': OutputErrorCollection[];
2872
3037
  '*collectionState': OutputCollectionState | null;
2873
3038
  '*groupInfo': UploadcareGroup | null;
3039
+ /** The failure of the last group creation, if it failed. */
3040
+ '*groupError': Error | null;
2874
3041
  '*uploadTrigger': Set<Uid>;
2875
3042
  };
2876
3043
  type SolutionBlockCtxState = UploaderBlockCtxState & {
@@ -2944,6 +3111,7 @@ type DynamicUploaderBlockState = {
2944
3111
  '*publicApi': UploaderPublicApi;
2945
3112
  '*validationManager': ValidationManager;
2946
3113
  '*secureUploadsManager': SecureUploadsManager;
3114
+ '*authTokenManager': AuthTokenManager;
2947
3115
  };
2948
3116
  type LocaleState = {
2949
3117
  [K in keyof LocaleDefinition as `*l10n/${K}`]: string;
@@ -2977,9 +3145,10 @@ declare class LitBlock extends LitBlockBase {
2977
3145
  readonly eventEmitter: EventEmitter;
2978
3146
  readonly uploadCollection: TypedCollection<UploadEntryData>;
2979
3147
  readonly secureUploadsManager: SecureUploadsManager;
3148
+ readonly authTokenManager: AuthTokenManager;
2980
3149
  readonly api: UploaderPublicApi;
2981
3150
  readonly validationManager: ValidationManager;
2982
- when<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "routerLayer" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "api" | "validationManager">(name: TName, callback: (instance: NonNullable<{
3151
+ when<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "routerLayer" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "authTokenManager" | "api" | "validationManager">(name: TName, callback: (instance: NonNullable<{
2983
3152
  modalManager: ModalManager | null;
2984
3153
  pluginManager: PluginManager;
2985
3154
  telemetryManager: TelemetryManager;
@@ -2991,10 +3160,11 @@ declare class LitBlock extends LitBlockBase {
2991
3160
  eventEmitter: EventEmitter;
2992
3161
  uploadCollection: TypedCollection<UploadEntryData>;
2993
3162
  secureUploadsManager: SecureUploadsManager;
3163
+ authTokenManager: AuthTokenManager;
2994
3164
  api: UploaderPublicApi;
2995
3165
  validationManager: ValidationManager;
2996
3166
  }[TName]>) => void): () => void;
2997
- wait<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "routerLayer" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "api" | "validationManager">(name: TName): Promise<NonNullable<{
3167
+ wait<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "routerLayer" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "authTokenManager" | "api" | "validationManager">(name: TName): Promise<NonNullable<{
2998
3168
  modalManager: ModalManager | null;
2999
3169
  pluginManager: PluginManager;
3000
3170
  telemetryManager: TelemetryManager;
@@ -3006,6 +3176,7 @@ declare class LitBlock extends LitBlockBase {
3006
3176
  eventEmitter: EventEmitter;
3007
3177
  uploadCollection: TypedCollection<UploadEntryData>;
3008
3178
  secureUploadsManager: SecureUploadsManager;
3179
+ authTokenManager: AuthTokenManager;
3009
3180
  api: UploaderPublicApi;
3010
3181
  validationManager: ValidationManager;
3011
3182
  }[TName]>>;
@@ -3137,6 +3308,7 @@ declare class LitSolutionBlock extends LitBlock {
3137
3308
  '*collectionErrors': OutputErrorCollection[];
3138
3309
  '*collectionState': OutputCollectionState | null;
3139
3310
  '*groupInfo': _uploadcare_upload_client.UploadcareGroup | null;
3311
+ '*groupError': Error | null;
3140
3312
  '*uploadTrigger': Set<string>;
3141
3313
  '*currentActivity': null;
3142
3314
  '*currentActivityParams': {};
@@ -3465,4 +3637,4 @@ declare global {
3465
3637
  declare const PACKAGE_NAME = "blocks";
3466
3638
  declare const PACKAGE_VERSION: string;
3467
3639
 
3468
- 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, PACKAGE_NAME, PACKAGE_VERSION, 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, loadFileUploaderFrom, toKebabCase };
3640
+ 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, PACKAGE_NAME, PACKAGE_VERSION, 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, loadFileUploaderFrom, toKebabCase };