@uploadcare/file-uploader 1.26.2 → 1.27.0-alpha.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 (85) hide show
  1. package/dist/CloudImageEditorActivity-7EK7P3UP.js +1 -0
  2. package/dist/CloudImageEditorActivity-HGSS7NV2.css +8 -0
  3. package/dist/CloudImageEditorActivity-HGSS7NV2.layered.css +7 -0
  4. package/dist/abstract/loadFileUploaderFrom.js +2 -2
  5. package/dist/chunk-5OA6ZVWQ.js +7 -0
  6. package/dist/chunk-BDD5ZPFI.js +7 -0
  7. package/dist/chunk-GCTQN3DZ.js +7 -0
  8. package/dist/chunk-LNXFGGSC.js +7 -0
  9. package/dist/chunk-NJ77GRVX.js +8 -0
  10. package/dist/chunk-TVCYFFRR.js +7 -0
  11. package/dist/cloud-image-editor-PX6YZMOH.css +6 -0
  12. package/dist/cloud-image-editor-PX6YZMOH.layered.css +7 -0
  13. package/dist/cloud-image-editor-Q5333S7T.js +1 -0
  14. package/dist/cloudImageEditorPlugin-BE5HU2W4.js +8 -0
  15. package/dist/cloudImageEditorPlugin-WZCVZALK.css +6 -0
  16. package/dist/cloudImageEditorPlugin-WZCVZALK.layered.css +7 -0
  17. package/dist/core.css +6 -0
  18. package/dist/core.d.ts +3168 -0
  19. package/dist/core.js +8 -0
  20. package/dist/core.layered.css +7 -0
  21. package/dist/env.js +3 -3
  22. package/dist/index.css +3 -3
  23. package/dist/index.d.ts +433 -106
  24. package/dist/index.js +5 -5
  25. package/dist/index.layered.css +3 -3
  26. package/dist/index.ssr.js +96 -6
  27. package/dist/locales/file-uploader/ar.js +2 -2
  28. package/dist/locales/file-uploader/az.js +2 -2
  29. package/dist/locales/file-uploader/ca.js +2 -2
  30. package/dist/locales/file-uploader/cs.js +2 -2
  31. package/dist/locales/file-uploader/da.js +2 -2
  32. package/dist/locales/file-uploader/de.js +2 -2
  33. package/dist/locales/file-uploader/el.js +2 -2
  34. package/dist/locales/file-uploader/en.js +2 -2
  35. package/dist/locales/file-uploader/es.js +2 -2
  36. package/dist/locales/file-uploader/et.js +2 -2
  37. package/dist/locales/file-uploader/fi.js +2 -2
  38. package/dist/locales/file-uploader/fr.js +2 -2
  39. package/dist/locales/file-uploader/he.js +2 -2
  40. package/dist/locales/file-uploader/hy.js +2 -2
  41. package/dist/locales/file-uploader/is.js +2 -2
  42. package/dist/locales/file-uploader/it.js +2 -2
  43. package/dist/locales/file-uploader/ja.js +2 -2
  44. package/dist/locales/file-uploader/ka.js +2 -2
  45. package/dist/locales/file-uploader/kk.js +2 -2
  46. package/dist/locales/file-uploader/ko.js +2 -2
  47. package/dist/locales/file-uploader/lv.js +2 -2
  48. package/dist/locales/file-uploader/nb.js +2 -2
  49. package/dist/locales/file-uploader/nl.js +2 -2
  50. package/dist/locales/file-uploader/pl.js +2 -2
  51. package/dist/locales/file-uploader/pt.js +2 -2
  52. package/dist/locales/file-uploader/ro.js +2 -2
  53. package/dist/locales/file-uploader/ru.js +2 -2
  54. package/dist/locales/file-uploader/sk.js +2 -2
  55. package/dist/locales/file-uploader/sr.js +2 -2
  56. package/dist/locales/file-uploader/sv.js +2 -2
  57. package/dist/locales/file-uploader/tr.js +2 -2
  58. package/dist/locales/file-uploader/uk.js +2 -2
  59. package/dist/locales/file-uploader/vi.js +2 -2
  60. package/dist/locales/file-uploader/zh-TW.js +2 -2
  61. package/dist/locales/file-uploader/zh.js +2 -2
  62. package/package.json +11 -1
  63. package/web/file-uploader.iife.min.d.ts +433 -106
  64. package/web/file-uploader.iife.min.js +4 -4
  65. package/web/file-uploader.min.d.ts +433 -106
  66. package/web/file-uploader.min.js +4 -4
  67. package/web/uc-basic.layered.min.css +3 -3
  68. package/web/uc-basic.min.css +3 -3
  69. package/web/uc-cloud-image-editor.layered.min.css +3 -3
  70. package/web/uc-cloud-image-editor.min.css +3 -3
  71. package/web/uc-cloud-image-editor.min.d.ts +518 -191
  72. package/web/uc-cloud-image-editor.min.js +4 -4
  73. package/web/uc-file-uploader-inline.layered.min.css +3 -3
  74. package/web/uc-file-uploader-inline.min.css +3 -3
  75. package/web/uc-file-uploader-inline.min.d.ts +433 -106
  76. package/web/uc-file-uploader-inline.min.js +4 -4
  77. package/web/uc-file-uploader-minimal.layered.min.css +3 -3
  78. package/web/uc-file-uploader-minimal.min.css +3 -3
  79. package/web/uc-file-uploader-minimal.min.d.ts +433 -106
  80. package/web/uc-file-uploader-minimal.min.js +4 -4
  81. package/web/uc-file-uploader-regular.layered.min.css +3 -3
  82. package/web/uc-file-uploader-regular.min.css +3 -3
  83. package/web/uc-file-uploader-regular.min.d.ts +433 -106
  84. package/web/uc-file-uploader-regular.min.js +4 -4
  85. package/web/uc-img.min.js +4 -4
