@uploadcare/file-uploader 1.26.3 → 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
package/dist/index.d.ts CHANGED
@@ -79,17 +79,77 @@ type LocaleDefinition = typeof _default;
79
79
  type LocaleDefinitionResolver = () => Promise<LocaleDefinition>;
80
80
  declare const defineLocale: (localeName: string, definitionOrResolver: LocaleDefinition | LocaleDefinitionResolver) => void;
81
81
 
82
- declare class A11y implements ISharedInstance {
83
- private _destroyKeyUX;
84
- private readonly _scopedWindow;
85
- constructor();
86
- registerBlock(scope: LitBlock): void;
87
- destroy(): void;
88
- }
89
-
90
82
  declare class LocaleManager extends SharedInstance {
91
83
  private _localeName;
92
84
  constructor(sharedInstancesBag: SharedInstancesBag);
85
+ private _applyOverrides;
86
+ private _applyPluginLocales;
87
+ }
88
+
89
+ /**
90
+ * Custom configuration options registration system for plugins
91
+ */
92
+ type CustomConfigDefinition<T = unknown> = {
93
+ /**
94
+ * Config option name (will be used as property and optionally as attribute)
95
+ */
96
+ name: string;
97
+ /**
98
+ * Default value for the config option
99
+ */
100
+ defaultValue: T;
101
+ /**
102
+ * Whether this config can be set via HTML attribute
103
+ * @default true
104
+ */
105
+ attribute?: boolean;
106
+ /**
107
+ * Convert attribute string to config value
108
+ * Only used if attribute is true
109
+ */
110
+ fromAttribute?: (value: string | null) => T;
111
+ /**
112
+ * Convert config value to attribute string
113
+ * Only used if attribute is true
114
+ */
115
+ toAttribute?: (value: T) => string | null;
116
+ /**
117
+ * Normalize/validate the config value
118
+ */
119
+ normalize?: (value: unknown) => T;
120
+ };
121
+ /**
122
+ * Registry for custom config options defined by plugins
123
+ * This is managed by the PluginManager as a shared instance property
124
+ */
125
+ declare class CustomConfigRegistry {
126
+ private _definitions;
127
+ register<T = unknown>(pluginId: string, definition: CustomConfigDefinition<T>): void;
128
+ unregister(name: string): void;
129
+ unregisterByPlugin(pluginId: string): void;
130
+ get(name: string): CustomConfigDefinition<any> | undefined;
131
+ getAll(): Map<string, CustomConfigDefinition<any>>;
132
+ }
133
+ /**
134
+ * Interface for TypeScript module augmentation
135
+ * Plugins should extend this interface to add their custom config types
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * declare module '@uploadcare/file-uploader' {
140
+ * interface CustomConfig {
141
+ * 'my-custom-option': string;
142
+ * }
143
+ * }
144
+ * ```
145
+ */
146
+ interface CustomConfig {
147
+ }
148
+
149
+ declare class SecureUploadsManager extends SharedInstance {
150
+ private _secureToken;
151
+ getSecureToken(): Promise<SecureUploadsSignatureAndExpire | null>;
152
+ destroy(): void;
93
153
  }
94
154
 
