@uploadcare/file-uploader 1.28.0 → 1.29.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.
- package/dist/abstract/loadFileUploaderFrom.js +2 -2
- package/dist/env.js +3 -3
- package/dist/index.css +3 -3
- package/dist/index.d.ts +676 -280
- package/dist/index.js +5 -5
- package/dist/index.layered.css +3 -3
- package/dist/index.ssr.js +111 -38
- package/dist/locales/file-uploader/ar.d.ts +0 -2
- package/dist/locales/file-uploader/ar.js +3 -3
- package/dist/locales/file-uploader/az.d.ts +0 -2
- package/dist/locales/file-uploader/az.js +3 -3
- package/dist/locales/file-uploader/ca.d.ts +0 -2
- package/dist/locales/file-uploader/ca.js +3 -3
- package/dist/locales/file-uploader/cs.d.ts +0 -2
- package/dist/locales/file-uploader/cs.js +3 -3
- package/dist/locales/file-uploader/da.d.ts +0 -2
- package/dist/locales/file-uploader/da.js +3 -3
- package/dist/locales/file-uploader/de.d.ts +0 -2
- package/dist/locales/file-uploader/de.js +3 -3
- package/dist/locales/file-uploader/el.d.ts +0 -2
- package/dist/locales/file-uploader/el.js +3 -3
- package/dist/locales/file-uploader/en.d.ts +0 -2
- package/dist/locales/file-uploader/en.js +3 -3
- package/dist/locales/file-uploader/es.d.ts +0 -2
- package/dist/locales/file-uploader/es.js +3 -3
- package/dist/locales/file-uploader/et.d.ts +0 -2
- package/dist/locales/file-uploader/et.js +3 -3
- package/dist/locales/file-uploader/fi.d.ts +0 -2
- package/dist/locales/file-uploader/fi.js +3 -3
- package/dist/locales/file-uploader/fr.d.ts +0 -2
- package/dist/locales/file-uploader/fr.js +3 -3
- package/dist/locales/file-uploader/he.d.ts +0 -2
- package/dist/locales/file-uploader/he.js +3 -3
- package/dist/locales/file-uploader/hy.d.ts +0 -2
- package/dist/locales/file-uploader/hy.js +3 -3
- package/dist/locales/file-uploader/is.d.ts +0 -2
- package/dist/locales/file-uploader/is.js +3 -3
- package/dist/locales/file-uploader/it.d.ts +0 -2
- package/dist/locales/file-uploader/it.js +3 -3
- package/dist/locales/file-uploader/ja.d.ts +0 -2
- package/dist/locales/file-uploader/ja.js +3 -3
- package/dist/locales/file-uploader/ka.d.ts +0 -2
- package/dist/locales/file-uploader/ka.js +3 -3
- package/dist/locales/file-uploader/kk.d.ts +0 -2
- package/dist/locales/file-uploader/kk.js +3 -3
- package/dist/locales/file-uploader/ko.d.ts +0 -2
- package/dist/locales/file-uploader/ko.js +3 -3
- package/dist/locales/file-uploader/lv.d.ts +0 -2
- package/dist/locales/file-uploader/lv.js +3 -3
- package/dist/locales/file-uploader/nb.d.ts +0 -2
- package/dist/locales/file-uploader/nb.js +3 -3
- package/dist/locales/file-uploader/nl.d.ts +0 -2
- package/dist/locales/file-uploader/nl.js +3 -3
- package/dist/locales/file-uploader/pl.d.ts +0 -2
- package/dist/locales/file-uploader/pl.js +3 -3
- package/dist/locales/file-uploader/pt.d.ts +0 -2
- package/dist/locales/file-uploader/pt.js +3 -3
- package/dist/locales/file-uploader/ro.d.ts +0 -2
- package/dist/locales/file-uploader/ro.js +3 -3
- package/dist/locales/file-uploader/ru.d.ts +0 -2
- package/dist/locales/file-uploader/ru.js +3 -3
- package/dist/locales/file-uploader/sk.d.ts +0 -2
- package/dist/locales/file-uploader/sk.js +3 -3
- package/dist/locales/file-uploader/sr.d.ts +0 -2
- package/dist/locales/file-uploader/sr.js +3 -3
- package/dist/locales/file-uploader/sv.d.ts +0 -2
- package/dist/locales/file-uploader/sv.js +3 -3
- package/dist/locales/file-uploader/tr.d.ts +0 -2
- package/dist/locales/file-uploader/tr.js +3 -3
- package/dist/locales/file-uploader/uk.d.ts +0 -2
- package/dist/locales/file-uploader/uk.js +3 -3
- package/dist/locales/file-uploader/vi.d.ts +0 -2
- package/dist/locales/file-uploader/vi.js +3 -3
- package/dist/locales/file-uploader/zh-TW.d.ts +0 -2
- package/dist/locales/file-uploader/zh-TW.js +3 -3
- package/dist/locales/file-uploader/zh.d.ts +0 -2
- package/dist/locales/file-uploader/zh.js +3 -3
- package/package.json +29 -29
- package/web/file-uploader.iife.min.d.ts +676 -282
- package/web/file-uploader.iife.min.js +4 -4
- package/web/file-uploader.iife.min.js.LEGAL.txt +1 -1
- package/web/file-uploader.min.d.ts +676 -282
- package/web/file-uploader.min.js +4 -4
- package/web/file-uploader.min.js.LEGAL.txt +1 -1
- package/web/uc-basic.layered.min.css +3 -3
- package/web/uc-basic.min.css +3 -3
- package/web/uc-cloud-image-editor.layered.min.css +3 -3
- package/web/uc-cloud-image-editor.min.css +3 -3
- package/web/uc-cloud-image-editor.min.d.ts +626 -232
- package/web/uc-cloud-image-editor.min.js +4 -4
- package/web/uc-file-uploader-inline.layered.min.css +3 -3
- package/web/uc-file-uploader-inline.min.css +3 -3
- package/web/uc-file-uploader-inline.min.d.ts +676 -282
- package/web/uc-file-uploader-inline.min.js +4 -4
- package/web/uc-file-uploader-inline.min.js.LEGAL.txt +1 -1
- package/web/uc-file-uploader-minimal.layered.min.css +3 -3
- package/web/uc-file-uploader-minimal.min.css +3 -3
- package/web/uc-file-uploader-minimal.min.d.ts +676 -282
- package/web/uc-file-uploader-minimal.min.js +4 -4
- package/web/uc-file-uploader-minimal.min.js.LEGAL.txt +1 -1
- package/web/uc-file-uploader-regular.layered.min.css +3 -3
- package/web/uc-file-uploader-regular.min.css +3 -3
- package/web/uc-file-uploader-regular.min.d.ts +676 -282
- package/web/uc-file-uploader-regular.min.js +4 -4
- package/web/uc-file-uploader-regular.min.js.LEGAL.txt +1 -1
- package/web/uc-img.min.js +3 -3
|
@@ -2,7 +2,7 @@ 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 {
|
|
5
|
+
import { FileFromOptions, Metadata, UploadcareFile, UploadError, NetworkError, UploadcareGroup, Queue } from '@uploadcare/upload-client';
|
|
6
6
|
export { Metadata, NetworkError, 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';
|
|
@@ -135,7 +135,6 @@ declare const _default: {
|
|
|
135
135
|
'src-type-camera': string;
|
|
136
136
|
'src-type-mobile-video-camera': string;
|
|
137
137
|
'src-type-mobile-photo-camera': string;
|
|
138
|
-
'src-type-draw': string;
|
|
139
138
|
'src-type-facebook': string;
|
|
140
139
|
'src-type-dropbox': string;
|
|
141
140
|
'src-type-gdrive': string;
|
|
@@ -150,7 +149,6 @@ declare const _default: {
|
|
|
150
149
|
'src-type-other': string;
|
|
151
150
|
'caption-from-url': string;
|
|
152
151
|
'caption-camera': string;
|
|
153
|
-
'caption-draw': string;
|
|
154
152
|
'caption-edit-file': string;
|
|
155
153
|
'file-no-name': string;
|
|
156
154
|
'toggle-fullscreen': string;
|
|
@@ -232,8 +230,72 @@ declare class A11y implements ISharedInstance {
|
|
|
232
230
|
declare class LocaleManager extends SharedInstance {
|
|
233
231
|
private _localeName;
|
|
234
232
|
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
233
|
+
private _applyOverrides;
|
|
234
|
+
private _applyPluginLocales;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
/**
|
|
238
|
+
* Custom configuration options registration system for plugins
|
|
239
|
+
*/
|
|
240
|
+
type CustomConfigDefinition<T = unknown> = {
|
|
241
|
+
/**
|
|
242
|
+
* Config option name (will be used as property and optionally as attribute)
|
|
243
|
+
*/
|
|
244
|
+
name: string;
|
|
245
|
+
/**
|
|
246
|
+
* Default value for the config option
|
|
247
|
+
*/
|
|
248
|
+
defaultValue: T;
|
|
249
|
+
/**
|
|
250
|
+
* Whether this config can be set via HTML attribute
|
|
251
|
+
* @default true
|
|
252
|
+
*/
|
|
253
|
+
attribute?: boolean;
|
|
254
|
+
/**
|
|
255
|
+
* Convert attribute string to config value
|
|
256
|
+
* Only used if attribute is true
|
|
257
|
+
*/
|
|
258
|
+
fromAttribute?: (value: string | null) => T;
|
|
259
|
+
/**
|
|
260
|
+
* Convert config value to attribute string
|
|
261
|
+
* Only used if attribute is true
|
|
262
|
+
*/
|
|
263
|
+
toAttribute?: (value: T) => string | null;
|
|
264
|
+
/**
|
|
265
|
+
* Normalize/validate the config value
|
|
266
|
+
*/
|
|
267
|
+
normalize?: (value: unknown) => T;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Registry for custom config options defined by plugins
|
|
271
|
+
* This is managed by the PluginManager as a shared instance property
|
|
272
|
+
*/
|
|
273
|
+
declare class CustomConfigRegistry {
|
|
274
|
+
private _definitions;
|
|
275
|
+
register<T = unknown>(pluginId: string, definition: CustomConfigDefinition<T>): void;
|
|
276
|
+
unregister(name: string): void;
|
|
277
|
+
unregisterByPlugin(pluginId: string): void;
|
|
278
|
+
get(name: string): CustomConfigDefinition<any> | undefined;
|
|
279
|
+
getAll(): Map<string, CustomConfigDefinition<any>>;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Interface for TypeScript module augmentation
|
|
283
|
+
* Plugins should extend this interface to add their custom config types
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* declare module '@uploadcare/file-uploader' {
|
|
288
|
+
* interface CustomConfig {
|
|
289
|
+
* 'my-custom-option': string;
|
|
290
|
+
* }
|
|
291
|
+
* }
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
interface CustomConfig {
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
declare function buildOutputCollectionState<TCollectionStatus extends OutputCollectionStatus, TGroupFlag extends GroupFlag = 'maybe-has-group'>(bag: SharedInstancesBag): OutputCollectionState<TCollectionStatus, TGroupFlag>;
|
|
298
|
+
|
|
237
299
|
declare class TypedData<T extends Record<string, unknown>> {
|
|
238
300
|
private _ctxId;
|
|
239
301
|
private _data;
|
|
@@ -246,6 +308,41 @@ declare class TypedData<T extends Record<string, unknown>> {
|
|
|
246
308
|
destroy(): void;
|
|
247
309
|
}
|
|
248
310
|
|
|
311
|
+
type FuncFileValidator = (outputEntry: OutputFileEntry, api: UploaderPublicApi, options?: {
|
|
312
|
+
signal?: AbortSignal;
|
|
313
|
+
}) => undefined | OutputErrorFile | Promise<undefined | OutputErrorFile>;
|
|
314
|
+
type FileValidatorDescriptor = {
|
|
315
|
+
runOn: 'add' | 'upload' | 'change';
|
|
316
|
+
validator: FuncFileValidator;
|
|
317
|
+
};
|
|
318
|
+
type FileValidator = FileValidatorDescriptor | FuncFileValidator;
|
|
319
|
+
type FuncCollectionValidator = (collection: ReturnType<typeof buildOutputCollectionState<OutputCollectionStatus>>, api: UploaderPublicApi) => undefined | OutputErrorCollection;
|
|
320
|
+
declare class ValidationManager extends SharedInstance {
|
|
321
|
+
private get _uploadCollection();
|
|
322
|
+
private _commonFileValidators;
|
|
323
|
+
private _commonCollectionValidators;
|
|
324
|
+
private _queue;
|
|
325
|
+
private _runQueueDebounced;
|
|
326
|
+
private _isDestroyed;
|
|
327
|
+
private _entryValidationState;
|
|
328
|
+
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
329
|
+
runFileValidators(runOn: FileValidatorDescriptor['runOn'], entryIds?: Uid[]): void;
|
|
330
|
+
runCollectionValidators(): void;
|
|
331
|
+
cleanupValidationForEntry(entry: TypedData<UploadEntryData>): void;
|
|
332
|
+
private _runFileValidatorsForEntry;
|
|
333
|
+
private _addCustomTypeToValidationError;
|
|
334
|
+
private _getEntryValidationState;
|
|
335
|
+
private _getValidatorDescriptors;
|
|
336
|
+
private _getValidatorDescriptorsForEntry;
|
|
337
|
+
destroy(): void;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
declare class SecureUploadsManager extends SharedInstance {
|
|
341
|
+
private _secureToken;
|
|
342
|
+
getSecureToken(): Promise<SecureUploadsSignatureAndExpire | null>;
|
|
343
|
+
destroy(): void;
|
|
344
|
+
}
|
|
345
|
+
|
|
249
346
|
type ChangeMap<T extends Record<string, unknown>> = Record<keyof T, Set<Uid>>;
|
|
250
347
|
type TypedCollectionPropertyObserver<T extends Record<string, unknown>> = (changeMap: ChangeMap<T>) => void;
|
|
251
348
|
type TypedCollectionObserverHandler<T extends Record<string, unknown>> = (list: Uid[], added: Set<TypedData<T>>, removed: Set<TypedData<T>>) => void;
|
|
@@ -297,157 +394,6 @@ declare const CameraSourceTypes: Readonly<{
|
|
|
297
394
|
}>;
|
|
298
395
|
type ModeCameraType = (typeof CameraSourceTypes)[keyof typeof CameraSourceTypes];
|
|
299
396
|
|
|
300
|
-
declare function buildOutputCollectionState<TCollectionStatus extends OutputCollectionStatus, TGroupFlag extends GroupFlag = 'maybe-has-group'>(bag: SharedInstancesBag): OutputCollectionState<TCollectionStatus, TGroupFlag>;
|
|
301
|
-
|
|
302
|
-
interface UploadEntryData extends Record<string, unknown> {
|
|
303
|
-
file: File | null;
|
|
304
|
-
externalUrl: string | null;
|
|
305
|
-
fileName: string | null;
|
|
306
|
-
fileSize: number | null;
|
|
307
|
-
lastModified: number;
|
|
308
|
-
uploadProgress: number;
|
|
309
|
-
uuid: string | null;
|
|
310
|
-
isImage: boolean;
|
|
311
|
-
mimeType: string | null;
|
|
312
|
-
ctxName: string | null;
|
|
313
|
-
cdnUrl: string | null;
|
|
314
|
-
cdnUrlModifiers: string | null;
|
|
315
|
-
fileInfo: UploadcareFile | null;
|
|
316
|
-
isUploading: boolean;
|
|
317
|
-
abortController: AbortController | null;
|
|
318
|
-
thumbUrl: string | null;
|
|
319
|
-
silent: boolean;
|
|
320
|
-
source: string | null;
|
|
321
|
-
fullPath: string | null;
|
|
322
|
-
metadata: Metadata | null;
|
|
323
|
-
errors: OutputErrorFile[];
|
|
324
|
-
uploadError: Error | null;
|
|
325
|
-
isRemoved: boolean;
|
|
326
|
-
isQueuedForUploading: boolean;
|
|
327
|
-
isValidationPending: boolean;
|
|
328
|
-
isQueuedForValidation: boolean;
|
|
329
|
-
}
|
|
330
|
-
type UploadEntryTypedData = TypedData<UploadEntryData>;
|
|
331
|
-
type UploadEntryKeys = keyof UploadEntryData;
|
|
332
|
-
|
|
333
|
-
type ApiAddFileCommonOptions = {
|
|
334
|
-
silent?: boolean;
|
|
335
|
-
fileName?: string;
|
|
336
|
-
source?: string;
|
|
337
|
-
};
|
|
338
|
-
declare class UploaderPublicApi extends SharedInstance {
|
|
339
|
-
private _l10n;
|
|
340
|
-
get _uploadCollection(): TypedCollection<UploadEntryData>;
|
|
341
|
-
get cfg(): Readonly<ConfigType>;
|
|
342
|
-
get l10n(): (str: string, variables?: Record<string, string | number>) => string;
|
|
343
|
-
/**
|
|
344
|
-
* TODO: Probably we should not allow user to override `source` property
|
|
345
|
-
*/
|
|
346
|
-
addFileFromUrl: (url: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
347
|
-
addFileFromUuid: (uuid: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
348
|
-
addFileFromCdnUrl: (cdnUrl: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
349
|
-
addFileFromObject: (file: File, { silent, fileName, source, fullPath, }?: ApiAddFileCommonOptions & {
|
|
350
|
-
fullPath?: string;
|
|
351
|
-
}) => OutputFileEntry<"idle">;
|
|
352
|
-
removeFileByInternalId: (internalId: string) => void;
|
|
353
|
-
removeAllFiles(): void;
|
|
354
|
-
uploadAll: () => void;
|
|
355
|
-
openSystemDialog: (options?: {
|
|
356
|
-
captureCamera?: boolean;
|
|
357
|
-
modeCamera?: ModeCameraType;
|
|
358
|
-
}) => void;
|
|
359
|
-
getOutputItem<TStatus extends OutputFileStatus>(entryId: string): OutputFileEntry<TStatus>;
|
|
360
|
-
getOutputCollectionState<TStatus extends OutputCollectionStatus>(): ReturnType<typeof buildOutputCollectionState<TStatus>>;
|
|
361
|
-
initFlow: (force?: boolean) => void;
|
|
362
|
-
doneFlow: () => void;
|
|
363
|
-
setCurrentActivity: <T extends RegisteredActivityType>(activityType: T, ...params: T extends keyof ActivityParamsMap ? [ActivityParamsMap[T]] : T extends RegisteredActivityType ? [undefined?] : [never]) => void;
|
|
364
|
-
getCurrentActivity: () => ActivityType;
|
|
365
|
-
setModalState: (opened: boolean) => void;
|
|
366
|
-
private get _sourceList();
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
declare const ExternalUploadSource: Readonly<{
|
|
370
|
-
readonly FACEBOOK: "facebook";
|
|
371
|
-
readonly DROPBOX: "dropbox";
|
|
372
|
-
readonly DROPBOX_CHOOSER: "dropboxchooser";
|
|
373
|
-
readonly GDRIVE: "gdrive";
|
|
374
|
-
readonly GPHOTOS: "gphotos";
|
|
375
|
-
readonly FLICKR: "flickr";
|
|
376
|
-
readonly VK: "vk";
|
|
377
|
-
readonly EVERNOTE: "evernote";
|
|
378
|
-
readonly BOX: "box";
|
|
379
|
-
readonly ONEDRIVE: "onedrive";
|
|
380
|
-
readonly HUDDLE: "huddle";
|
|
381
|
-
}>;
|
|
382
|
-
declare const UploadSource: Readonly<{
|
|
383
|
-
readonly FACEBOOK: "facebook";
|
|
384
|
-
readonly DROPBOX: "dropbox";
|
|
385
|
-
readonly DROPBOX_CHOOSER: "dropboxchooser";
|
|
386
|
-
readonly GDRIVE: "gdrive";
|
|
387
|
-
readonly GPHOTOS: "gphotos";
|
|
388
|
-
readonly FLICKR: "flickr";
|
|
389
|
-
readonly VK: "vk";
|
|
390
|
-
readonly EVERNOTE: "evernote";
|
|
391
|
-
readonly BOX: "box";
|
|
392
|
-
readonly ONEDRIVE: "onedrive";
|
|
393
|
-
readonly HUDDLE: "huddle";
|
|
394
|
-
readonly MOBILE_VIDEO_CAMERA: "mobile-video-camera";
|
|
395
|
-
readonly MOBILE_PHOTO_CAMERA: "mobile-photo-camera";
|
|
396
|
-
readonly LOCAL: "local";
|
|
397
|
-
readonly DROP_AREA: "drop-area";
|
|
398
|
-
readonly CAMERA: "camera";
|
|
399
|
-
readonly EXTERNAL: "external";
|
|
400
|
-
readonly API: "js-api";
|
|
401
|
-
readonly URL: "url";
|
|
402
|
-
readonly DRAW: "draw";
|
|
403
|
-
}>;
|
|
404
|
-
type SourceTypes = (typeof UploadSource)[keyof typeof UploadSource];
|
|
405
|
-
|
|
406
|
-
declare class LitUploaderBlock extends LitActivityBlock {
|
|
407
|
-
static extSrcList: Readonly<typeof ExternalUploadSource>;
|
|
408
|
-
static sourceTypes: Readonly<typeof UploadSource>;
|
|
409
|
-
protected couldBeCtxOwner: boolean;
|
|
410
|
-
private _isCtxOwner;
|
|
411
|
-
private _unobserveCollection?;
|
|
412
|
-
private _unobserveCollectionProperties?;
|
|
413
|
-
init$: {
|
|
414
|
-
'*commonProgress': number;
|
|
415
|
-
'*uploadList': never[];
|
|
416
|
-
'*uploadQueue': _uploadcare_upload_client.Queue;
|
|
417
|
-
'*collectionErrors': OutputErrorCollection[];
|
|
418
|
-
'*collectionState': OutputCollectionState | null;
|
|
419
|
-
'*groupInfo': _uploadcare_upload_client.UploadcareGroup | null;
|
|
420
|
-
'*uploadTrigger': Set<string>;
|
|
421
|
-
'*currentActivity': null;
|
|
422
|
-
'*currentActivityParams': {};
|
|
423
|
-
'*history': never[];
|
|
424
|
-
'*historyBack': null;
|
|
425
|
-
'*closeModal': () => void;
|
|
426
|
-
};
|
|
427
|
-
private get _hasCtxOwner();
|
|
428
|
-
initCallback(): void;
|
|
429
|
-
getAPI(): UploaderPublicApi;
|
|
430
|
-
get validationManager(): ValidationManager;
|
|
431
|
-
get api(): UploaderPublicApi;
|
|
432
|
-
get uploadCollection(): TypedCollection<UploadEntryData>;
|
|
433
|
-
get secureUploadsManager(): SecureUploadsManager;
|
|
434
|
-
disconnectedCallback(): void;
|
|
435
|
-
connectedCallback(): void;
|
|
436
|
-
private _initCtxOwner;
|
|
437
|
-
private _observeUploadCollection;
|
|
438
|
-
private _unobserveUploadCollection;
|
|
439
|
-
private _createGroup;
|
|
440
|
-
private _flushOutputItems;
|
|
441
|
-
private _handleCollectionUpdate;
|
|
442
|
-
private _handleCollectionPropertiesUpdate;
|
|
443
|
-
private _flushCommonUploadProgress;
|
|
444
|
-
private _openCloudImageEditor;
|
|
445
|
-
private _setInitialCrop;
|
|
446
|
-
protected getMetadataFor(entryId: string): Promise<_uploadcare_upload_client.Metadata | undefined>;
|
|
447
|
-
protected getUploadClientOptions(): Promise<FileFromOptions>;
|
|
448
|
-
getOutputData(): OutputFileEntry[];
|
|
449
|
-
}
|
|
450
|
-
|
|
451
397
|
/**
|
|
452
398
|
* Mapping of loading resources per operation
|
|
453
399
|
*/
|
|
@@ -562,11 +508,14 @@ declare global {
|
|
|
562
508
|
declare class Icon extends LitBlock {
|
|
563
509
|
name: string;
|
|
564
510
|
private _resolvedHref;
|
|
511
|
+
private _pluginSvg;
|
|
565
512
|
private _iconHrefResolver;
|
|
513
|
+
private _unsubscribePlugins?;
|
|
566
514
|
initCallback(): void;
|
|
567
515
|
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
568
516
|
private _updateResolvedHref;
|
|
569
517
|
render(): lit_html.TemplateResult<1>;
|
|
518
|
+
disconnectedCallback(): void;
|
|
570
519
|
}
|
|
571
520
|
declare global {
|
|
572
521
|
interface HTMLElementTagNameMap {
|
|
@@ -1097,6 +1046,7 @@ declare class CloudImageEditorBlock extends LitBlock {
|
|
|
1097
1046
|
private _hasNetworkProblems;
|
|
1098
1047
|
private _isInitialized;
|
|
1099
1048
|
private _pendingInitUpdate;
|
|
1049
|
+
private _pendingSizeWait;
|
|
1100
1050
|
private readonly _debouncedShowLoader;
|
|
1101
1051
|
private readonly _imgRef;
|
|
1102
1052
|
private readonly _cropperRef;
|
|
@@ -1146,12 +1096,11 @@ type ActivityParams$1 = {
|
|
|
1146
1096
|
internalId: string;
|
|
1147
1097
|
};
|
|
1148
1098
|
declare class CloudImageEditorActivity extends LitUploaderBlock {
|
|
1149
|
-
couldBeCtxOwner: boolean;
|
|
1150
|
-
activityType: "cloud-image-edit";
|
|
1151
1099
|
private _entry?;
|
|
1152
1100
|
private _editorConfig;
|
|
1153
1101
|
get activityParams(): ActivityParams$1;
|
|
1154
1102
|
initCallback(): void;
|
|
1103
|
+
disconnectedCallback(): void;
|
|
1155
1104
|
private _handleApply;
|
|
1156
1105
|
private _handleCancel;
|
|
1157
1106
|
handleChange(event: CustomEvent<ChangeResult>): void;
|
|
@@ -1188,7 +1137,6 @@ type ActivityParams = {
|
|
|
1188
1137
|
};
|
|
1189
1138
|
declare class ExternalSource extends LitUploaderBlock {
|
|
1190
1139
|
couldBeCtxOwner: boolean;
|
|
1191
|
-
activityType: "external";
|
|
1192
1140
|
private _messageBridge?;
|
|
1193
1141
|
private _iframeRef;
|
|
1194
1142
|
private _latestSelectionSummary;
|
|
@@ -1232,22 +1180,26 @@ declare global {
|
|
|
1232
1180
|
declare const ACTIVITY_TYPES: Readonly<{
|
|
1233
1181
|
START_FROM: "start-from";
|
|
1234
1182
|
CAMERA: "camera";
|
|
1235
|
-
DRAW: "draw";
|
|
1236
1183
|
UPLOAD_LIST: "upload-list";
|
|
1237
1184
|
URL: "url";
|
|
1238
1185
|
CLOUD_IMG_EDIT: "cloud-image-edit";
|
|
1239
1186
|
EXTERNAL: "external";
|
|
1240
1187
|
}>;
|
|
1241
|
-
type RegisteredActivityType = (typeof ACTIVITY_TYPES)[keyof typeof ACTIVITY_TYPES];
|
|
1242
|
-
type ActivityType = RegisteredActivityType |
|
|
1188
|
+
type RegisteredActivityType = (typeof ACTIVITY_TYPES)[keyof typeof ACTIVITY_TYPES] | keyof CustomActivities;
|
|
1189
|
+
type ActivityType = RegisteredActivityType | null;
|
|
1243
1190
|
|
|
1244
1191
|
declare const ACTIVE_PROP = "___ACTIVITY_IS_ACTIVE___";
|
|
1192
|
+
interface CustomActivities {
|
|
1193
|
+
}
|
|
1245
1194
|
type ActivityParamsMap = {
|
|
1246
1195
|
'cloud-image-edit': ActivityParams$1;
|
|
1247
1196
|
external: ActivityParams;
|
|
1197
|
+
} & {
|
|
1198
|
+
[Key in keyof CustomActivities]: CustomActivities[Key]['params'];
|
|
1248
1199
|
};
|
|
1249
1200
|
declare class LitActivityBlock extends LitBlock {
|
|
1250
1201
|
protected historyTracked: boolean;
|
|
1202
|
+
activityType: ActivityType;
|
|
1251
1203
|
private [ACTIVE_PROP]?;
|
|
1252
1204
|
init$: {
|
|
1253
1205
|
'*currentActivity': null;
|
|
@@ -1261,12 +1213,11 @@ declare class LitActivityBlock extends LitBlock {
|
|
|
1261
1213
|
private _activate;
|
|
1262
1214
|
initCallback(): void;
|
|
1263
1215
|
private _historyFlush;
|
|
1264
|
-
|
|
1216
|
+
protected _isActivityRegistered(): boolean;
|
|
1265
1217
|
private static _activityCallbacks;
|
|
1266
1218
|
static activities: Readonly<{
|
|
1267
1219
|
START_FROM: 'start-from';
|
|
1268
1220
|
CAMERA: 'camera';
|
|
1269
|
-
DRAW: 'draw';
|
|
1270
1221
|
UPLOAD_LIST: 'upload-list';
|
|
1271
1222
|
URL: 'url';
|
|
1272
1223
|
CLOUD_IMG_EDIT: 'cloud-image-edit';
|
|
@@ -1282,8 +1233,8 @@ declare class LitActivityBlock extends LitBlock {
|
|
|
1282
1233
|
private _unregisterActivity;
|
|
1283
1234
|
disconnectedCallback(): void;
|
|
1284
1235
|
get activityParams(): ActivityParamsMap[keyof ActivityParamsMap];
|
|
1285
|
-
get initActivity():
|
|
1286
|
-
get doneActivity():
|
|
1236
|
+
get initActivity(): RegisteredActivityType | null;
|
|
1237
|
+
get doneActivity(): RegisteredActivityType | null;
|
|
1287
1238
|
historyBack(): void;
|
|
1288
1239
|
}
|
|
1289
1240
|
|
|
@@ -1345,7 +1296,9 @@ type EventPayload = {
|
|
|
1345
1296
|
declare class EventEmitter extends SharedInstance {
|
|
1346
1297
|
private _timeoutStore;
|
|
1347
1298
|
private _targets;
|
|
1299
|
+
private _listeners;
|
|
1348
1300
|
bindTarget(target: LitBlock): () => void;
|
|
1301
|
+
on<T extends EventKey>(type: T, handler: (payload: EventPayload[T]) => void): () => void;
|
|
1349
1302
|
private _dispatch;
|
|
1350
1303
|
emit<T extends EventKey, TDebounce extends boolean | number | undefined = undefined>(type: T, payload?: TDebounce extends false | undefined ? EventPayload[T] : () => EventPayload[T], options?: {
|
|
1351
1304
|
debounce?: TDebounce;
|
|
@@ -1353,20 +1306,123 @@ declare class EventEmitter extends SharedInstance {
|
|
|
1353
1306
|
destroy(): void;
|
|
1354
1307
|
}
|
|
1355
1308
|
|
|
1356
|
-
type
|
|
1357
|
-
|
|
1309
|
+
type ApiAddFileCommonOptions = {
|
|
1310
|
+
silent?: boolean;
|
|
1311
|
+
fileName?: string;
|
|
1312
|
+
source?: string;
|
|
1358
1313
|
};
|
|
1314
|
+
declare class UploaderPublicApi extends SharedInstance {
|
|
1315
|
+
private _l10n;
|
|
1316
|
+
get _uploadCollection(): TypedCollection<UploadEntryData>;
|
|
1317
|
+
get cfg(): Readonly<ConfigType>;
|
|
1318
|
+
get l10n(): (str: string, variables?: Record<string, string | number>) => string;
|
|
1319
|
+
/**
|
|
1320
|
+
* TODO: Probably we should not allow user to override `source` property
|
|
1321
|
+
*/
|
|
1322
|
+
addFileFromUrl: (url: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
1323
|
+
addFileFromUuid: (uuid: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
1324
|
+
addFileFromCdnUrl: (cdnUrl: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
1325
|
+
addFileFromObject: (file: File, { silent, fileName, source, fullPath, }?: ApiAddFileCommonOptions & {
|
|
1326
|
+
fullPath?: string;
|
|
1327
|
+
}) => OutputFileEntry<"idle">;
|
|
1328
|
+
removeFileByInternalId: (internalId: string) => void;
|
|
1329
|
+
removeAllFiles(): void;
|
|
1330
|
+
uploadAll: () => void;
|
|
1331
|
+
openSystemDialog: (options?: {
|
|
1332
|
+
captureCamera?: boolean;
|
|
1333
|
+
modeCamera?: ModeCameraType;
|
|
1334
|
+
}) => void;
|
|
1335
|
+
getOutputItem<TStatus extends OutputFileStatus>(entryId: string): OutputFileEntry<TStatus>;
|
|
1336
|
+
getOutputCollectionState<TStatus extends OutputCollectionStatus>(): ReturnType<typeof buildOutputCollectionState<TStatus>>;
|
|
1337
|
+
initFlow: (force?: boolean) => void;
|
|
1338
|
+
doneFlow: () => void;
|
|
1339
|
+
private _pluginsReady;
|
|
1340
|
+
setCurrentActivity: <T extends ActivityType>(activityType: T, ...params: T extends keyof ActivityParamsMap ? [ActivityParamsMap[T]] extends [never] ? [] : [ActivityParamsMap[T]] : []) => void;
|
|
1341
|
+
on: <T extends EventKey>(type: T, handler: (payload: EventPayload[T]) => void) => (() => void);
|
|
1342
|
+
getCurrentActivity: () => ActivityType;
|
|
1343
|
+
historyBack: () => void;
|
|
1344
|
+
setModalState: (opened: boolean) => void;
|
|
1345
|
+
private get _sourceList();
|
|
1346
|
+
}
|
|
1359
1347
|
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1348
|
+
declare const ExternalUploadSource: Readonly<{
|
|
1349
|
+
readonly FACEBOOK: "facebook";
|
|
1350
|
+
readonly DROPBOX: "dropbox";
|
|
1351
|
+
readonly DROPBOX_CHOOSER: "dropboxchooser";
|
|
1352
|
+
readonly GDRIVE: "gdrive";
|
|
1353
|
+
readonly GPHOTOS: "gphotos";
|
|
1354
|
+
readonly FLICKR: "flickr";
|
|
1355
|
+
readonly VK: "vk";
|
|
1356
|
+
readonly EVERNOTE: "evernote";
|
|
1357
|
+
readonly BOX: "box";
|
|
1358
|
+
readonly ONEDRIVE: "onedrive";
|
|
1359
|
+
readonly HUDDLE: "huddle";
|
|
1360
|
+
}>;
|
|
1361
|
+
declare const UploadSource: Readonly<{
|
|
1362
|
+
readonly FACEBOOK: "facebook";
|
|
1363
|
+
readonly DROPBOX: "dropbox";
|
|
1364
|
+
readonly DROPBOX_CHOOSER: "dropboxchooser";
|
|
1365
|
+
readonly GDRIVE: "gdrive";
|
|
1366
|
+
readonly GPHOTOS: "gphotos";
|
|
1367
|
+
readonly FLICKR: "flickr";
|
|
1368
|
+
readonly VK: "vk";
|
|
1369
|
+
readonly EVERNOTE: "evernote";
|
|
1370
|
+
readonly BOX: "box";
|
|
1371
|
+
readonly ONEDRIVE: "onedrive";
|
|
1372
|
+
readonly HUDDLE: "huddle";
|
|
1373
|
+
readonly MOBILE_VIDEO_CAMERA: "mobile-video-camera";
|
|
1374
|
+
readonly MOBILE_PHOTO_CAMERA: "mobile-photo-camera";
|
|
1375
|
+
readonly LOCAL: "local";
|
|
1376
|
+
readonly DROP_AREA: "drop-area";
|
|
1377
|
+
readonly CAMERA: "camera";
|
|
1378
|
+
readonly EXTERNAL: "external";
|
|
1379
|
+
readonly API: "js-api";
|
|
1380
|
+
readonly URL: "url";
|
|
1381
|
+
}>;
|
|
1382
|
+
type SourceTypes = (typeof UploadSource)[keyof typeof UploadSource];
|
|
1383
|
+
|
|
1384
|
+
declare class LitUploaderBlock extends LitActivityBlock {
|
|
1385
|
+
static extSrcList: Readonly<typeof ExternalUploadSource>;
|
|
1386
|
+
static sourceTypes: Readonly<typeof UploadSource>;
|
|
1387
|
+
protected couldBeCtxOwner: boolean;
|
|
1388
|
+
private _isCtxOwner;
|
|
1389
|
+
private _unobserveCollection?;
|
|
1390
|
+
private _unobserveCollectionProperties?;
|
|
1391
|
+
init$: {
|
|
1392
|
+
'*commonProgress': number;
|
|
1393
|
+
'*uploadList': never[];
|
|
1394
|
+
'*uploadQueue': _uploadcare_upload_client.Queue;
|
|
1395
|
+
'*collectionErrors': OutputErrorCollection[];
|
|
1396
|
+
'*collectionState': OutputCollectionState | null;
|
|
1397
|
+
'*groupInfo': _uploadcare_upload_client.UploadcareGroup | null;
|
|
1398
|
+
'*uploadTrigger': Set<string>;
|
|
1399
|
+
'*currentActivity': null;
|
|
1400
|
+
'*currentActivityParams': {};
|
|
1401
|
+
'*history': never[];
|
|
1402
|
+
'*historyBack': null;
|
|
1403
|
+
'*closeModal': () => void;
|
|
1404
|
+
};
|
|
1405
|
+
private get _hasCtxOwner();
|
|
1406
|
+
initCallback(): void;
|
|
1407
|
+
getAPI(): UploaderPublicApi;
|
|
1408
|
+
get validationManager(): ValidationManager;
|
|
1409
|
+
get api(): UploaderPublicApi;
|
|
1410
|
+
get uploadCollection(): TypedCollection<UploadEntryData>;
|
|
1411
|
+
get secureUploadsManager(): SecureUploadsManager;
|
|
1412
|
+
disconnectedCallback(): void;
|
|
1413
|
+
connectedCallback(): void;
|
|
1414
|
+
private _initCtxOwner;
|
|
1415
|
+
private _observeUploadCollection;
|
|
1416
|
+
private _unobserveUploadCollection;
|
|
1417
|
+
private _createGroup;
|
|
1418
|
+
private _flushOutputItems;
|
|
1419
|
+
private _handleCollectionUpdate;
|
|
1420
|
+
private _handleCollectionPropertiesUpdate;
|
|
1421
|
+
private _flushCommonUploadProgress;
|
|
1422
|
+
private _setInitialCrop;
|
|
1423
|
+
protected getMetadataFor(entryId: string): Promise<_uploadcare_upload_client.Metadata | undefined>;
|
|
1424
|
+
protected getUploadClientOptions(): Promise<FileFromOptions>;
|
|
1425
|
+
getOutputData(): OutputFileEntry[];
|
|
1370
1426
|
}
|
|
1371
1427
|
|
|
1372
1428
|
type SelectOption = {
|
|
@@ -1389,7 +1445,6 @@ declare global {
|
|
|
1389
1445
|
type CameraMode = 'photo' | 'video';
|
|
1390
1446
|
declare class CameraSource extends LitUploaderBlock {
|
|
1391
1447
|
couldBeCtxOwner: boolean;
|
|
1392
|
-
activityType: "camera";
|
|
1393
1448
|
private _unsubPermissions;
|
|
1394
1449
|
private _capturing;
|
|
1395
1450
|
private _chunks;
|
|
@@ -1509,25 +1564,54 @@ declare global {
|
|
|
1509
1564
|
/**
|
|
1510
1565
|
* Config keys that can't be passed as attribute (because they are object or function)
|
|
1511
1566
|
*/
|
|
1512
|
-
declare const complexConfigKeys: readonly ["metadata", "localeDefinitionOverride", "secureUploadsSignatureResolver", "secureDeliveryProxyUrlResolver", "iconHrefResolver", "fileValidators", "collectionValidators", "mediaRecorderOptions"];
|
|
1513
|
-
/** Mapping of attribute names to state */
|
|
1514
|
-
declare const attrStateMapping: Record<string, string>;
|
|
1567
|
+
declare const complexConfigKeys: readonly ["metadata", "plugins", "localeDefinitionOverride", "secureUploadsSignatureResolver", "secureDeliveryProxyUrlResolver", "iconHrefResolver", "fileValidators", "collectionValidators", "mediaRecorderOptions"];
|
|
1515
1568
|
declare class Config extends LitBlock {
|
|
1516
1569
|
attributesMeta: Partial<ConfigPlainType> & {
|
|
1517
1570
|
'ctx-name': string;
|
|
1518
1571
|
};
|
|
1519
1572
|
init$: LitBlock["init$"] & ConfigType;
|
|
1520
1573
|
private _computationControllers;
|
|
1574
|
+
private _pluginChangeUnsubscribe?;
|
|
1575
|
+
private _mutationObserver?;
|
|
1576
|
+
/**
|
|
1577
|
+
* Mapping of attribute names to custom config keys for plugin-registered configs.
|
|
1578
|
+
* Updated dynamically when plugins are registered or changed.
|
|
1579
|
+
* Similar to builtinAttrKeyMapping but for custom configs.
|
|
1580
|
+
*/
|
|
1581
|
+
private _customAttrKeyMapping;
|
|
1582
|
+
/** Set of all custom config names registered by plugins */
|
|
1583
|
+
private _customConfigKeys;
|
|
1584
|
+
/**
|
|
1585
|
+
* Map of custom config subscriptions (config name -> unsubscribe function)
|
|
1586
|
+
* Used to track and clean up subscriptions when plugins change
|
|
1587
|
+
*/
|
|
1588
|
+
private _customConfigSubscriptions;
|
|
1589
|
+
/**
|
|
1590
|
+
* Check if a key is a custom config (registered by plugins)
|
|
1591
|
+
*/
|
|
1592
|
+
private _isCustomConfig;
|
|
1593
|
+
/**
|
|
1594
|
+
* Get the custom config definition for a key
|
|
1595
|
+
*/
|
|
1596
|
+
private _getCustomConfigDefinition;
|
|
1597
|
+
/**
|
|
1598
|
+
* Get attribute names for a config key (kebab-case and lowercase)
|
|
1599
|
+
*/
|
|
1600
|
+
private _getAttributeNames;
|
|
1521
1601
|
private _flushValueToAttribute;
|
|
1522
1602
|
private _flushValueToState;
|
|
1523
1603
|
private _setValue;
|
|
1524
1604
|
private _getValue;
|
|
1525
1605
|
private _assertSameValueDifferentReference;
|
|
1606
|
+
private _processCustomConfigs;
|
|
1607
|
+
private _setupCustomConfigs;
|
|
1608
|
+
private _setupMutationObserver;
|
|
1526
1609
|
initCallback(): void;
|
|
1527
|
-
attributeChangedCallback(name:
|
|
1610
|
+
attributeChangedCallback(name: string, oldVal: string, newVal: string): void;
|
|
1611
|
+
disconnectedCallback(): void;
|
|
1528
1612
|
static get observedAttributes(): string[];
|
|
1529
1613
|
}
|
|
1530
|
-
interface Config extends ConfigType {
|
|
1614
|
+
interface Config extends ConfigType, CustomConfig {
|
|
1531
1615
|
}
|
|
1532
1616
|
declare global {
|
|
1533
1617
|
interface HTMLElementTagNameMap {
|
|
@@ -1611,12 +1695,12 @@ declare class FileItem extends FileItemConfig {
|
|
|
1611
1695
|
private _isFailed;
|
|
1612
1696
|
private _isUploading;
|
|
1613
1697
|
private _isFocused;
|
|
1614
|
-
private _isEditable;
|
|
1615
1698
|
private _showFileNames;
|
|
1616
1699
|
private _ariaLabelStatusFile;
|
|
1700
|
+
private _pluginFileActions;
|
|
1617
1701
|
private _renderedOnce;
|
|
1618
1702
|
private _observer?;
|
|
1619
|
-
private
|
|
1703
|
+
private _unsubscribePlugins?;
|
|
1620
1704
|
private _handleRemove;
|
|
1621
1705
|
private _handleUploadClick;
|
|
1622
1706
|
private _calculateState;
|
|
@@ -1628,6 +1712,8 @@ declare class FileItem extends FileItemConfig {
|
|
|
1628
1712
|
private _handleEntryId;
|
|
1629
1713
|
private _updateShowFileNames;
|
|
1630
1714
|
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
1715
|
+
private _updatePluginFileActions;
|
|
1716
|
+
private _handlePluginFileAction;
|
|
1631
1717
|
initCallback(): void;
|
|
1632
1718
|
connectedCallback(): void;
|
|
1633
1719
|
disconnectedCallback(): void;
|
|
@@ -1936,6 +2022,10 @@ type ConfigType = {
|
|
|
1936
2022
|
* Expiry threshold for secure uploads.
|
|
1937
2023
|
*/
|
|
1938
2024
|
secureUploadsExpireThreshold: number;
|
|
2025
|
+
/**
|
|
2026
|
+
* Array of plugins to register with the uploader instance.
|
|
2027
|
+
*/
|
|
2028
|
+
plugins: UploaderPlugin[];
|
|
1939
2029
|
/**
|
|
1940
2030
|
* Metadata for the file.
|
|
1941
2031
|
*/
|
|
@@ -2196,10 +2286,237 @@ type OutputCollectionState<TStatus extends OutputCollectionStatus = OutputCollec
|
|
|
2196
2286
|
allEntries: OutputFileEntry[];
|
|
2197
2287
|
});
|
|
2198
2288
|
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2289
|
+
type PluginIconRegistration = {
|
|
2290
|
+
name: string;
|
|
2291
|
+
svg: string;
|
|
2292
|
+
};
|
|
2293
|
+
type PluginI18nRegistration = Record<string, Record<string, string>>;
|
|
2294
|
+
type PluginSourceRegistration = {
|
|
2295
|
+
id: string;
|
|
2296
|
+
label: string;
|
|
2297
|
+
icon?: string;
|
|
2298
|
+
/**
|
|
2299
|
+
* @internal
|
|
2300
|
+
*
|
|
2301
|
+
* Optional expansion function. When present, SourceList calls this to determine
|
|
2302
|
+
* which source IDs should actually be rendered in place of this source.
|
|
2303
|
+
* Useful for sources that map to multiple device-specific variants (e.g. camera
|
|
2304
|
+
* expanding to separate photo/video buttons on mobile).
|
|
2305
|
+
* Return `[id]` (the source's own id) to render it as-is.
|
|
2306
|
+
*/
|
|
2307
|
+
expand?: () => string[];
|
|
2308
|
+
onSelect: () => Promise<void> | void;
|
|
2309
|
+
};
|
|
2310
|
+
type PluginRenderDispose = () => void;
|
|
2311
|
+
type PluginRender = (el: HTMLElement, activityParams: Record<string, unknown>) => PluginRenderDispose | undefined;
|
|
2312
|
+
type PluginActivityRegistration = {
|
|
2313
|
+
id: string;
|
|
2314
|
+
render: PluginRender;
|
|
2315
|
+
};
|
|
2316
|
+
type PluginFileActionRegistration = {
|
|
2317
|
+
/** Unique action identifier. */
|
|
2318
|
+
id: string;
|
|
2319
|
+
/** Icon name to display in the action button. */
|
|
2320
|
+
icon: string;
|
|
2321
|
+
/** Label shown next to the icon in the action button. Accepts a plain string or an i18n key registered via `registerI18n`. */
|
|
2322
|
+
label: string;
|
|
2323
|
+
/** Return `true` to show the action button for the given file entry. */
|
|
2324
|
+
shouldRender: (fileEntry: OutputFileEntry) => boolean;
|
|
2325
|
+
onClick: (fileEntry: OutputFileEntry) => void | Promise<void>;
|
|
2326
|
+
};
|
|
2327
|
+
type PluginFileHookResult = {
|
|
2328
|
+
/** The (optionally transformed) file */
|
|
2329
|
+
file: File | Blob;
|
|
2330
|
+
};
|
|
2331
|
+
type PluginFileHookContext = PluginFileHookResult & {
|
|
2332
|
+
/**
|
|
2333
|
+
* An AbortSignal that fires when the operation is cancelled (e.g. upload aborted or file removed).
|
|
2334
|
+
* Hooks should respect this signal to avoid doing unnecessary work.
|
|
2335
|
+
*/
|
|
2336
|
+
signal: AbortSignal;
|
|
2337
|
+
};
|
|
2338
|
+
type PluginFileHookRegistration = {
|
|
2339
|
+
/**
|
|
2340
|
+
* When the hook is called:
|
|
2341
|
+
* - `'beforeUpload'`: called right before the file is uploaded.
|
|
2342
|
+
* - `'onAdd'`: called after the file is added to the upload list.
|
|
2343
|
+
*
|
|
2344
|
+
* Return the (optionally transformed) file. After the hook runs, `mimeType`,
|
|
2345
|
+
* `isImage`, `fileSize`, and `fileName` are all re-derived from the returned file.
|
|
2346
|
+
*/
|
|
2347
|
+
type: 'beforeUpload' | 'onAdd';
|
|
2348
|
+
handler: (context: PluginFileHookContext) => PluginFileHookResult | Promise<PluginFileHookResult>;
|
|
2349
|
+
/**
|
|
2350
|
+
* Maximum time in milliseconds to wait for the hook to complete before skipping it.
|
|
2351
|
+
* @default 30000
|
|
2352
|
+
*/
|
|
2353
|
+
timeout?: number;
|
|
2354
|
+
};
|
|
2355
|
+
type PluginRegistryApi = {
|
|
2356
|
+
registerSource: (source: PluginSourceRegistration) => void;
|
|
2357
|
+
registerActivity: (activity: PluginActivityRegistration) => void;
|
|
2358
|
+
registerFileAction: (fileAction: PluginFileActionRegistration) => void;
|
|
2359
|
+
registerFileHook: (hook: PluginFileHookRegistration) => void;
|
|
2360
|
+
registerIcon: (icon: PluginIconRegistration) => void;
|
|
2361
|
+
registerI18n: (i18n: PluginI18nRegistration) => void;
|
|
2362
|
+
registerConfig: <T = unknown>(definition: CustomConfigDefinition<T>) => void;
|
|
2363
|
+
};
|
|
2364
|
+
/**
|
|
2365
|
+
* API for managing plugin config subscriptions
|
|
2366
|
+
*/
|
|
2367
|
+
type PluginConfigApi = {
|
|
2368
|
+
get: <TKey extends keyof (ConfigType & CustomConfig)>(configName: TKey) => (ConfigType & CustomConfig)[TKey];
|
|
2369
|
+
subscribe: <TKey extends keyof (ConfigType & CustomConfig)>(configName: TKey, callback: (value: (ConfigType & CustomConfig)[TKey]) => void) => () => void;
|
|
2370
|
+
};
|
|
2371
|
+
/**
|
|
2372
|
+
* API for managing plugin activity interactions
|
|
2373
|
+
*/
|
|
2374
|
+
type PluginActivityApi = {
|
|
2375
|
+
/**
|
|
2376
|
+
* Get the current activity parameters.
|
|
2377
|
+
*
|
|
2378
|
+
* @returns The current activity parameters object
|
|
2379
|
+
*
|
|
2380
|
+
* @example
|
|
2381
|
+
* ```typescript
|
|
2382
|
+
* const params = pluginApi.activity.getParams();
|
|
2383
|
+
* console.log('Current params:', params);
|
|
2384
|
+
* ```
|
|
2385
|
+
*/
|
|
2386
|
+
getParams: () => Record<string, unknown>;
|
|
2387
|
+
/**
|
|
2388
|
+
* Subscribe to changes in activity parameters.
|
|
2389
|
+
* The callback will be called immediately with the current params,
|
|
2390
|
+
* and then whenever the params change.
|
|
2391
|
+
*
|
|
2392
|
+
* Subscriptions are automatically cleaned up when the plugin is disposed.
|
|
2393
|
+
*
|
|
2394
|
+
* @param callback - Function to call with the new params
|
|
2395
|
+
* @returns Unsubscribe function
|
|
2396
|
+
*
|
|
2397
|
+
* @example
|
|
2398
|
+
* ```typescript
|
|
2399
|
+
* pluginApi.activity.subscribeToParams((params) => {
|
|
2400
|
+
* console.log('Activity params changed:', params);
|
|
2401
|
+
* });
|
|
2402
|
+
* // Cleanup happens automatically on plugin disposal
|
|
2403
|
+
* ```
|
|
2404
|
+
*/
|
|
2405
|
+
subscribeToParams: (callback: (params: Record<string, unknown>) => void) => () => void;
|
|
2406
|
+
};
|
|
2407
|
+
type PluginFileEntryUpdate = {
|
|
2408
|
+
file?: File | Blob;
|
|
2409
|
+
cdnUrl?: string | null;
|
|
2410
|
+
cdnUrlModifiers?: string | null;
|
|
2411
|
+
mimeType?: string | null;
|
|
2412
|
+
};
|
|
2413
|
+
type PluginFilesApi = {
|
|
2414
|
+
/**
|
|
2415
|
+
* Update mutable properties of a file entry by its internalId.
|
|
2416
|
+
* `fileSize` is recalculated automatically when `file` is provided.
|
|
2417
|
+
*/
|
|
2418
|
+
update: (internalId: string, changes: PluginFileEntryUpdate) => void;
|
|
2419
|
+
};
|
|
2420
|
+
type PluginApi = {
|
|
2421
|
+
registry: PluginRegistryApi;
|
|
2422
|
+
config: PluginConfigApi;
|
|
2423
|
+
activity: PluginActivityApi;
|
|
2424
|
+
files: PluginFilesApi;
|
|
2425
|
+
};
|
|
2426
|
+
type PluginUploaderApi = UploaderPublicApi;
|
|
2427
|
+
type PluginSetupResult = (() => void) | void | Promise<(() => void) | void>;
|
|
2428
|
+
type PluginSetupParams = {
|
|
2429
|
+
pluginApi: PluginApi;
|
|
2430
|
+
uploaderApi: PluginUploaderApi;
|
|
2431
|
+
};
|
|
2432
|
+
type UploaderPlugin = {
|
|
2433
|
+
id: string;
|
|
2434
|
+
setup: (params: PluginSetupParams) => PluginSetupResult;
|
|
2435
|
+
};
|
|
2436
|
+
type Owned<T> = T & {
|
|
2437
|
+
pluginId: string;
|
|
2438
|
+
};
|
|
2439
|
+
type PluginRegistrySnapshot = {
|
|
2440
|
+
sources: Owned<PluginSourceRegistration>[];
|
|
2441
|
+
activities: Owned<PluginActivityRegistration>[];
|
|
2442
|
+
fileActions: Owned<PluginFileActionRegistration>[];
|
|
2443
|
+
fileHooks: Owned<PluginFileHookRegistration>[];
|
|
2444
|
+
icons: Owned<PluginIconRegistration>[];
|
|
2445
|
+
i18n: Owned<PluginI18nRegistration>[];
|
|
2446
|
+
};
|
|
2447
|
+
|
|
2448
|
+
type EventMap = {
|
|
2449
|
+
[T in keyof EventPayload]: CustomEvent<EventPayload[T]>;
|
|
2450
|
+
};
|
|
2451
|
+
|
|
2452
|
+
interface UploadEntryData extends Record<string, unknown> {
|
|
2453
|
+
file: File | null;
|
|
2454
|
+
externalUrl: string | null;
|
|
2455
|
+
fileName: string | null;
|
|
2456
|
+
fileSize: number | null;
|
|
2457
|
+
lastModified: number;
|
|
2458
|
+
uploadProgress: number;
|
|
2459
|
+
uuid: string | null;
|
|
2460
|
+
isImage: boolean;
|
|
2461
|
+
mimeType: string | null;
|
|
2462
|
+
ctxName: string | null;
|
|
2463
|
+
cdnUrl: string | null;
|
|
2464
|
+
cdnUrlModifiers: string | null;
|
|
2465
|
+
fileInfo: UploadcareFile | null;
|
|
2466
|
+
isUploading: boolean;
|
|
2467
|
+
abortController: AbortController | null;
|
|
2468
|
+
thumbUrl: string | null;
|
|
2469
|
+
silent: boolean;
|
|
2470
|
+
source: string | null;
|
|
2471
|
+
fullPath: string | null;
|
|
2472
|
+
metadata: Metadata | null;
|
|
2473
|
+
errors: OutputErrorFile[];
|
|
2474
|
+
uploadError: Error | null;
|
|
2475
|
+
isRemoved: boolean;
|
|
2476
|
+
isQueuedForUploading: boolean;
|
|
2477
|
+
isValidationPending: boolean;
|
|
2478
|
+
isQueuedForValidation: boolean;
|
|
2479
|
+
}
|
|
2480
|
+
type UploadEntryTypedData = TypedData<UploadEntryData>;
|
|
2481
|
+
type UploadEntryKeys = keyof UploadEntryData;
|
|
2482
|
+
|
|
2483
|
+
declare class PluginRegistry {
|
|
2484
|
+
private _sources;
|
|
2485
|
+
private _activities;
|
|
2486
|
+
private _fileActions;
|
|
2487
|
+
private _fileHooks;
|
|
2488
|
+
private _icons;
|
|
2489
|
+
private _i18n;
|
|
2490
|
+
readonly config: CustomConfigRegistry;
|
|
2491
|
+
private _own;
|
|
2492
|
+
addSource(pluginId: string, item: PluginSourceRegistration): void;
|
|
2493
|
+
addActivity(pluginId: string, item: PluginActivityRegistration): void;
|
|
2494
|
+
addFileAction(pluginId: string, item: PluginFileActionRegistration): void;
|
|
2495
|
+
addFileHook(pluginId: string, item: PluginFileHookRegistration): void;
|
|
2496
|
+
addIcon(pluginId: string, item: PluginIconRegistration): void;
|
|
2497
|
+
addI18n(pluginId: string, item: PluginI18nRegistration): void;
|
|
2498
|
+
addConfig<T>(pluginId: string, definition: CustomConfigDefinition<T>): void;
|
|
2499
|
+
purge(pluginId: string): void;
|
|
2500
|
+
snapshot(): PluginRegistrySnapshot;
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
declare class PluginManager extends SharedInstance {
|
|
2504
|
+
private _plugins;
|
|
2505
|
+
private _subscribers;
|
|
2506
|
+
private _pluginsUpdate;
|
|
2507
|
+
private _lazyPluginLoader;
|
|
2508
|
+
readonly registry: PluginRegistry;
|
|
2509
|
+
get configRegistry(): CustomConfigRegistry;
|
|
2510
|
+
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
2511
|
+
pluginsReady(): Promise<void>;
|
|
2512
|
+
onPluginsChange(callback: Unsubscriber): Unsubscriber;
|
|
2513
|
+
private _syncPlugins;
|
|
2514
|
+
private _registerPlugin;
|
|
2515
|
+
private _unregisterPlugin;
|
|
2516
|
+
snapshot(): PluginRegistrySnapshot;
|
|
2517
|
+
runOnAddHooks(entry: UploadEntryTypedData): Promise<void>;
|
|
2202
2518
|
destroy(): void;
|
|
2519
|
+
private _notifySubscribers;
|
|
2203
2520
|
}
|
|
2204
2521
|
|
|
2205
2522
|
type CommonEventType = InternalEventKey | EventKey;
|
|
@@ -2240,14 +2557,87 @@ declare class TelemetryManager extends SharedInstance {
|
|
|
2240
2557
|
private get _location();
|
|
2241
2558
|
}
|
|
2242
2559
|
|
|
2560
|
+
interface ISharedInstance {
|
|
2561
|
+
destroy?(): void;
|
|
2562
|
+
}
|
|
2563
|
+
declare class SharedInstance {
|
|
2564
|
+
protected _ctx: PubSub<SharedState>;
|
|
2565
|
+
protected _sharedInstancesBag: SharedInstancesBag;
|
|
2566
|
+
private _subscriptions;
|
|
2567
|
+
private _cfgProxy;
|
|
2568
|
+
protected _debugPrint: (...args: unknown[]) => void;
|
|
2569
|
+
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
2570
|
+
protected addSub(unsub: () => void): void;
|
|
2571
|
+
protected get _cfg(): Readonly<ConfigType>;
|
|
2572
|
+
destroy(): void;
|
|
2573
|
+
}
|
|
2574
|
+
declare const instanceKeyMap: {
|
|
2575
|
+
modalManager: "*modalManager";
|
|
2576
|
+
pluginManager: "*pluginManager";
|
|
2577
|
+
telemetryManager: "*telemetryManager";
|
|
2578
|
+
localeManager: "*localeManager";
|
|
2579
|
+
a11y: "*a11y";
|
|
2580
|
+
clipboard: "*clipboard";
|
|
2581
|
+
blocksRegistry: "*blocksRegistry";
|
|
2582
|
+
eventEmitter: "*eventEmitter";
|
|
2583
|
+
uploadCollection: "*uploadCollection";
|
|
2584
|
+
secureUploadsManager: "*secureUploadsManager";
|
|
2585
|
+
api: "*publicApi";
|
|
2586
|
+
validationManager: "*validationManager";
|
|
2587
|
+
};
|
|
2588
|
+
type InstanceTypeMap = {
|
|
2589
|
+
[key in keyof typeof instanceKeyMap]: SharedState[(typeof instanceKeyMap)[key]];
|
|
2590
|
+
};
|
|
2591
|
+
type InstanceName = keyof typeof instanceKeyMap;
|
|
2592
|
+
type SharedInstancesState = Pick<SharedState, (typeof instanceKeyMap)[keyof typeof instanceKeyMap]>;
|
|
2593
|
+
type SharedInstancesBag = ReturnType<typeof createSharedInstancesBag>;
|
|
2594
|
+
declare const createSharedInstancesBag: (getCtx: () => PubSub<SharedState>) => {
|
|
2595
|
+
readonly ctx: PubSub<SharedState>;
|
|
2596
|
+
readonly modalManager: ModalManager | null;
|
|
2597
|
+
readonly pluginManager: PluginManager;
|
|
2598
|
+
readonly telemetryManager: TelemetryManager;
|
|
2599
|
+
readonly localeManager: LocaleManager;
|
|
2600
|
+
readonly a11y: A11y;
|
|
2601
|
+
readonly blocksRegistry: Set<LitBlock>;
|
|
2602
|
+
readonly eventEmitter: EventEmitter;
|
|
2603
|
+
readonly uploadCollection: TypedCollection<UploadEntryData>;
|
|
2604
|
+
readonly secureUploadsManager: SecureUploadsManager;
|
|
2605
|
+
readonly api: UploaderPublicApi;
|
|
2606
|
+
readonly validationManager: ValidationManager;
|
|
2607
|
+
when<TName extends InstanceName>(name: TName, callback: (instance: NonNullable<InstanceTypeMap[TName]>) => void): () => void;
|
|
2608
|
+
wait<TName extends InstanceName>(name: TName): Promise<NonNullable<InstanceTypeMap[TName]>>;
|
|
2609
|
+
};
|
|
2610
|
+
|
|
2611
|
+
type PasteScope = 'local' | 'global' | false;
|
|
2612
|
+
declare class ClipboardLayer extends SharedInstance {
|
|
2613
|
+
private scopes;
|
|
2614
|
+
private listener;
|
|
2615
|
+
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
2616
|
+
private openUploadList;
|
|
2617
|
+
private _listener;
|
|
2618
|
+
private handlePaste;
|
|
2619
|
+
registerBlock(scope: Node): () => void;
|
|
2620
|
+
destroy(): void;
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
type ConfigGetter = <K extends keyof ConfigType>(key: K) => ConfigType[K];
|
|
2624
|
+
type LazyPluginEntry = {
|
|
2625
|
+
configDeps: readonly (keyof ConfigType)[];
|
|
2626
|
+
isEnabled: (get: ConfigGetter) => boolean;
|
|
2627
|
+
load: () => UploaderPlugin | undefined | Promise<UploaderPlugin | undefined>;
|
|
2628
|
+
};
|
|
2629
|
+
|
|
2243
2630
|
type SharedConfigState = {
|
|
2244
2631
|
[K in keyof ConfigType as `*cfg/${K}`]: ConfigType[K];
|
|
2245
2632
|
};
|
|
2633
|
+
type SharedCustomConfigState = {
|
|
2634
|
+
[K in keyof CustomConfig as `*cfg/${K}`]: CustomConfig[K];
|
|
2635
|
+
};
|
|
2246
2636
|
type BlocksRegistry = Set<LitBlock>;
|
|
2247
2637
|
type ActivityBlockCtxState = {
|
|
2248
|
-
'*currentActivity':
|
|
2638
|
+
'*currentActivity': RegisteredActivityType | null;
|
|
2249
2639
|
'*currentActivityParams': Record<string, unknown>;
|
|
2250
|
-
'*history': (
|
|
2640
|
+
'*history': (RegisteredActivityType | null)[];
|
|
2251
2641
|
'*historyBack': (() => void) | null;
|
|
2252
2642
|
'*closeModal': () => void;
|
|
2253
2643
|
};
|
|
@@ -2264,6 +2654,7 @@ type UploaderBlockCtxState = ActivityBlockCtxState & {
|
|
|
2264
2654
|
};
|
|
2265
2655
|
type SolutionBlockCtxState = UploaderBlockCtxState & {
|
|
2266
2656
|
'*solution': string | null;
|
|
2657
|
+
'*lazyPlugins': LazyPluginEntry[] | null;
|
|
2267
2658
|
};
|
|
2268
2659
|
type CloudImageEditorState = {
|
|
2269
2660
|
'*originalUrl': string | null;
|
|
@@ -2314,7 +2705,9 @@ type EditorToolbarState = {
|
|
|
2314
2705
|
'*currentOperation': string | null;
|
|
2315
2706
|
'*operationTooltip': string | null;
|
|
2316
2707
|
};
|
|
2708
|
+
type SharedContextInstances = Map<string, ISharedInstance>;
|
|
2317
2709
|
type DynamicBlockState = {
|
|
2710
|
+
'*sharedContextInstances': SharedContextInstances;
|
|
2318
2711
|
'*blocksRegistry': BlocksRegistry;
|
|
2319
2712
|
'*eventEmitter': EventEmitter;
|
|
2320
2713
|
'*localeManager': LocaleManager;
|
|
@@ -2322,6 +2715,7 @@ type DynamicBlockState = {
|
|
|
2322
2715
|
'*a11y': A11y;
|
|
2323
2716
|
'*modalManager': ModalManager | null;
|
|
2324
2717
|
'*clipboard': ClipboardLayer;
|
|
2718
|
+
'*pluginManager': PluginManager;
|
|
2325
2719
|
};
|
|
2326
2720
|
type DynamicUploaderBlockState = {
|
|
2327
2721
|
'*uploadCollection': TypedCollection<UploadEntryData>;
|
|
@@ -2332,66 +2726,7 @@ type DynamicUploaderBlockState = {
|
|
|
2332
2726
|
type LocaleState = {
|
|
2333
2727
|
[K in keyof LocaleDefinition as `*l10n/${K}`]: string;
|
|
2334
2728
|
};
|
|
2335
|
-
type SharedState = SolutionBlockCtxState & SharedConfigState & CloudImageEditorState & EditorImageCropperState & EditorToolbarState & DynamicBlockState & DynamicUploaderBlockState & LocaleState;
|
|
2336
|
-
|
|
2337
|
-
interface ISharedInstance {
|
|
2338
|
-
destroy?(): void;
|
|
2339
|
-
}
|
|
2340
|
-
declare class SharedInstance {
|
|
2341
|
-
protected _ctx: PubSub<SharedState>;
|
|
2342
|
-
protected _sharedInstancesBag: SharedInstancesBag;
|
|
2343
|
-
private _subscriptions;
|
|
2344
|
-
private _cfgProxy;
|
|
2345
|
-
protected _debugPrint: (...args: unknown[]) => void;
|
|
2346
|
-
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
2347
|
-
protected addSub(unsub: () => void): void;
|
|
2348
|
-
protected get _cfg(): Readonly<ConfigType>;
|
|
2349
|
-
destroy(): void;
|
|
2350
|
-
}
|
|
2351
|
-
type SharedInstancesState = Pick<SharedState, '*blocksRegistry' | '*eventEmitter' | '*localeManager' | '*telemetryManager' | '*a11y' | '*clipboard' | '*modalManager' | '*uploadCollection' | '*publicApi' | '*validationManager' | '*secureUploadsManager'>;
|
|
2352
|
-
type SharedInstancesBag = ReturnType<typeof createSharedInstancesBag>;
|
|
2353
|
-
declare const createSharedInstancesBag: (getCtx: () => PubSub<SharedState>) => {
|
|
2354
|
-
readonly ctx: PubSub<SharedState>;
|
|
2355
|
-
readonly modalManager: ModalManager | null;
|
|
2356
|
-
readonly telemetryManager: TelemetryManager;
|
|
2357
|
-
readonly localeManager: LocaleManager;
|
|
2358
|
-
readonly a11y: A11y;
|
|
2359
|
-
readonly blocksRegistry: Set<LitBlock>;
|
|
2360
|
-
readonly eventEmitter: EventEmitter;
|
|
2361
|
-
readonly uploadCollection: TypedCollection<UploadEntryData>;
|
|
2362
|
-
readonly secureUploadsManager: SecureUploadsManager;
|
|
2363
|
-
readonly api: UploaderPublicApi;
|
|
2364
|
-
readonly validationManager: ValidationManager;
|
|
2365
|
-
};
|
|
2366
|
-
|
|
2367
|
-
type FuncFileValidator = (outputEntry: OutputFileEntry, api: UploaderPublicApi, options?: {
|
|
2368
|
-
signal?: AbortSignal;
|
|
2369
|
-
}) => undefined | OutputErrorFile | Promise<undefined | OutputErrorFile>;
|
|
2370
|
-
type FileValidatorDescriptor = {
|
|
2371
|
-
runOn: 'add' | 'upload' | 'change';
|
|
2372
|
-
validator: FuncFileValidator;
|
|
2373
|
-
};
|
|
2374
|
-
type FileValidator = FileValidatorDescriptor | FuncFileValidator;
|
|
2375
|
-
type FuncCollectionValidator = (collection: ReturnType<typeof buildOutputCollectionState<OutputCollectionStatus>>, api: UploaderPublicApi) => undefined | OutputErrorCollection;
|
|
2376
|
-
declare class ValidationManager extends SharedInstance {
|
|
2377
|
-
private get _uploadCollection();
|
|
2378
|
-
private _commonFileValidators;
|
|
2379
|
-
private _commonCollectionValidators;
|
|
2380
|
-
private _queue;
|
|
2381
|
-
private _runQueueDebounced;
|
|
2382
|
-
private _isDestroyed;
|
|
2383
|
-
private _entryValidationState;
|
|
2384
|
-
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
2385
|
-
runFileValidators(runOn: FileValidatorDescriptor['runOn'], entryIds?: Uid[]): void;
|
|
2386
|
-
runCollectionValidators(): void;
|
|
2387
|
-
cleanupValidationForEntry(entry: TypedData<UploadEntryData>): void;
|
|
2388
|
-
private _runFileValidatorsForEntry;
|
|
2389
|
-
private _addCustomTypeToValidationError;
|
|
2390
|
-
private _getEntryValidationState;
|
|
2391
|
-
private _getValidatorDescriptors;
|
|
2392
|
-
private _getValidatorDescriptorsForEntry;
|
|
2393
|
-
destroy(): void;
|
|
2394
|
-
}
|
|
2729
|
+
type SharedState = SolutionBlockCtxState & SharedConfigState & SharedCustomConfigState & CloudImageEditorState & EditorImageCropperState & EditorToolbarState & DynamicBlockState & DynamicUploaderBlockState & LocaleState;
|
|
2395
2730
|
|
|
2396
2731
|
declare const LitBlockBase: typeof LitElement & Constructor<{
|
|
2397
2732
|
willYield: boolean;
|
|
@@ -2403,9 +2738,7 @@ declare const LitBlockBase: typeof LitElement & Constructor<{
|
|
|
2403
2738
|
};
|
|
2404
2739
|
declare class LitBlock extends LitBlockBase {
|
|
2405
2740
|
private _cfgProxy;
|
|
2406
|
-
protected _sharedContextInstances: Map<keyof SharedInstancesState, ISharedInstance>;
|
|
2407
2741
|
static styleAttrs: string[];
|
|
2408
|
-
activityType: ActivityType;
|
|
2409
2742
|
init$: {};
|
|
2410
2743
|
constructor();
|
|
2411
2744
|
l10n: (str: string, variables?: Record<string, string | number>) => string;
|
|
@@ -2413,6 +2746,7 @@ declare class LitBlock extends LitBlockBase {
|
|
|
2413
2746
|
protected _sharedInstancesBag: {
|
|
2414
2747
|
readonly ctx: PubSub<SharedState>;
|
|
2415
2748
|
readonly modalManager: ModalManager | null;
|
|
2749
|
+
readonly pluginManager: PluginManager;
|
|
2416
2750
|
readonly telemetryManager: TelemetryManager;
|
|
2417
2751
|
readonly localeManager: LocaleManager;
|
|
2418
2752
|
readonly a11y: A11y;
|
|
@@ -2422,6 +2756,34 @@ declare class LitBlock extends LitBlockBase {
|
|
|
2422
2756
|
readonly secureUploadsManager: SecureUploadsManager;
|
|
2423
2757
|
readonly api: UploaderPublicApi;
|
|
2424
2758
|
readonly validationManager: ValidationManager;
|
|
2759
|
+
when<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "api" | "validationManager">(name: TName, callback: (instance: NonNullable<{
|
|
2760
|
+
modalManager: ModalManager | null;
|
|
2761
|
+
pluginManager: PluginManager;
|
|
2762
|
+
telemetryManager: TelemetryManager;
|
|
2763
|
+
localeManager: LocaleManager;
|
|
2764
|
+
a11y: A11y;
|
|
2765
|
+
clipboard: ClipboardLayer;
|
|
2766
|
+
blocksRegistry: BlocksRegistry;
|
|
2767
|
+
eventEmitter: EventEmitter;
|
|
2768
|
+
uploadCollection: TypedCollection<UploadEntryData>;
|
|
2769
|
+
secureUploadsManager: SecureUploadsManager;
|
|
2770
|
+
api: UploaderPublicApi;
|
|
2771
|
+
validationManager: ValidationManager;
|
|
2772
|
+
}[TName]>) => void): () => void;
|
|
2773
|
+
wait<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "api" | "validationManager">(name: TName): Promise<NonNullable<{
|
|
2774
|
+
modalManager: ModalManager | null;
|
|
2775
|
+
pluginManager: PluginManager;
|
|
2776
|
+
telemetryManager: TelemetryManager;
|
|
2777
|
+
localeManager: LocaleManager;
|
|
2778
|
+
a11y: A11y;
|
|
2779
|
+
clipboard: ClipboardLayer;
|
|
2780
|
+
blocksRegistry: BlocksRegistry;
|
|
2781
|
+
eventEmitter: EventEmitter;
|
|
2782
|
+
uploadCollection: TypedCollection<UploadEntryData>;
|
|
2783
|
+
secureUploadsManager: SecureUploadsManager;
|
|
2784
|
+
api: UploaderPublicApi;
|
|
2785
|
+
validationManager: ValidationManager;
|
|
2786
|
+
}[TName]>>;
|
|
2425
2787
|
};
|
|
2426
2788
|
emit(type: Parameters<EventEmitter['emit']>[0], payload?: Parameters<EventEmitter['emit']>[1], options?: Parameters<EventEmitter['emit']>[2]): void;
|
|
2427
2789
|
hasBlockInCtx(callback: (block: LitBlock) => boolean): boolean;
|
|
@@ -2440,11 +2802,7 @@ declare class LitBlock extends LitBlockBase {
|
|
|
2440
2802
|
* Called when the last block is removed from the context. Note that inheritors must run their callback before that.
|
|
2441
2803
|
*/
|
|
2442
2804
|
private destroyCtxCallback;
|
|
2443
|
-
|
|
2444
|
-
* Adds a shared context instance if it does not exist yet.
|
|
2445
|
-
* @param key The shared state key.
|
|
2446
|
-
* @param resolver The resolver function that creates the instance.
|
|
2447
|
-
*/
|
|
2805
|
+
private _getSharedContextInstances;
|
|
2448
2806
|
protected _addSharedContextInstance<TKey extends keyof SharedInstancesState>(key: TKey, resolver: (sharedInstancesBag: SharedInstancesBag) => NonNullable<SharedInstancesState[TKey]>): void;
|
|
2449
2807
|
private _destroySharedContextInstances;
|
|
2450
2808
|
protected _getSharedContextInstance<TKey extends keyof SharedState, TRequired extends boolean = true>(key: TKey, isRequired?: TRequired): TRequired extends true ? NonNullable<SharedState[TKey]> : SharedState[TKey];
|
|
@@ -2471,7 +2829,7 @@ declare class Modal extends LitBlock {
|
|
|
2471
2829
|
private _handleDialogClose;
|
|
2472
2830
|
private _handleDialogMouseDown;
|
|
2473
2831
|
private _handleDialogMouseUp;
|
|
2474
|
-
show(): void
|
|
2832
|
+
show(): Promise<void>;
|
|
2475
2833
|
hide(): void;
|
|
2476
2834
|
private _handleModalOpen;
|
|
2477
2835
|
private _handleModalClose;
|
|
@@ -2543,8 +2901,10 @@ declare const toKebabCase: <T extends string>(str: T) => KebabCase<T>;
|
|
|
2543
2901
|
|
|
2544
2902
|
declare class LitSolutionBlock extends LitBlock {
|
|
2545
2903
|
static styleAttrs: string[];
|
|
2904
|
+
static lazyPlugins: LazyPluginEntry[] | null;
|
|
2546
2905
|
init$: {
|
|
2547
2906
|
'*solution': string | null;
|
|
2907
|
+
'*lazyPlugins': LazyPluginEntry[] | null;
|
|
2548
2908
|
'*commonProgress': number;
|
|
2549
2909
|
'*uploadList': never[];
|
|
2550
2910
|
'*uploadQueue': _uploadcare_upload_client.Queue;
|
|
@@ -2676,18 +3036,20 @@ declare global {
|
|
|
2676
3036
|
}
|
|
2677
3037
|
}
|
|
2678
3038
|
|
|
3039
|
+
type SourceButtonConfig = {
|
|
3040
|
+
id: string;
|
|
3041
|
+
label: string;
|
|
3042
|
+
icon?: string;
|
|
3043
|
+
onClick: () => void | Promise<void>;
|
|
3044
|
+
};
|
|
2679
3045
|
declare class SourceBtn extends LitUploaderBlock {
|
|
2680
3046
|
couldBeCtxOwner: boolean;
|
|
2681
|
-
|
|
2682
|
-
type?: string;
|
|
3047
|
+
source?: SourceButtonConfig;
|
|
2683
3048
|
private _iconName;
|
|
2684
3049
|
private _srcTypeKey;
|
|
2685
|
-
private _initTypes;
|
|
2686
|
-
initCallback(): void;
|
|
2687
|
-
private _registerType;
|
|
2688
|
-
activate(): void;
|
|
2689
|
-
private _applyType;
|
|
2690
3050
|
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
3051
|
+
private _applySource;
|
|
3052
|
+
activate(): void;
|
|
2691
3053
|
render(): lit_html.TemplateResult<1>;
|
|
2692
3054
|
}
|
|
2693
3055
|
declare global {
|
|
@@ -2696,9 +3058,10 @@ declare global {
|
|
|
2696
3058
|
}
|
|
2697
3059
|
}
|
|
2698
3060
|
|
|
2699
|
-
declare class SourceList extends
|
|
3061
|
+
declare class SourceList extends LitUploaderBlock {
|
|
2700
3062
|
private _rawSourceList;
|
|
2701
|
-
private
|
|
3063
|
+
private _unsubscribePlugins?;
|
|
3064
|
+
private _sources;
|
|
2702
3065
|
/**
|
|
2703
3066
|
* CSS-only attribute
|
|
2704
3067
|
*/
|
|
@@ -2706,8 +3069,10 @@ declare class SourceList extends LitBlock {
|
|
|
2706
3069
|
initCallback(): void;
|
|
2707
3070
|
protected updated(changedProperties: PropertyValues<this>): void;
|
|
2708
3071
|
private _updateSources;
|
|
2709
|
-
private
|
|
3072
|
+
private _expandSource;
|
|
3073
|
+
private _makePluginSourceConfig;
|
|
2710
3074
|
render(): lit_html.TemplateResult<1>;
|
|
3075
|
+
disconnectedCallback(): void;
|
|
2711
3076
|
}
|
|
2712
3077
|
declare global {
|
|
2713
3078
|
interface HTMLElementTagNameMap {
|
|
@@ -2771,38 +3136,65 @@ declare global {
|
|
|
2771
3136
|
}
|
|
2772
3137
|
}
|
|
2773
3138
|
|
|
2774
|
-
declare class
|
|
3139
|
+
declare class SimpleBtn extends LitUploaderBlock {
|
|
3140
|
+
static styleAttrs: string[];
|
|
2775
3141
|
couldBeCtxOwner: boolean;
|
|
2776
|
-
|
|
2777
|
-
private
|
|
3142
|
+
dropzone: boolean;
|
|
3143
|
+
private _buttonTextKey;
|
|
3144
|
+
private readonly _handleClick;
|
|
2778
3145
|
initCallback(): void;
|
|
2779
|
-
private _inputRef;
|
|
2780
|
-
private _handleInput;
|
|
2781
|
-
private _handleUpload;
|
|
2782
3146
|
render(): lit_html.TemplateResult<1>;
|
|
2783
3147
|
}
|
|
2784
3148
|
declare global {
|
|
2785
3149
|
interface HTMLElementTagNameMap {
|
|
2786
|
-
'uc-
|
|
3150
|
+
'uc-simple-btn': SimpleBtn;
|
|
2787
3151
|
}
|
|
2788
3152
|
}
|
|
2789
3153
|
|
|
2790
|
-
declare class
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
3154
|
+
declare class PluginActivityHost extends LitActivityBlock {
|
|
3155
|
+
registration: Owned<PluginActivityRegistration>;
|
|
3156
|
+
private _dispose?;
|
|
3157
|
+
private _containerRef;
|
|
3158
|
+
initCallback(): void;
|
|
3159
|
+
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
3160
|
+
private _ensureRegistered;
|
|
3161
|
+
private _renderActivity;
|
|
3162
|
+
private _disposeActivity;
|
|
3163
|
+
disconnectedCallback(): void;
|
|
3164
|
+
render(): lit_html.TemplateResult<1>;
|
|
3165
|
+
}
|
|
3166
|
+
declare class PluginActivityRenderer extends LitBlock {
|
|
3167
|
+
mode: 'modal' | 'inline';
|
|
3168
|
+
private _activities;
|
|
3169
|
+
private _unsubscribePlugins?;
|
|
2796
3170
|
initCallback(): void;
|
|
3171
|
+
private _syncActivities;
|
|
3172
|
+
disconnectedCallback(): void;
|
|
2797
3173
|
render(): lit_html.TemplateResult<1>;
|
|
2798
3174
|
}
|
|
2799
3175
|
declare global {
|
|
2800
3176
|
interface HTMLElementTagNameMap {
|
|
2801
|
-
'uc-
|
|
3177
|
+
'uc-plugin-activity-host': PluginActivityHost;
|
|
3178
|
+
'uc-plugin-activity-renderer': PluginActivityRenderer;
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
declare class UrlSource extends LitUploaderBlock {
|
|
3183
|
+
private _formState;
|
|
3184
|
+
private _inputRef;
|
|
3185
|
+
private _handleInput;
|
|
3186
|
+
private _handleUpload;
|
|
3187
|
+
firstUpdated(): void;
|
|
3188
|
+
render(): lit_html.TemplateResult<1>;
|
|
3189
|
+
}
|
|
3190
|
+
declare global {
|
|
3191
|
+
interface HTMLElementTagNameMap {
|
|
3192
|
+
'uc-url-source': UrlSource;
|
|
2802
3193
|
}
|
|
2803
3194
|
}
|
|
2804
3195
|
|
|
2805
3196
|
declare class FileUploaderRegular extends LitSolutionBlock {
|
|
3197
|
+
static lazyPlugins: LazyPluginEntry[];
|
|
2806
3198
|
attributesMeta: {
|
|
2807
3199
|
headless?: boolean;
|
|
2808
3200
|
'ctx-name': string;
|
|
@@ -2820,6 +3212,7 @@ declare global {
|
|
|
2820
3212
|
}
|
|
2821
3213
|
|
|
2822
3214
|
declare class FileUploaderInline extends LitSolutionBlock {
|
|
3215
|
+
static lazyPlugins: LazyPluginEntry[];
|
|
2823
3216
|
attributesMeta: {
|
|
2824
3217
|
'ctx-name': string;
|
|
2825
3218
|
};
|
|
@@ -2840,6 +3233,7 @@ declare global {
|
|
|
2840
3233
|
}
|
|
2841
3234
|
|
|
2842
3235
|
declare class FileUploaderMinimal extends LitSolutionBlock {
|
|
3236
|
+
static lazyPlugins: LazyPluginEntry[];
|
|
2843
3237
|
attributesMeta: {
|
|
2844
3238
|
'ctx-name': string;
|
|
2845
3239
|
};
|
|
@@ -2866,4 +3260,4 @@ declare global {
|
|
|
2866
3260
|
declare const PACKAGE_NAME = "blocks";
|
|
2867
3261
|
declare const PACKAGE_VERSION: string;
|
|
2868
3262
|
|
|
2869
|
-
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 };
|
|
3263
|
+
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, 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 PluginFileActionRegistration, type PluginFileEntryUpdate, type PluginFileHookContext, type PluginFileHookRegistration, type PluginFileHookResult, type PluginFilesApi, type PluginI18nRegistration, type PluginIconRegistration, type PluginRegistryApi, type PluginRegistrySnapshot, type PluginRender, type PluginRenderDispose, type PluginSetupParams, type PluginSetupResult, type PluginSourceRegistration, type PluginUploaderApi, 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 };
|