@@ -220,17 +220,77 @@ type LocaleDefinition = typeof _default;
220
220
  type LocaleDefinitionResolver = () => Promise<LocaleDefinition>;
221
221
  declare const defineLocale: (localeName: string, definitionOrResolver: LocaleDefinition | LocaleDefinitionResolver) => void;
222
222
 
223
- declare class A11y implements ISharedInstance {
224
- private _destroyKeyUX;
225
- private readonly _scopedWindow;
226
- constructor();
227
- registerBlock(scope: LitBlock): void;
228
- destroy(): void;
229
- }
230
-
231
223
  declare class LocaleManager extends SharedInstance {
232
224
  private _localeName;
233
225
  constructor(sharedInstancesBag: SharedInstancesBag);
226
+ private _applyOverrides;
227
+ private _applyPluginLocales;
228
+ }
229
+
230
+ /**
231
+ * Custom configuration options registration system for plugins
232
+ */
233
+ type CustomConfigDefinition<T = unknown> = {
234
+ /**
235
+ * Config option name (will be used as property and optionally as attribute)
236
+ */
237
+ name: string;
238
+ /**
239
+ * Default value for the config option
240
+ */
241
+ defaultValue: T;
242
+ /**
243
+ * Whether this config can be set via HTML attribute
244
+ * @default true
245
+ */
246
+ attribute?: boolean;
247
+ /**
248
+ * Convert attribute string to config value
249
+ * Only used if attribute is true
250
+ */
251
+ fromAttribute?: (value: string | null) => T;
252
+ /**
253
+ * Convert config value to attribute string
254
+ * Only used if attribute is true
255
+ */
256
+ toAttribute?: (value: T) => string | null;
257
+ /**
258
+ * Normalize/validate the config value
259
+ */
260
+ normalize?: (value: unknown) => T;
261
+ };
262
+ /**
263
+ * Registry for custom config options defined by plugins
264
+ * This is managed by the PluginManager as a shared instance property
265
+ */
266
+ declare class CustomConfigRegistry {
267
+ private _definitions;
268
+ register<T = unknown>(pluginId: string, definition: CustomConfigDefinition<T>): void;
269
+ unregister(name: string): void;
270
+ unregisterByPlugin(pluginId: string): void;
271
+ get(name: string): CustomConfigDefinition<any> | undefined;
272
+ getAll(): Map<string, CustomConfigDefinition<any>>;
273
+ }
274
+ /**
275
+ * Interface for TypeScript module augmentation
276
+ * Plugins should extend this interface to add their custom config types
277
+ *
278
+ * @example
279
+ * ```typescript
280
+ * declare module '@uploadcare/file-uploader' {
281
+ * interface CustomConfig {
282
+ * 'my-custom-option': string;
283
+ * }
284
+ * }
285
+ * ```
286
+ */
287
+ interface CustomConfig {
288
+ }
289
+
290
+ declare class SecureUploadsManager extends SharedInstance {
291
+ private _secureToken;
292
+ getSecureToken(): Promise<SecureUploadsSignatureAndExpire | null>;
293
+ destroy(): void;
234
294
  }
235
295
 