95
155
  declare class TypedData<T extends Record<string, unknown>> {
@@ -218,7 +278,7 @@ declare class UploaderPublicApi extends SharedInstance {
218
278
  getOutputCollectionState<TStatus extends OutputCollectionStatus>(): ReturnType<typeof buildOutputCollectionState<TStatus>>;
219
279
  initFlow: (force?: boolean) => void;
220
280
  doneFlow: () => void;
221
- setCurrentActivity: <T extends RegisteredActivityType>(activityType: T, ...params: T extends keyof ActivityParamsMap ? [ActivityParamsMap[T]] : T extends RegisteredActivityType ? [undefined?] : [never]) => void;
281
+ setCurrentActivity: <T extends ActivityType>(activityType: T, ...params: T extends keyof ActivityParamsMap ? [ActivityParamsMap[T]] extends [never] ? [] : [ActivityParamsMap[T]] : []) => void;
222
282
  getCurrentActivity: () => ActivityType;
223
283
  setModalState: (opened: boolean) => void;
224
284
  private get _sourceList();
@@ -418,11 +478,14 @@ declare global {
418
478
  declare class Icon extends LitBlock {
419
479
  name: string;
420
480
  private _resolvedHref;
481
+ private _pluginSvg;
421
482
  private _iconHrefResolver;
483
+ private _unsubscribePlugins?;
422
484
  initCallback(): void;
423
485
  protected willUpdate(changedProperties: PropertyValues<this>): void;
424
486
  private _updateResolvedHref;
425
487
  render(): lit_html.TemplateResult<1>;
488
+ disconnectedCallback(): void;
426
489
  }
427
490
  declare global {
428
491
  interface HTMLElementTagNameMap {
@@ -1002,12 +1065,11 @@ type ActivityParams$1 = {
1002
1065
  internalId: string;
1003
1066
  };
1004
1067
  declare class CloudImageEditorActivity extends LitUploaderBlock {
1005
- couldBeCtxOwner: boolean;
1006
- activityType: "cloud-image-edit";
1007
1068
  private _entry?;
1008
1069
  private _editorConfig;
1009
1070
  get activityParams(): ActivityParams$1;
1010
1071
  initCallback(): void;
1072
+ disconnectedCallback(): void;
1011
1073
  private _handleApply;
1012
1074
  private _handleCancel;
1013
1075
  handleChange(event: CustomEvent<ChangeResult>): void;
@@ -1094,13 +1156,17 @@ declare const ACTIVITY_TYPES: Readonly<{
1094
1156
  CLOUD_IMG_EDIT: "cloud-image-edit";
1095
1157
  EXTERNAL: "external";
1096
1158
  }>;
1097
- type RegisteredActivityType = (typeof ACTIVITY_TYPES)[keyof typeof ACTIVITY_TYPES];
1098
- type ActivityType = RegisteredActivityType | (string & {}) | null;
1159
+ type RegisteredActivityType = (typeof ACTIVITY_TYPES)[keyof typeof ACTIVITY_TYPES] | keyof CustomActivities;
1160
+ type ActivityType = RegisteredActivityType | null;
1099
1161
 
1100
1162
  declare const ACTIVE_PROP = "___ACTIVITY_IS_ACTIVE___";
1163
+ interface CustomActivities {
1164
+ }
1101
1165
  type ActivityParamsMap = {
1102
1166
  'cloud-image-edit': ActivityParams$1;
1103
1167
  external: ActivityParams;
1168
+ } & {
1169
+ [Key in keyof CustomActivities]: CustomActivities[Key]['params'];
1104
1170
  };
1105
1171
  declare class LitActivityBlock extends LitBlock {
1106
1172
  protected historyTracked: boolean;
@@ -1117,7 +1183,7 @@ declare class LitActivityBlock extends LitBlock {
1117
1183
  private _activate;
1118
1184
  initCallback(): void;
1119
1185
  private _historyFlush;
1120
- private _isActivityRegistered;
1186
+ protected _isActivityRegistered(): boolean;
1121
1187
  private static _activityCallbacks;
1122
1188
  static activities: Readonly<{
1123
1189
  START_FROM: 'start-from';
@@ -1138,8 +1204,8 @@ declare class LitActivityBlock extends LitBlock {
1138
1204
  private _unregisterActivity;
1139
1205
  disconnectedCallback(): void;
1140
1206
  get activityParams(): ActivityParamsMap[keyof ActivityParamsMap];
1141
- get initActivity(): string | null;
1142
- get doneActivity(): string | null;
1207
+ get initActivity(): RegisteredActivityType | null;
1208
+ get doneActivity(): RegisteredActivityType | null;
1143
1209
  historyBack(): void;
1144
1210
  }
1145
1211
 
@@ -1213,6 +1279,35 @@ type EventMap = {
1213
1279
  [T in keyof EventPayload]: CustomEvent<EventPayload[T]>;
1214
1280
  };
1215
1281
 
1282
+ type FuncFileValidator = (outputEntry: OutputFileEntry, api: UploaderPublicApi, options?: {
1283
+ signal?: AbortSignal;
1284
+ }) => undefined | OutputErrorFile | Promise<undefined | OutputErrorFile>;
1285
+ type FileValidatorDescriptor = {
1286
+ runOn: 'add' | 'upload' | 'change';
1287
+ validator: FuncFileValidator;
1288
+ };
1289
+ type FileValidator = FileValidatorDescriptor | FuncFileValidator;
1290
+ type FuncCollectionValidator = (collection: ReturnType<typeof buildOutputCollectionState<OutputCollectionStatus>>, api: UploaderPublicApi) => undefined | OutputErrorCollection;
1291
+ declare class ValidationManager extends SharedInstance {
1292
+ private get _uploadCollection();
1293
+ private _commonFileValidators;
1294
+ private _commonCollectionValidators;
1295
+ private _queue;
1296
+ private _runQueueDebounced;
1297
+ private _isDestroyed;
1298
+ private _entryValidationState;
1299
+ constructor(sharedInstancesBag: SharedInstancesBag);
1300
+ runFileValidators(runOn: FileValidatorDescriptor['runOn'], entryIds?: Uid[]): void;
1301
+ runCollectionValidators(): void;
1302
+ cleanupValidationForEntry(entry: TypedData<UploadEntryData>): void;
1303
+ private _runFileValidatorsForEntry;
1304
+ private _addCustomTypeToValidationError;
1305
+ private _getEntryValidationState;
1306
+ private _getValidatorDescriptors;
1307
+ private _getValidatorDescriptorsForEntry;
1308
+ destroy(): void;
1309
+ }
1310
+
1216
1311
  type SelectOption = {
1217
1312
  text: string;
1218
1313
  value: string;
@@ -1353,25 +1448,54 @@ declare global {
1353
1448
  /**
1354
1449
  * Config keys that can't be passed as attribute (because they are object or function)
1355
1450
  */
1356
- declare const complexConfigKeys: readonly ["metadata", "localeDefinitionOverride", "secureUploadsSignatureResolver", "secureDeliveryProxyUrlResolver", "iconHrefResolver", "fileValidators", "collectionValidators", "mediaRecorderOptions"];
1357
- /** Mapping of attribute names to state */
1358
- declare const attrStateMapping: Record<string, string>;
1451
+ declare const complexConfigKeys: readonly ["metadata", "plugins", "localeDefinitionOverride", "secureUploadsSignatureResolver", "secureDeliveryProxyUrlResolver", "iconHrefResolver", "fileValidators", "collectionValidators", "mediaRecorderOptions"];
1359
1452
  declare class Config extends LitBlock {
1360
1453
  attributesMeta: Partial<ConfigPlainType> & {
1361
1454
  'ctx-name': string;
1362
1455
  };
1363
1456
  init$: LitBlock["init$"] & ConfigType;
1364
1457
  private _computationControllers;
1458
+ private _pluginChangeUnsubscribe?;
1459
+ private _mutationObserver?;
1460
+ /**
1461
+ * Mapping of attribute names to custom config keys for plugin-registered configs.
1462
+ * Updated dynamically when plugins are registered or changed.
1463
+ * Similar to builtinAttrKeyMapping but for custom configs.
1464
+ */
1465
+ private _customAttrKeyMapping;
1466
+ /** Set of all custom config names registered by plugins */
1467
+ private _customConfigKeys;
1468
+ /**
1469
+ * Map of custom config subscriptions (config name -> unsubscribe function)
1470
+ * Used to track and clean up subscriptions when plugins change
1471
+ */
1472
+ private _customConfigSubscriptions;
1473
+ /**
1474
+ * Check if a key is a custom config (registered by plugins)
1475
+ */
1476
+ private _isCustomConfig;
1477
+ /**
1478
+ * Get the custom config definition for a key
1479
+ */
1480
+ private _getCustomConfigDefinition;
1481
+ /**
1482
+ * Get attribute names for a config key (kebab-case and lowercase)
1483
+ */
1484
+ private _getAttributeNames;
1365
1485
  private _flushValueToAttribute;
1366
1486
  private _flushValueToState;
1367
1487
  private _setValue;
1368
1488
  private _getValue;
1369
1489
  private _assertSameValueDifferentReference;
1490
+ private _processCustomConfigs;
1491
+ private _setupCustomConfigs;
1492
+ private _setupMutationObserver;
1370
1493
  initCallback(): void;
1371
- attributeChangedCallback(name: keyof typeof attrStateMapping, oldVal: string, newVal: string): void;
1494
+ attributeChangedCallback(name: string, oldVal: string, newVal: string): void;
1495
+ disconnectedCallback(): void;
1372
1496
  static get observedAttributes(): string[];
1373
1497
  }
1374
- interface Config extends ConfigType {
1498
+ interface Config extends ConfigType, CustomConfig {
1375
1499
  }
1376
1500
  declare global {
1377
1501
  interface HTMLElementTagNameMap {
@@ -1455,12 +1579,12 @@ declare class FileItem extends FileItemConfig {
1455
1579
  private _isFailed;
1456
1580
  private _isUploading;
1457
1581
  private _isFocused;
1458
- private _isEditable;
1459
1582
  private _showFileNames;
1460
1583
  private _ariaLabelStatusFile;
1584
+ private _pluginFileActions;
1461
1585
  private _renderedOnce;
1462
1586
  private _observer?;
1463
- private _handleEdit;
1587
+ private _unsubscribePlugins?;
1464
1588
  private _handleRemove;
1465
1589
  private _handleUploadClick;
1466
1590
  private _calculateState;
@@ -1472,6 +1596,8 @@ declare class FileItem extends FileItemConfig {
1472
1596
  private _handleEntryId;
1473
1597
  private _updateShowFileNames;
1474
1598
  protected willUpdate(changedProperties: PropertyValues<this>): void;
1599
+ private _updatePluginFileActions;
1600
+ private _handlePluginFileAction;
1475
1601
  initCallback(): void;
1476
1602
  connectedCallback(): void;
1477
1603
  disconnectedCallback(): void;
@@ -1776,6 +1902,10 @@ type ConfigType = {
1776
1902
  * Expiry threshold for secure uploads.
1777
1903
  */
1778
1904
  secureUploadsExpireThreshold: number;
1905
+ /**
1906
+ * Array of plugins to register with the uploader instance.
1907
+ */
1908
+ plugins: UploaderPlugin[];
1779
1909
  /**
1780
1910
  * Metadata for the file.
1781
1911
  */
@@ -2032,10 +2162,162 @@ type OutputCollectionState<TStatus extends OutputCollectionStatus = OutputCollec
2032
2162
  allEntries: OutputFileEntry[];
2033
2163
  });
2034
2164
 
2035
- declare class SecureUploadsManager extends SharedInstance {
2036
- private _secureToken;
2037
- getSecureToken(): Promise<SecureUploadsSignatureAndExpire | null>;
2165
+ type PluginVersion = string;
2166
+ type PluginIconRegistration = {
2167
+ name: string;
2168
+ svg: string;
2169
+ };
2170
+ type PluginI18nRegistration = Record<string, Record<string, string>>;
2171
+ type PluginSourceRegistration = {
2172
+ id: string;
2173
+ label: string;
2174
+ icon?: string;
2175
+ onSelect: () => Promise<void> | void;
2176
+ };
2177
+ type PluginRenderDispose = () => void;
2178
+ type PluginRender = (el: HTMLElement, activityParams: Record<string, unknown>) => PluginRenderDispose | undefined;
2179
+ type PluginActivityRegistration = {
2180
+ id: string;
2181
+ render: PluginRender;
2182
+ };
2183
+ type PluginFileActionRegistration = {
2184
+ id: string;
2185
+ icon: string;
2186
+ shouldRender: (fileEntry: OutputFileEntry) => boolean;
2187
+ onClick: (fileEntry: OutputFileEntry) => void | Promise<void>;
2188
+ };
2189
+ type PluginRegistryApi = {
2190
+ registerSource: (source: PluginSourceRegistration) => PluginSourceRegistration;
2191
+ registerActivity: (activity: PluginActivityRegistration) => PluginActivityRegistration;
2192
+ registerFileAction: (fileAction: PluginFileActionRegistration) => PluginFileActionRegistration;
2193
+ registerIcon: (icon: PluginIconRegistration) => PluginIconRegistration;
2194
+ registerI18n: (i18n: PluginI18nRegistration) => PluginI18nRegistration;
2195
+ registerConfig: <T = unknown>(definition: CustomConfigDefinition<T>) => void;
2196
+ };
2197
+ /**
2198
+ * API for managing plugin config subscriptions
2199
+ */
2200
+ type PluginConfigApi = {
2201
+ /**
2202
+ * Get the current value of a config option.
2203
+ *
2204
+ * @param configName - The name of the config to get
2205
+ * @returns The current config value
2206
+ *
2207
+ * @example
2208
+ * ```typescript
2209
+ * const theme = pluginApi.config.get('my-theme');
2210
+ * console.log('Current theme:', theme);
2211
+ * ```
2212
+ */
2213
+ get: <T = unknown>(configName: keyof (ConfigType & CustomConfig)) => T;
2214
+ /**
2215
+ * Subscribe to changes in a custom config value.
2216
+ * The callback will be called immediately with the current value,
2217
+ * and then whenever the value changes.
2218
+ *
2219
+ * Subscriptions are automatically cleaned up when the plugin is disposed.
2220
+ *
2221
+ * @param configName - The name of the custom config to subscribe to
2222
+ * @param callback - Function to call with the new value
2223
+ * @returns Unsubscribe function
2224
+ *
2225
+ * @example
2226
+ * ```typescript
2227
+ * pluginApi.config.subscribe('my-option', (value) => {
2228
+ * console.log('Config changed:', value);
2229
+ * });
2230
+ * // Cleanup happens automatically on plugin disposal
2231
+ * ```
2232
+ */
2233
+ subscribe: <T = unknown>(configName: keyof (ConfigType & CustomConfig), callback: (value: T) => void) => () => void;
2234
+ };
2235
+ /**
2236
+ * API for managing plugin activity interactions
2237
+ */
2238
+ type PluginActivityApi = {
2239
+ /**
2240
+ * Get the current activity parameters.
2241
+ *
2242
+ * @returns The current activity parameters object
2243
+ *
2244
+ * @example
2245
+ * ```typescript
2246
+ * const params = pluginApi.activity.getParams();
2247
+ * console.log('Current params:', params);
2248
+ * ```
2249
+ */
2250
+ getParams: () => Record<string, unknown>;
2251
+ /**
2252
+ * Subscribe to changes in activity parameters.
2253
+ * The callback will be called immediately with the current params,
2254
+ * and then whenever the params change.
2255
+ *
2256
+ * Subscriptions are automatically cleaned up when the plugin is disposed.
2257
+ *
2258
+ * @param callback - Function to call with the new params
2259
+ * @returns Unsubscribe function
2260
+ *
2261
+ * @example
2262
+ * ```typescript
2263
+ * pluginApi.activity.subscribeToParams((params) => {
2264
+ * console.log('Activity params changed:', params);
2265
+ * });
2266
+ * // Cleanup happens automatically on plugin disposal
2267
+ * ```
2268
+ */
2269
+ subscribeToParams: (callback: (params: Record<string, unknown>) => void) => () => void;
2270
+ };
2271
+ type PluginApi = {
2272
+ registry: PluginRegistryApi;
2273
+ config: PluginConfigApi;
2274
+ activity: PluginActivityApi;
2275
+ };
2276
+ type PluginUploaderApi = UploaderPublicApi;
2277
+ type PluginExports = {
2278
+ dispose?: () => void;
2279
+ };
2280
+ type PluginSetupResult = PluginExports | void | Promise<PluginExports | void>;
2281
+ type PluginSetupParams = {
2282
+ pluginApi: PluginApi;
2283
+ uploaderApi: PluginUploaderApi;
2284
+ };
2285
+ type UploaderPlugin = {
2286
+ id: string;
2287
+ version: PluginVersion;
2288
+ setup: (params: PluginSetupParams) => PluginSetupResult;
2289
+ };
2290
+ type Owned<T> = T & {
2291
+ pluginId: string;
2292
+ };
2293
+ type PluginRegistrySnapshot = {
2294
+ sources: Owned<PluginSourceRegistration>[];
2295
+ activities: Owned<PluginActivityRegistration>[];
2296
+ fileActions: Owned<PluginFileActionRegistration>[];
2297
+ icons: Owned<PluginIconRegistration>[];
2298
+ i18n: Owned<PluginI18nRegistration>[];
2299
+ };
2300
+
2301
+ declare class PluginManager extends SharedInstance {
2302
+ private _plugins;
2303
+ private _sources;
2304
+ private _activities;
2305
+ private _fileActions;
2306
+ private _icons;
2307
+ private _i18n;
2308
+ private _subscribers;
2309
+ private _pluginsUpdate;
2310
+ readonly configRegistry: CustomConfigRegistry;
2311
+ constructor(sharedInstancesBag: SharedInstancesBag);
2312
+ onPluginsChange(callback: () => void): () => void;
2313
+ private _syncPlugins;
2314
+ private _registerPlugin;
2315
+ private _unregisterPlugin;
2316
+ snapshot(): PluginRegistrySnapshot;
2038
2317
  destroy(): void;
2318
+ private _register;
2319
+ private _purgeRegistrations;
2320
+ private _notifySubscribers;
2039
2321
  }
2040
2322
 
2041
2323
  type CommonEventType = InternalEventKey | EventKey;
@@ -2076,14 +2358,71 @@ declare class TelemetryManager extends SharedInstance {
2076
2358
  private get _location();
2077
2359
  }
2078
2360
 
2361
+ interface ISharedInstance {
2362
+ destroy?(): void;
2363
+ }
2364
+ declare class SharedInstance {
2365
+ protected _ctx: PubSub<SharedState>;
2366
+ protected _sharedInstancesBag: SharedInstancesBag;
2367
+ private _subscriptions;
2368
+ private _cfgProxy;
2369
+ protected _debugPrint: (...args: unknown[]) => void;
2370
+ constructor(sharedInstancesBag: SharedInstancesBag);
2371
+ protected addSub(unsub: () => void): void;
2372
+ protected get _cfg(): Readonly<ConfigType>;
2373
+ destroy(): void;
2374
+ }
2375
+ declare const instanceKeyMap: {
2376
+ modalManager: "*modalManager";
2377
+ pluginManager: "*pluginManager";
2378
+ telemetryManager: "*telemetryManager";
2379
+ localeManager: "*localeManager";
2380
+ a11y: "*a11y";
2381
+ blocksRegistry: "*blocksRegistry";
2382
+ eventEmitter: "*eventEmitter";
2383
+ uploadCollection: "*uploadCollection";
2384
+ secureUploadsManager: "*secureUploadsManager";
2385
+ api: "*publicApi";
2386
+ validationManager: "*validationManager";
2387
+ };
2388
+ type InstanceTypeMap = {
2389
+ [key in keyof typeof instanceKeyMap]: SharedState[(typeof instanceKeyMap)[key]];
2390
+ };
2391
+ type InstanceName = keyof typeof instanceKeyMap;
2392
+ type SharedInstancesState = Pick<SharedState, (typeof instanceKeyMap)[keyof typeof instanceKeyMap]>;
2393
+ type SharedInstancesBag = ReturnType<typeof createSharedInstancesBag>;
2394
+ declare const createSharedInstancesBag: (getCtx: () => PubSub<SharedState>) => {
2395
+ readonly ctx: PubSub<SharedState>;
2396
+ readonly modalManager: ModalManager | null;
2397
+ readonly pluginManager: PluginManager;
2398
+ readonly telemetryManager: TelemetryManager;
2399
+ readonly localeManager: LocaleManager;
2400
+ readonly a11y: A11y;
2401
+ readonly blocksRegistry: Set<LitBlock>;
2402
+ readonly eventEmitter: EventEmitter;
2403
+ readonly uploadCollection: TypedCollection<UploadEntryData>;
2404
+ readonly secureUploadsManager: SecureUploadsManager;
2405
+ readonly api: UploaderPublicApi;
2406
+ readonly validationManager: ValidationManager;
2407
+ when<TName extends InstanceName>(name: TName, callback: (instance: NonNullable<InstanceTypeMap[TName]>) => void): () => void;
2408
+ };
2409
+
2410
+ declare class A11y implements ISharedInstance {
2411
+ private _destroyKeyUX;
2412
+ private readonly _scopedWindow;
2413
+ constructor();
2414
+ registerBlock(scope: LitBlock): void;
2415
+ destroy(): void;
2416
+ }
2417
+
2079
2418
  type SharedConfigState = {
2080
2419
  [K in keyof ConfigType as `*cfg/${K}`]: ConfigType[K];
2081
2420
  };
2082
2421
  type BlocksRegistry = Set<LitBlock>;
2083
2422
  type ActivityBlockCtxState = {
2084
- '*currentActivity': string | null;
2423
+ '*currentActivity': RegisteredActivityType | null;
2085
2424
  '*currentActivityParams': Record<string, unknown>;
2086
- '*history': (string | null)[];
2425
+ '*history': (RegisteredActivityType | null)[];
2087
2426
  '*historyBack': (() => void) | null;
2088
2427
  '*closeModal': () => void;
2089
2428
  };
@@ -2150,13 +2489,16 @@ type EditorToolbarState = {
2150
2489
  '*currentOperation': string | null;
2151
2490
  '*operationTooltip': string | null;
2152
2491
  };
2492
+ type SharedContextInstances = Map<string, ISharedInstance>;
2153
2493
  type DynamicBlockState = {
2494
+ '*sharedContextInstances': SharedContextInstances;
2154
2495
  '*blocksRegistry': BlocksRegistry;
2155
2496
  '*eventEmitter': EventEmitter;
2156
2497
  '*localeManager': LocaleManager;
2157
2498
  '*telemetryManager': TelemetryManager;
2158
2499
  '*a11y': A11y;
2159
2500
  '*modalManager': ModalManager | null;
2501
+ '*pluginManager': PluginManager;
2160
2502
  };
2161
2503
  type DynamicUploaderBlockState = {
2162
2504
  '*uploadCollection': TypedCollection<UploadEntryData>;
@@ -2169,65 +2511,6 @@ type LocaleState = {
2169
2511
  };
2170
2512
  type SharedState = SolutionBlockCtxState & SharedConfigState & CloudImageEditorState & EditorImageCropperState & EditorToolbarState & DynamicBlockState & DynamicUploaderBlockState & LocaleState;
2171
2513
 
2172
- interface ISharedInstance {
2173
- destroy?(): void;
2174
- }
2175
- declare class SharedInstance {
2176
- protected _ctx: PubSub<SharedState>;
2177
- protected _sharedInstancesBag: SharedInstancesBag;
2178
- private _subscriptions;
2179
- private _cfgProxy;
2180
- protected _debugPrint: (...args: unknown[]) => void;
2181
- constructor(sharedInstancesBag: SharedInstancesBag);
2182
- protected addSub(unsub: () => void): void;
2183
- protected get _cfg(): Readonly<ConfigType>;
2184
- destroy(): void;
2185
- }
2186
- type SharedInstancesState = Pick<SharedState, '*blocksRegistry' | '*eventEmitter' | '*localeManager' | '*telemetryManager' | '*a11y' | '*modalManager' | '*uploadCollection' | '*publicApi' | '*validationManager' | '*secureUploadsManager'>;
2187
- type SharedInstancesBag = ReturnType<typeof createSharedInstancesBag>;
2188
- declare const createSharedInstancesBag: (getCtx: () => PubSub<SharedState>) => {
2189
- readonly ctx: PubSub<SharedState>;
2190
- readonly modalManager: ModalManager | null;
2191
- readonly telemetryManager: TelemetryManager;
2192
- readonly localeManager: LocaleManager;
2193
- readonly a11y: A11y;
2194
- readonly blocksRegistry: Set<LitBlock>;
2195
- readonly eventEmitter: EventEmitter;
2196
- readonly uploadCollection: TypedCollection<UploadEntryData>;
2197
- readonly secureUploadsManager: SecureUploadsManager;
2198
- readonly api: UploaderPublicApi;
2199
- readonly validationManager: ValidationManager;
2200
- };
2201
-
2202
- type FuncFileValidator = (outputEntry: OutputFileEntry, api: UploaderPublicApi, options?: {
2203
- signal?: AbortSignal;
2204
- }) => undefined | OutputErrorFile | Promise<undefined | OutputErrorFile>;
2205
- type FileValidatorDescriptor = {
2206
- runOn: 'add' | 'upload' | 'change';
2207
- validator: FuncFileValidator;
2208
- };
2209
- type FileValidator = FileValidatorDescriptor | FuncFileValidator;
2210
- type FuncCollectionValidator = (collection: ReturnType<typeof buildOutputCollectionState<OutputCollectionStatus>>, api: UploaderPublicApi) => undefined | OutputErrorCollection;
2211
- declare class ValidationManager extends SharedInstance {
2212
- private get _uploadCollection();
2213
- private _commonFileValidators;
2214
- private _commonCollectionValidators;
2215
- private _queue;
2216
- private _runQueueDebounced;
2217
- private _isDestroyed;
2218
- private _entryValidationState;
2219
- constructor(sharedInstancesBag: SharedInstancesBag);
2220
- runFileValidators(runOn: FileValidatorDescriptor['runOn'], entryIds?: Uid[]): void;
2221
- runCollectionValidators(): void;
2222
- cleanupValidationForEntry(entry: TypedData<UploadEntryData>): void;
2223
- private _runFileValidatorsForEntry;
2224
- private _addCustomTypeToValidationError;
2225
- private _getEntryValidationState;
2226
- private _getValidatorDescriptors;
2227
- private _getValidatorDescriptorsForEntry;
2228
- destroy(): void;
2229
- }
2230
-
2231
2514
  declare const LitBlockBase: typeof LitElement & Constructor<{
2232
2515
  willYield: boolean;
2233
2516
  yield(slot: string, defaultContent?: unknown): unknown;
@@ -2238,7 +2521,6 @@ declare const LitBlockBase: typeof LitElement & Constructor<{
2238
2521
  };
2239
2522
  declare class LitBlock extends LitBlockBase {
2240
2523
  private _cfgProxy;
2241
- protected _sharedContextInstances: Map<keyof SharedInstancesState, ISharedInstance>;
2242
2524
  static styleAttrs: string[];
2243
2525
  activityType: ActivityType;
2244
2526
  init$: {};
@@ -2248,6 +2530,7 @@ declare class LitBlock extends LitBlockBase {
2248
2530
  protected _sharedInstancesBag: {
2249
2531
  readonly ctx: PubSub<SharedState>;
2250
2532
  readonly modalManager: ModalManager | null;
2533
+ readonly pluginManager: PluginManager;
2251
2534
  readonly telemetryManager: TelemetryManager;
2252
2535
  readonly localeManager: LocaleManager;
2253
2536
  readonly a11y: A11y;
@@ -2257,6 +2540,19 @@ declare class LitBlock extends LitBlockBase {
2257
2540
  readonly secureUploadsManager: SecureUploadsManager;
2258
2541
  readonly api: UploaderPublicApi;
2259
2542
  readonly validationManager: ValidationManager;
2543
+ when<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "api" | "validationManager">(name: TName, callback: (instance: NonNullable<{
2544
+ modalManager: ModalManager | null;
2545
+ pluginManager: PluginManager;
2546
+ telemetryManager: TelemetryManager;
2547
+ localeManager: LocaleManager;
2548
+ a11y: A11y;
2549
+ blocksRegistry: BlocksRegistry;
2550
+ eventEmitter: EventEmitter;
2551
+ uploadCollection: TypedCollection<UploadEntryData>;
2552
+ secureUploadsManager: SecureUploadsManager;
2553
+ api: UploaderPublicApi;
2554
+ validationManager: ValidationManager;
2555
+ }[TName]>) => void): () => void;
2260
2556
  };
2261
2557
  emit(type: Parameters<EventEmitter['emit']>[0], payload?: Parameters<EventEmitter['emit']>[1], options?: Parameters<EventEmitter['emit']>[2]): void;
2262
2558
  hasBlockInCtx(callback: (block: LitBlock) => boolean): boolean;
@@ -2274,11 +2570,7 @@ declare class LitBlock extends LitBlockBase {
2274
2570
  * Called when the last block is removed from the context. Note that inheritors must run their callback before that.
2275
2571
  */
2276
2572
  private destroyCtxCallback;
2277
- /**
2278
- * Adds a shared context instance if it does not exist yet.
2279
- * @param key The shared state key.
2280
- * @param resolver The resolver function that creates the instance.
2281
- */
2573
+ private _getSharedContextInstances;
2282
2574
  protected _addSharedContextInstance<TKey extends keyof SharedInstancesState>(key: TKey, resolver: (sharedInstancesBag: SharedInstancesBag) => NonNullable<SharedInstancesState[TKey]>): void;
2283
2575
  private _destroySharedContextInstances;
2284
2576
  protected _getSharedContextInstance<TKey extends keyof SharedState, TRequired extends boolean = true>(key: TKey, isRequired?: TRequired): TRequired extends true ? NonNullable<SharedState[TKey]> : SharedState[TKey];
@@ -2510,18 +2802,20 @@ declare global {
2510
2802
  }
2511
2803
  }
2512
2804
 
2805
+ type SourceButtonConfig = {
2806
+ id: string;
2807
+ label: string;
2808
+ icon?: string;
2809
+ onClick: () => void | Promise<void>;
2810
+ };
2513
2811
  declare class SourceBtn extends LitUploaderBlock {
2514
2812
  couldBeCtxOwner: boolean;
2515
- private _registeredTypes;
2516
- type?: string;
2813
+ source?: SourceButtonConfig;
2517
2814
  private _iconName;
2518
2815
  private _srcTypeKey;
2519
- private _initTypes;
2520
- initCallback(): void;
2521
- private _registerType;
2522
- activate(): void;
2523
- private _applyType;
2524
2816
  protected willUpdate(changedProperties: PropertyValues<this>): void;
2817
+ private _applySource;
2818
+ activate(): void;
2525
2819
  render(): lit_html.TemplateResult<1>;
2526
2820
  }
2527
2821
  declare global {
@@ -2530,9 +2824,11 @@ declare global {
2530
2824
  }
2531
2825
  }
2532
2826
 
2533
- declare class SourceList extends LitBlock {
2827
+ declare class SourceList extends LitUploaderBlock {
2534
2828
  private _rawSourceList;
2535
2829
  private _cameraModes;
2830
+ private _unsubscribePlugins?;
2831
+ private _sources;
2536
2832
  /**
2537
2833
  * CSS-only attribute
2538
2834
  */
@@ -2540,8 +2836,12 @@ declare class SourceList extends LitBlock {
2540
2836
  initCallback(): void;
2541
2837
  protected updated(changedProperties: PropertyValues<this>): void;
2542
2838
  private _updateSources;
2543
- private _sources;
2839
+ private _expandSource;
2840
+ private _makeBuiltInSourceConfig;
2841
+ private _makePluginSourceConfig;
2842
+ private _openActivity;
2544
2843
  render(): lit_html.TemplateResult<1>;
2844
+ disconnectedCallback(): void;
2545
2845
  }
2546
2846
  declare global {
2547
2847
  interface HTMLElementTagNameMap {
@@ -2604,13 +2904,11 @@ declare global {
2604
2904
  }
2605
2905
 
2606
2906
  declare class UrlSource extends LitUploaderBlock {
2607
- couldBeCtxOwner: boolean;
2608
- activityType: ActivityType;
2609
2907
  private _formState;
2610
- initCallback(): void;
2611
2908
  private _inputRef;
2612
2909
  private _handleInput;
2613
2910
  private _handleUpload;
2911
+ firstUpdated(): void;
2614
2912
  render(): lit_html.TemplateResult<1>;
2615
2913
  }
2616
2914
  declare global {
@@ -2634,6 +2932,35 @@ declare global {
2634
2932
  }
2635
2933
  }
2636
2934
 
2935
+ declare class PluginActivityHost extends LitActivityBlock {
2936
+ registration: Owned<PluginActivityRegistration>;
2937
+ activityType: ActivityType;
2938
+ private _dispose?;
2939
+ private _containerRef;
2940
+ initCallback(): void;
2941
+ protected willUpdate(changedProperties: PropertyValues<this>): void;
2942
+ private _ensureRegistered;
2943
+ private _renderActivity;
2944
+ private _disposeActivity;
2945
+ disconnectedCallback(): void;
2946
+ render(): lit_html.TemplateResult<1>;
2947
+ }
2948
+ declare class PluginActivityRenderer extends LitBlock {
2949
+ mode: 'modal' | 'inline';
2950
+ private _activities;
2951
+ private _unsubscribePlugins?;
2952
+ initCallback(): void;
2953
+ private _syncActivities;
2954
+ disconnectedCallback(): void;
2955
+ render(): lit_html.TemplateResult<1>;
2956
+ }
2957
+ declare global {
2958
+ interface HTMLElementTagNameMap {
2959
+ 'uc-plugin-activity-host': PluginActivityHost;
2960
+ 'uc-plugin-activity-renderer': PluginActivityRenderer;
2961
+ }
2962
+ }
2963
+
2637
2964
  declare class FileUploaderRegular extends LitSolutionBlock {
2638
2965
  attributesMeta: {
2639
2966
  headless?: boolean;
@@ -2694,4 +3021,4 @@ declare global {
2694
3021
  }
2695
3022
  }
2696
3023
 
2697
- 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, 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, toKebabCase };
3024
+ 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, 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, toKebabCase };