236
296
  declare class TypedData<T extends Record<string, unknown>> {
@@ -359,7 +419,7 @@ declare class UploaderPublicApi extends SharedInstance {
359
419
  getOutputCollectionState<TStatus extends OutputCollectionStatus>(): ReturnType<typeof buildOutputCollectionState<TStatus>>;
360
420
  initFlow: (force?: boolean) => void;
361
421
  doneFlow: () => void;
362
- setCurrentActivity: <T extends RegisteredActivityType>(activityType: T, ...params: T extends keyof ActivityParamsMap ? [ActivityParamsMap[T]] : T extends RegisteredActivityType ? [undefined?] : [never]) => void;
422
+ setCurrentActivity: <T extends ActivityType>(activityType: T, ...params: T extends keyof ActivityParamsMap ? [ActivityParamsMap[T]] extends [never] ? [] : [ActivityParamsMap[T]] : []) => void;
363
423
  getCurrentActivity: () => ActivityType;
364
424
  setModalState: (opened: boolean) => void;
365
425
  private get _sourceList();
@@ -559,11 +619,14 @@ declare global {
559
619
  declare class Icon extends LitBlock {
560
620
  name: string;
561
621
  private _resolvedHref;
622
+ private _pluginSvg;
562
623
  private _iconHrefResolver;
624
+ private _unsubscribePlugins?;
563
625
  initCallback(): void;
564
626
  protected willUpdate(changedProperties: PropertyValues<this>): void;
565
627
  private _updateResolvedHref;
566
628
  render(): lit_html.TemplateResult<1>;
629
+ disconnectedCallback(): void;
567
630
  }
568
631
  declare global {
569
632
  interface HTMLElementTagNameMap {
@@ -1143,12 +1206,11 @@ type ActivityParams$1 = {
1143
1206
  internalId: string;
1144
1207
  };
1145
1208
  declare class CloudImageEditorActivity extends LitUploaderBlock {
1146
- couldBeCtxOwner: boolean;
1147
- activityType: "cloud-image-edit";
1148
1209
  private _entry?;
1149
1210
  private _editorConfig;
1150
1211
  get activityParams(): ActivityParams$1;
1151
1212
  initCallback(): void;
1213
+ disconnectedCallback(): void;
1152
1214
  private _handleApply;
1153
1215
  private _handleCancel;
1154
1216
  handleChange(event: CustomEvent<ChangeResult>): void;
@@ -1235,13 +1297,17 @@ declare const ACTIVITY_TYPES: Readonly<{
1235
1297
  CLOUD_IMG_EDIT: "cloud-image-edit";
1236
1298
  EXTERNAL: "external";
1237
1299
  }>;
1238
- type RegisteredActivityType = (typeof ACTIVITY_TYPES)[keyof typeof ACTIVITY_TYPES];
1239
- type ActivityType = RegisteredActivityType | (string & {}) | null;
1300
+ type RegisteredActivityType = (typeof ACTIVITY_TYPES)[keyof typeof ACTIVITY_TYPES] | keyof CustomActivities;
1301
+ type ActivityType = RegisteredActivityType | null;
1240
1302
 
1241
1303
  declare const ACTIVE_PROP = "___ACTIVITY_IS_ACTIVE___";
1304
+ interface CustomActivities {
1305
+ }
1242
1306
  type ActivityParamsMap = {
1243
1307
  'cloud-image-edit': ActivityParams$1;
1244
1308
  external: ActivityParams;
1309
+ } & {
1310
+ [Key in keyof CustomActivities]: CustomActivities[Key]['params'];
1245
1311
  };
1246
1312
  declare class LitActivityBlock extends LitBlock {
1247
1313
  protected historyTracked: boolean;
@@ -1258,7 +1324,7 @@ declare class LitActivityBlock extends LitBlock {
1258
1324
  private _activate;
1259
1325
  initCallback(): void;
1260
1326
  private _historyFlush;
1261
- private _isActivityRegistered;
1327
+ protected _isActivityRegistered(): boolean;
1262
1328
  private static _activityCallbacks;
1263
1329
  static activities: Readonly<{
1264
1330
  START_FROM: 'start-from';
@@ -1279,8 +1345,8 @@ declare class LitActivityBlock extends LitBlock {
1279
1345
  private _unregisterActivity;
1280
1346
  disconnectedCallback(): void;
1281
1347
  get activityParams(): ActivityParamsMap[keyof ActivityParamsMap];
1282
- get initActivity(): string | null;
1283
- get doneActivity(): string | null;
1348
+ get initActivity(): RegisteredActivityType | null;
1349
+ get doneActivity(): RegisteredActivityType | null;
1284
1350
  historyBack(): void;
1285
1351
  }
1286
1352
 
@@ -1354,6 +1420,35 @@ type EventMap = {
1354
1420
  [T in keyof EventPayload]: CustomEvent<EventPayload[T]>;
1355
1421
  };
1356
1422
 
1423
+ type FuncFileValidator = (outputEntry: OutputFileEntry, api: UploaderPublicApi, options?: {
1424
+ signal?: AbortSignal;
1425
+ }) => undefined | OutputErrorFile | Promise<undefined | OutputErrorFile>;
1426
+ type FileValidatorDescriptor = {
1427
+ runOn: 'add' | 'upload' | 'change';
1428
+ validator: FuncFileValidator;
1429
+ };
1430
+ type FileValidator = FileValidatorDescriptor | FuncFileValidator;
1431
+ type FuncCollectionValidator = (collection: ReturnType<typeof buildOutputCollectionState<OutputCollectionStatus>>, api: UploaderPublicApi) => undefined | OutputErrorCollection;
1432
+ declare class ValidationManager extends SharedInstance {
1433
+ private get _uploadCollection();
1434
+ private _commonFileValidators;
1435
+ private _commonCollectionValidators;
1436
+ private _queue;
1437
+ private _runQueueDebounced;
1438
+ private _isDestroyed;
1439
+ private _entryValidationState;
1440
+ constructor(sharedInstancesBag: SharedInstancesBag);
1441
+ runFileValidators(runOn: FileValidatorDescriptor['runOn'], entryIds?: Uid[]): void;
1442
+ runCollectionValidators(): void;
1443
+ cleanupValidationForEntry(entry: TypedData<UploadEntryData>): void;
1444
+ private _runFileValidatorsForEntry;
1445
+ private _addCustomTypeToValidationError;
1446
+ private _getEntryValidationState;
1447
+ private _getValidatorDescriptors;
1448
+ private _getValidatorDescriptorsForEntry;
1449
+ destroy(): void;
1450
+ }
1451
+
1357
1452
  type SelectOption = {
1358
1453
  text: string;
1359
1454
  value: string;
@@ -1494,25 +1589,54 @@ declare global {
1494
1589
  /**
1495
1590
  * Config keys that can't be passed as attribute (because they are object or function)
1496
1591
  */
1497
- declare const complexConfigKeys: readonly ["metadata", "localeDefinitionOverride", "secureUploadsSignatureResolver", "secureDeliveryProxyUrlResolver", "iconHrefResolver", "fileValidators", "collectionValidators", "mediaRecorderOptions"];
1498
- /** Mapping of attribute names to state */
1499
- declare const attrStateMapping: Record<string, string>;
1592
+ declare const complexConfigKeys: readonly ["metadata", "plugins", "localeDefinitionOverride", "secureUploadsSignatureResolver", "secureDeliveryProxyUrlResolver", "iconHrefResolver", "fileValidators", "collectionValidators", "mediaRecorderOptions"];
1500
1593
  declare class Config extends LitBlock {
1501
1594
  attributesMeta: Partial<ConfigPlainType> & {
1502
1595
  'ctx-name': string;
1503
1596
  };
1504
1597
  init$: LitBlock["init$"] & ConfigType;
1505
1598
  private _computationControllers;
1599
+ private _pluginChangeUnsubscribe?;
1600
+ private _mutationObserver?;
1601
+ /**
1602
+ * Mapping of attribute names to custom config keys for plugin-registered configs.
1603
+ * Updated dynamically when plugins are registered or changed.
1604
+ * Similar to builtinAttrKeyMapping but for custom configs.
1605
+ */
1606
+ private _customAttrKeyMapping;
1607
+ /** Set of all custom config names registered by plugins */
1608
+ private _customConfigKeys;
1609
+ /**
1610
+ * Map of custom config subscriptions (config name -> unsubscribe function)
1611
+ * Used to track and clean up subscriptions when plugins change
1612
+ */
1613
+ private _customConfigSubscriptions;
1614
+ /**
1615
+ * Check if a key is a custom config (registered by plugins)
1616
+ */
1617
+ private _isCustomConfig;
1618
+ /**
1619
+ * Get the custom config definition for a key
1620
+ */
1621
+ private _getCustomConfigDefinition;
1622
+ /**
1623
+ * Get attribute names for a config key (kebab-case and lowercase)
1624
+ */
1625
+ private _getAttributeNames;
1506
1626
  private _flushValueToAttribute;
1507
1627
  private _flushValueToState;
1508
1628
  private _setValue;
1509
1629
  private _getValue;
1510
1630
  private _assertSameValueDifferentReference;
1631
+ private _processCustomConfigs;
1632
+ private _setupCustomConfigs;
1633
+ private _setupMutationObserver;
1511
1634
  initCallback(): void;
1512
- attributeChangedCallback(name: keyof typeof attrStateMapping, oldVal: string, newVal: string): void;
1635
+ attributeChangedCallback(name: string, oldVal: string, newVal: string): void;
1636
+ disconnectedCallback(): void;
1513
1637
  static get observedAttributes(): string[];
1514
1638
  }
1515
- interface Config extends ConfigType {
1639
+ interface Config extends ConfigType, CustomConfig {
1516
1640
  }
1517
1641
  declare global {
1518
1642
  interface HTMLElementTagNameMap {
@@ -1596,12 +1720,12 @@ declare class FileItem extends FileItemConfig {
1596
1720
  private _isFailed;
1597
1721
  private _isUploading;
1598
1722
  private _isFocused;
1599
- private _isEditable;
1600
1723
  private _showFileNames;
1601
1724
  private _ariaLabelStatusFile;
1725
+ private _pluginFileActions;
1602
1726
  private _renderedOnce;
1603
1727
  private _observer?;
1604
- private _handleEdit;
1728
+ private _unsubscribePlugins?;
1605
1729
  private _handleRemove;
1606
1730
  private _handleUploadClick;
1607
1731
  private _calculateState;
@@ -1613,6 +1737,8 @@ declare class FileItem extends FileItemConfig {
1613
1737
  private _handleEntryId;
1614
1738
  private _updateShowFileNames;
1615
1739
  protected willUpdate(changedProperties: PropertyValues<this>): void;
1740
+ private _updatePluginFileActions;
1741
+ private _handlePluginFileAction;
1616
1742
  initCallback(): void;
1617
1743
  connectedCallback(): void;
1618
1744
  disconnectedCallback(): void;
@@ -1917,6 +2043,10 @@ type ConfigType = {
1917
2043
  * Expiry threshold for secure uploads.
1918
2044
  */
1919
2045
  secureUploadsExpireThreshold: number;
2046
+ /**
2047
+ * Array of plugins to register with the uploader instance.
2048
+ */
2049
+ plugins: UploaderPlugin[];
1920
2050
  /**
1921
2051
  * Metadata for the file.
1922
2052
  */
@@ -2173,10 +2303,162 @@ type OutputCollectionState<TStatus extends OutputCollectionStatus = OutputCollec
2173
2303
  allEntries: OutputFileEntry[];
2174
2304
  });
2175
2305
 
2176
- declare class SecureUploadsManager extends SharedInstance {
2177
- private _secureToken;
2178
- getSecureToken(): Promise<SecureUploadsSignatureAndExpire | null>;
2306
+ type PluginVersion = string;
2307
+ type PluginIconRegistration = {
2308
+ name: string;
2309
+ svg: string;
2310
+ };
2311
+ type PluginI18nRegistration = Record<string, Record<string, string>>;
2312
+ type PluginSourceRegistration = {
2313
+ id: string;
2314
+ label: string;
2315
+ icon?: string;
2316
+ onSelect: () => Promise<void> | void;
2317
+ };
2318
+ type PluginRenderDispose = () => void;
2319
+ type PluginRender = (el: HTMLElement, activityParams: Record<string, unknown>) => PluginRenderDispose | undefined;
2320
+ type PluginActivityRegistration = {
2321
+ id: string;
2322
+ render: PluginRender;
2323
+ };
2324
+ type PluginFileActionRegistration = {
2325
+ id: string;
2326
+ icon: string;
2327
+ shouldRender: (fileEntry: OutputFileEntry) => boolean;
2328
+ onClick: (fileEntry: OutputFileEntry) => void | Promise<void>;
2329
+ };
2330
+ type PluginRegistryApi = {
2331
+ registerSource: (source: PluginSourceRegistration) => PluginSourceRegistration;
2332
+ registerActivity: (activity: PluginActivityRegistration) => PluginActivityRegistration;
2333
+ registerFileAction: (fileAction: PluginFileActionRegistration) => PluginFileActionRegistration;
2334
+ registerIcon: (icon: PluginIconRegistration) => PluginIconRegistration;
2335
+ registerI18n: (i18n: PluginI18nRegistration) => PluginI18nRegistration;
2336
+ registerConfig: <T = unknown>(definition: CustomConfigDefinition<T>) => void;
2337
+ };
2338
+ /**
2339
+ * API for managing plugin config subscriptions
2340
+ */
2341
+ type PluginConfigApi = {
2342
+ /**
2343
+ * Get the current value of a config option.
2344
+ *
2345
+ * @param configName - The name of the config to get
2346
+ * @returns The current config value
2347
+ *
2348
+ * @example
2349
+ * ```typescript
2350
+ * const theme = pluginApi.config.get('my-theme');
2351
+ * console.log('Current theme:', theme);
2352
+ * ```
2353
+ */
2354
+ get: <T = unknown>(configName: keyof (ConfigType & CustomConfig)) => T;
2355
+ /**
2356
+ * Subscribe to changes in a custom config value.
2357
+ * The callback will be called immediately with the current value,
2358
+ * and then whenever the value changes.
2359
+ *
2360
+ * Subscriptions are automatically cleaned up when the plugin is disposed.
2361
+ *
2362
+ * @param configName - The name of the custom config to subscribe to
2363
+ * @param callback - Function to call with the new value
2364
+ * @returns Unsubscribe function
2365
+ *
2366
+ * @example
2367
+ * ```typescript
2368
+ * pluginApi.config.subscribe('my-option', (value) => {
2369
+ * console.log('Config changed:', value);
2370
+ * });
2371
+ * // Cleanup happens automatically on plugin disposal
2372
+ * ```
2373
+ */
2374
+ subscribe: <T = unknown>(configName: keyof (ConfigType & CustomConfig), callback: (value: T) => void) => () => void;
2375
+ };
2376
+ /**
2377
+ * API for managing plugin activity interactions
2378
+ */
2379
+ type PluginActivityApi = {
2380
+ /**
2381
+ * Get the current activity parameters.
2382
+ *
2383
+ * @returns The current activity parameters object
2384
+ *
2385
+ * @example
2386
+ * ```typescript
2387
+ * const params = pluginApi.activity.getParams();
2388
+ * console.log('Current params:', params);
2389
+ * ```
2390
+ */
2391
+ getParams: () => Record<string, unknown>;
2392
+ /**
2393
+ * Subscribe to changes in activity parameters.
2394
+ * The callback will be called immediately with the current params,
2395
+ * and then whenever the params change.
2396
+ *
2397
+ * Subscriptions are automatically cleaned up when the plugin is disposed.
2398
+ *
2399
+ * @param callback - Function to call with the new params
2400
+ * @returns Unsubscribe function
2401
+ *
2402
+ * @example
2403
+ * ```typescript
2404
+ * pluginApi.activity.subscribeToParams((params) => {
2405
+ * console.log('Activity params changed:', params);
2406
+ * });
2407
+ * // Cleanup happens automatically on plugin disposal
2408
+ * ```
2409
+ */
2410
+ subscribeToParams: (callback: (params: Record<string, unknown>) => void) => () => void;
2411
+ };
2412
+ type PluginApi = {
2413
+ registry: PluginRegistryApi;
2414
+ config: PluginConfigApi;
2415
+ activity: PluginActivityApi;
2416
+ };
2417
+ type PluginUploaderApi = UploaderPublicApi;
2418
+ type PluginExports = {
2419
+ dispose?: () => void;
2420
+ };
2421
+ type PluginSetupResult = PluginExports | void | Promise<PluginExports | void>;
2422
+ type PluginSetupParams = {
2423
+ pluginApi: PluginApi;
2424
+ uploaderApi: PluginUploaderApi;
2425
+ };
2426
+ type UploaderPlugin = {
2427
+ id: string;
2428
+ version: PluginVersion;
2429
+ setup: (params: PluginSetupParams) => PluginSetupResult;
2430
+ };
2431
+ type Owned<T> = T & {
2432
+ pluginId: string;
2433
+ };
2434
+ type PluginRegistrySnapshot = {
2435
+ sources: Owned<PluginSourceRegistration>[];
2436
+ activities: Owned<PluginActivityRegistration>[];
2437
+ fileActions: Owned<PluginFileActionRegistration>[];
2438
+ icons: Owned<PluginIconRegistration>[];
2439
+ i18n: Owned<PluginI18nRegistration>[];
2440
+ };
2441
+
2442
+ declare class PluginManager extends SharedInstance {
2443
+ private _plugins;
2444
+ private _sources;
2445
+ private _activities;
2446
+ private _fileActions;
2447
+ private _icons;
2448
+ private _i18n;
2449
+ private _subscribers;
2450
+ private _pluginsUpdate;
2451
+ readonly configRegistry: CustomConfigRegistry;
2452
+ constructor(sharedInstancesBag: SharedInstancesBag);
2453
+ onPluginsChange(callback: () => void): () => void;
2454
+ private _syncPlugins;
2455
+ private _registerPlugin;
2456
+ private _unregisterPlugin;
2457
+ snapshot(): PluginRegistrySnapshot;
2179
2458
  destroy(): void;
2459
+ private _register;
2460
+ private _purgeRegistrations;
2461
+ private _notifySubscribers;
2180
2462
  }
2181
2463
 
2182
2464
  type CommonEventType = InternalEventKey | EventKey;
@@ -2217,14 +2499,71 @@ declare class TelemetryManager extends SharedInstance {
2217
2499
  private get _location();
2218
2500
  }
2219
2501
 
2502
+ interface ISharedInstance {
2503
+ destroy?(): void;
2504
+ }
2505
+ declare class SharedInstance {
2506
+ protected _ctx: PubSub<SharedState>;
2507
+ protected _sharedInstancesBag: SharedInstancesBag;
2508
+ private _subscriptions;
2509
+ private _cfgProxy;
2510
+ protected _debugPrint: (...args: unknown[]) => void;
2511
+ constructor(sharedInstancesBag: SharedInstancesBag);
2512
+ protected addSub(unsub: () => void): void;
2513
+ protected get _cfg(): Readonly<ConfigType>;
2514
+ destroy(): void;
2515
+ }
2516
+ declare const instanceKeyMap: {
2517
+ modalManager: "*modalManager";
2518
+ pluginManager: "*pluginManager";
2519
+ telemetryManager: "*telemetryManager";
2520
+ localeManager: "*localeManager";
2521
+ a11y: "*a11y";
2522
+ blocksRegistry: "*blocksRegistry";
2523
+ eventEmitter: "*eventEmitter";
2524
+ uploadCollection: "*uploadCollection";
2525
+ secureUploadsManager: "*secureUploadsManager";
2526
+ api: "*publicApi";
2527
+ validationManager: "*validationManager";
2528
+ };
2529
+ type InstanceTypeMap = {
2530
+ [key in keyof typeof instanceKeyMap]: SharedState[(typeof instanceKeyMap)[key]];
2531
+ };
2532
+ type InstanceName = keyof typeof instanceKeyMap;
2533
+ type SharedInstancesState = Pick<SharedState, (typeof instanceKeyMap)[keyof typeof instanceKeyMap]>;
2534
+ type SharedInstancesBag = ReturnType<typeof createSharedInstancesBag>;
2535
+ declare const createSharedInstancesBag: (getCtx: () => PubSub<SharedState>) => {
2536
+ readonly ctx: PubSub<SharedState>;
2537
+ readonly modalManager: ModalManager | null;
2538
+ readonly pluginManager: PluginManager;
2539
+ readonly telemetryManager: TelemetryManager;
2540
+ readonly localeManager: LocaleManager;
2541
+ readonly a11y: A11y;
2542
+ readonly blocksRegistry: Set<LitBlock>;
2543
+ readonly eventEmitter: EventEmitter;
2544
+ readonly uploadCollection: TypedCollection<UploadEntryData>;
2545
+ readonly secureUploadsManager: SecureUploadsManager;
2546
+ readonly api: UploaderPublicApi;
2547
+ readonly validationManager: ValidationManager;
2548
+ when<TName extends InstanceName>(name: TName, callback: (instance: NonNullable<InstanceTypeMap[TName]>) => void): () => void;
2549
+ };
2550
+
2551
+ declare class A11y implements ISharedInstance {
2552
+ private _destroyKeyUX;
2553
+ private readonly _scopedWindow;
2554
+ constructor();
2555
+ registerBlock(scope: LitBlock): void;
2556
+ destroy(): void;
2557
+ }
2558
+
2220
2559
  type SharedConfigState = {
2221
2560
  [K in keyof ConfigType as `*cfg/${K}`]: ConfigType[K];
2222
2561
  };
2223
2562
  type BlocksRegistry = Set<LitBlock>;
2224
2563
  type ActivityBlockCtxState = {
2225
- '*currentActivity': string | null;
2564
+ '*currentActivity': RegisteredActivityType | null;
2226
2565
  '*currentActivityParams': Record<string, unknown>;
2227
- '*history': (string | null)[];
2566
+ '*history': (RegisteredActivityType | null)[];
2228
2567
  '*historyBack': (() => void) | null;
2229
2568
  '*closeModal': () => void;
2230
2569
  };
@@ -2291,13 +2630,16 @@ type EditorToolbarState = {
2291
2630
  '*currentOperation': string | null;
2292
2631
  '*operationTooltip': string | null;
2293
2632
  };
2633
+ type SharedContextInstances = Map<string, ISharedInstance>;
2294
2634
  type DynamicBlockState = {
2635
+ '*sharedContextInstances': SharedContextInstances;
2295
2636
  '*blocksRegistry': BlocksRegistry;
2296
2637
  '*eventEmitter': EventEmitter;
2297
2638
  '*localeManager': LocaleManager;
2298
2639
  '*telemetryManager': TelemetryManager;
2299
2640
  '*a11y': A11y;
2300
2641
  '*modalManager': ModalManager | null;
2642
+ '*pluginManager': PluginManager;
2301
2643
  };
2302
2644
  type DynamicUploaderBlockState = {
2303
2645
  '*uploadCollection': TypedCollection<UploadEntryData>;
@@ -2310,65 +2652,6 @@ type LocaleState = {
2310
2652
  };
2311
2653
  type SharedState = SolutionBlockCtxState & SharedConfigState & CloudImageEditorState & EditorImageCropperState & EditorToolbarState & DynamicBlockState & DynamicUploaderBlockState & LocaleState;
2312
2654
 
2313
- interface ISharedInstance {
2314
- destroy?(): void;
2315
- }
2316
- declare class SharedInstance {
2317
- protected _ctx: PubSub<SharedState>;
2318
- protected _sharedInstancesBag: SharedInstancesBag;
2319
- private _subscriptions;
2320
- private _cfgProxy;
2321
- protected _debugPrint: (...args: unknown[]) => void;
2322
- constructor(sharedInstancesBag: SharedInstancesBag);
2323
- protected addSub(unsub: () => void): void;
2324
- protected get _cfg(): Readonly<ConfigType>;
2325
- destroy(): void;
2326
- }
2327
- type SharedInstancesState = Pick<SharedState, '*blocksRegistry' | '*eventEmitter' | '*localeManager' | '*telemetryManager' | '*a11y' | '*modalManager' | '*uploadCollection' | '*publicApi' | '*validationManager' | '*secureUploadsManager'>;
2328
- type SharedInstancesBag = ReturnType<typeof createSharedInstancesBag>;
2329
- declare const createSharedInstancesBag: (getCtx: () => PubSub<SharedState>) => {
2330
- readonly ctx: PubSub<SharedState>;
2331
- readonly modalManager: ModalManager | null;
2332
- readonly telemetryManager: TelemetryManager;
2333
- readonly localeManager: LocaleManager;
2334
- readonly a11y: A11y;
2335
- readonly blocksRegistry: Set<LitBlock>;
2336
- readonly eventEmitter: EventEmitter;
2337
- readonly uploadCollection: TypedCollection<UploadEntryData>;
2338
- readonly secureUploadsManager: SecureUploadsManager;
2339
- readonly api: UploaderPublicApi;
2340
- readonly validationManager: ValidationManager;
2341
- };
2342
-
2343
- type FuncFileValidator = (outputEntry: OutputFileEntry, api: UploaderPublicApi, options?: {
2344
- signal?: AbortSignal;
2345
- }) => undefined | OutputErrorFile | Promise<undefined | OutputErrorFile>;
2346
- type FileValidatorDescriptor = {
2347
- runOn: 'add' | 'upload' | 'change';
2348
- validator: FuncFileValidator;
2349
- };
2350
- type FileValidator = FileValidatorDescriptor | FuncFileValidator;
2351
- type FuncCollectionValidator = (collection: ReturnType<typeof buildOutputCollectionState<OutputCollectionStatus>>, api: UploaderPublicApi) => undefined | OutputErrorCollection;
2352
- declare class ValidationManager extends SharedInstance {
2353
- private get _uploadCollection();
2354
- private _commonFileValidators;
2355
- private _commonCollectionValidators;
2356
- private _queue;
2357
- private _runQueueDebounced;
2358
- private _isDestroyed;
2359
- private _entryValidationState;
2360
- constructor(sharedInstancesBag: SharedInstancesBag);
2361
- runFileValidators(runOn: FileValidatorDescriptor['runOn'], entryIds?: Uid[]): void;
2362
- runCollectionValidators(): void;
2363
- cleanupValidationForEntry(entry: TypedData<UploadEntryData>): void;
2364
- private _runFileValidatorsForEntry;
2365
- private _addCustomTypeToValidationError;
2366
- private _getEntryValidationState;
2367
- private _getValidatorDescriptors;
2368
- private _getValidatorDescriptorsForEntry;
2369
- destroy(): void;
2370
- }
2371
-
2372
2655
  declare const LitBlockBase: typeof LitElement & Constructor<{
2373
2656
  willYield: boolean;
2374
2657
  yield(slot: string, defaultContent?: unknown): unknown;
@@ -2379,7 +2662,6 @@ declare const LitBlockBase: typeof LitElement & Constructor<{
2379
2662
  };
2380
2663
  declare class LitBlock extends LitBlockBase {
2381
2664
  private _cfgProxy;
2382
- protected _sharedContextInstances: Map<keyof SharedInstancesState, ISharedInstance>;
2383
2665
  static styleAttrs: string[];
2384
2666
  activityType: ActivityType;
2385
2667
  init$: {};
@@ -2389,6 +2671,7 @@ declare class LitBlock extends LitBlockBase {
2389
2671
  protected _sharedInstancesBag: {
2390
2672
  readonly ctx: PubSub<SharedState>;
2391
2673
  readonly modalManager: ModalManager | null;
2674
+ readonly pluginManager: PluginManager;
2392
2675
  readonly telemetryManager: TelemetryManager;
2393
2676
  readonly localeManager: LocaleManager;
2394
2677
  readonly a11y: A11y;
@@ -2398,6 +2681,19 @@ declare class LitBlock extends LitBlockBase {
2398
2681
  readonly secureUploadsManager: SecureUploadsManager;
2399
2682
  readonly api: UploaderPublicApi;
2400
2683
  readonly validationManager: ValidationManager;
2684
+ when<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "api" | "validationManager">(name: TName, callback: (instance: NonNullable<{
2685
+ modalManager: ModalManager | null;
2686
+ pluginManager: PluginManager;
2687
+ telemetryManager: TelemetryManager;
2688
+ localeManager: LocaleManager;
2689
+ a11y: A11y;
2690
+ blocksRegistry: BlocksRegistry;
2691
+ eventEmitter: EventEmitter;
2692
+ uploadCollection: TypedCollection<UploadEntryData>;
2693
+ secureUploadsManager: SecureUploadsManager;
2694
+ api: UploaderPublicApi;
2695
+ validationManager: ValidationManager;
2696
+ }[TName]>) => void): () => void;
2401
2697
  };
2402
2698
  emit(type: Parameters<EventEmitter['emit']>[0], payload?: Parameters<EventEmitter['emit']>[1], options?: Parameters<EventEmitter['emit']>[2]): void;
2403
2699
  hasBlockInCtx(callback: (block: LitBlock) => boolean): boolean;
@@ -2415,11 +2711,7 @@ declare class LitBlock extends LitBlockBase {
2415
2711
  * Called when the last block is removed from the context. Note that inheritors must run their callback before that.
2416
2712
  */
2417
2713
  private destroyCtxCallback;
2418
- /**
2419
- * Adds a shared context instance if it does not exist yet.
2420
- * @param key The shared state key.
2421
- * @param resolver The resolver function that creates the instance.
2422
- */
2714
+ private _getSharedContextInstances;
2423
2715
  protected _addSharedContextInstance<TKey extends keyof SharedInstancesState>(key: TKey, resolver: (sharedInstancesBag: SharedInstancesBag) => NonNullable<SharedInstancesState[TKey]>): void;
2424
2716
  private _destroySharedContextInstances;
2425
2717
  protected _getSharedContextInstance<TKey extends keyof SharedState, TRequired extends boolean = true>(key: TKey, isRequired?: TRequired): TRequired extends true ? NonNullable<SharedState[TKey]> : SharedState[TKey];
@@ -2651,18 +2943,20 @@ declare global {
2651
2943
  }
2652
2944
  }
2653
2945
 
2946
+ type SourceButtonConfig = {
2947
+ id: string;
2948
+ label: string;
2949
+ icon?: string;
2950
+ onClick: () => void | Promise<void>;
2951
+ };
2654
2952
  declare class SourceBtn extends LitUploaderBlock {
2655
2953
  couldBeCtxOwner: boolean;
2656
- private _registeredTypes;
2657
- type?: string;
2954
+ source?: SourceButtonConfig;
2658
2955
  private _iconName;
2659
2956
  private _srcTypeKey;
2660
- private _initTypes;
2661
- initCallback(): void;
2662
- private _registerType;
2663
- activate(): void;
2664
- private _applyType;
2665
2957
  protected willUpdate(changedProperties: PropertyValues<this>): void;
2958
+ private _applySource;
2959
+ activate(): void;
2666
2960
  render(): lit_html.TemplateResult<1>;
2667
2961
  }
2668
2962
  declare global {
@@ -2671,9 +2965,11 @@ declare global {
2671
2965
  }
2672
2966
  }
2673
2967
 
2674
- declare class SourceList extends LitBlock {
2968
+ declare class SourceList extends LitUploaderBlock {
2675
2969
  private _rawSourceList;
2676
2970
  private _cameraModes;
2971
+ private _unsubscribePlugins?;
2972
+ private _sources;
2677
2973
  /**
2678
2974
  * CSS-only attribute
2679
2975
  */
@@ -2681,8 +2977,12 @@ declare class SourceList extends LitBlock {
2681
2977
  initCallback(): void;
2682
2978
  protected updated(changedProperties: PropertyValues<this>): void;
2683
2979
  private _updateSources;
2684
- private _sources;
2980
+ private _expandSource;
2981
+ private _makeBuiltInSourceConfig;
2982
+ private _makePluginSourceConfig;
2983
+ private _openActivity;
2685
2984
  render(): lit_html.TemplateResult<1>;
2985
+ disconnectedCallback(): void;
2686
2986
  }
2687
2987
  declare global {
2688
2988
  interface HTMLElementTagNameMap {
@@ -2745,13 +3045,11 @@ declare global {
2745
3045
  }
2746
3046
 
2747
3047
  declare class UrlSource extends LitUploaderBlock {
2748
- couldBeCtxOwner: boolean;
2749
- activityType: ActivityType;
2750
3048
  private _formState;
2751
- initCallback(): void;
2752
3049
  private _inputRef;
2753
3050
  private _handleInput;
2754
3051
  private _handleUpload;
3052
+ firstUpdated(): void;
2755
3053
  render(): lit_html.TemplateResult<1>;
2756
3054
  }
2757
3055
  declare global {
@@ -2775,6 +3073,35 @@ declare global {
2775
3073
  }
2776
3074
  }
2777
3075
 
3076
+ declare class PluginActivityHost extends LitActivityBlock {
3077
+ registration: Owned<PluginActivityRegistration>;
3078
+ activityType: ActivityType;
3079
+ private _dispose?;
3080
+ private _containerRef;
3081
+ initCallback(): void;
3082
+ protected willUpdate(changedProperties: PropertyValues<this>): void;
3083
+ private _ensureRegistered;
3084
+ private _renderActivity;
3085
+ private _disposeActivity;
3086
+ disconnectedCallback(): void;
3087
+ render(): lit_html.TemplateResult<1>;
3088
+ }
3089
+ declare class PluginActivityRenderer extends LitBlock {
3090
+ mode: 'modal' | 'inline';
3091
+ private _activities;
3092
+ private _unsubscribePlugins?;
3093
+ initCallback(): void;
3094
+ private _syncActivities;
3095
+ disconnectedCallback(): void;
3096
+ render(): lit_html.TemplateResult<1>;
3097
+ }
3098
+ declare global {
3099
+ interface HTMLElementTagNameMap {
3100
+ 'uc-plugin-activity-host': PluginActivityHost;
3101
+ 'uc-plugin-activity-renderer': PluginActivityRenderer;
3102
+ }
3103
+ }
3104
+
2778
3105
  declare class FileUploaderRegular extends LitSolutionBlock {
2779
3106
  attributesMeta: {
2780
3107
  headless?: boolean;
@@ -2838,4 +3165,4 @@ declare global {
2838
3165
  declare const PACKAGE_NAME = "blocks";
2839
3166
  declare const PACKAGE_VERSION: string;
2840
3167
 
2841
- export { LitActivityBlock as ActivityBlock, ActivityHeader, type ApiAddFileCommonOptions, BaseComponent, LitBlock as Block, BtnUi, CameraSource, CloudImageEditor, CloudImageEditorActivity, CloudImageEditorBlock, type CollectionValidators, Config, type ConfigAttributesType, type ConfigComplexType, type ConfigPlainType, type ConfigType, Copyright, CropFrame, PubSub as Data, DropArea, EditorAspectRatioButtonControl, EditorCropButtonControl, EditorFilterControl, EditorFreeformButtonControl, EditorImageCropper, EditorImageFader, EditorOperationControl, EditorScroller, EditorSlider, EditorToolbar, type EventMap, type EventPayload, EventType, ExternalSource, ExternalUploadSource, 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, type OutputCollectionErrorType, type OutputCollectionState, type OutputCollectionStatus, type OutputCustomErrorType, type OutputError, type OutputErrorCollection, type OutputErrorFile, type OutputErrorTypePayload, type OutputFileEntry, type OutputFileErrorPayload, type OutputFileErrorType, type OutputFileStatus, PACKAGE_NAME, PACKAGE_VERSION, PresenceToggle, ProgressBar, ProgressBarCommon, type SecureDeliveryProxyUrlResolver, type SecureUploadsSignatureAndExpire, type SecureUploadsSignatureResolver, Select, SimpleBtn, SliderUi, LitSolutionBlock as SolutionBlock, SourceBtn, SourceList, type SourceTypes, Spinner, StartFrom, Thumb, UID, UploadCtxProvider, UploadList, UploadSource, LitUploaderBlock as UploaderBlock, UploaderPublicApi, UrlSource, defineComponents, defineLocale, loadFileUploaderFrom, toKebabCase };
3168
+ export { LitActivityBlock as ActivityBlock, ActivityHeader, 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, PubSub as Data, DropArea, EditorAspectRatioButtonControl, EditorCropButtonControl, EditorFilterControl, EditorFreeformButtonControl, EditorImageCropper, EditorImageFader, EditorOperationControl, EditorScroller, EditorSlider, EditorToolbar, type EventMap, type EventPayload, EventType, ExternalSource, ExternalUploadSource, 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, 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 PluginExports, type PluginFileActionRegistration, type PluginI18nRegistration, type PluginIconRegistration, PluginManager, type PluginRegistryApi, type PluginRegistrySnapshot, type PluginRender, type PluginRenderDispose, type PluginSetupParams, type PluginSetupResult, type PluginSourceRegistration, type PluginUploaderApi, type PluginVersion, PresenceToggle, ProgressBar, ProgressBarCommon, type SecureDeliveryProxyUrlResolver, type SecureUploadsSignatureAndExpire, type SecureUploadsSignatureResolver, Select, SimpleBtn, SliderUi, LitSolutionBlock as SolutionBlock, SourceBtn, SourceList, type SourceTypes, Spinner, StartFrom, Thumb, UID, UploadCtxProvider, UploadList, UploadSource, LitUploaderBlock as UploaderBlock, type UploaderPlugin, UploaderPublicApi, UrlSource, defineComponents, defineLocale, loadFileUploaderFrom, toKebabCase };