@uploadcare/file-uploader
Version:
Building blocks for Uploadcare products integration
1,494 lines (1,438 loc) • 90.2 kB
TypeScript
import { LitElement, PropertyValues, TemplateResult, nothing } from 'lit';
export { loadFileUploaderFrom } from './abstract/loadFileUploaderFrom.js';
import _default from './locales/file-uploader/en.js';
import * as lit_html from 'lit-html';
import * as lit_html_directives_ref_js from 'lit-html/directives/ref.js';
import * as _uploadcare_upload_client from '@uploadcare/upload-client';
import { UploadcareFile, Metadata, FileFromOptions, UploadError, NetworkError, UploadcareGroup, Queue } from '@uploadcare/upload-client';
export { Metadata, NetworkError, UploadError, UploadcareError, UploadcareFile, UploadcareGroup } from '@uploadcare/upload-client';
import { Ref } from 'lit/directives/ref.js';
import { TelemetryRequest } from '@uploadcare/quality-insights';
export { PACKAGE_NAME, PACKAGE_VERSION } from './env.js';
type Unsubscriber = () => void;
declare class PubSub<T extends Record<string, unknown>> {
private static _contexts;
private _store;
private _ctxId;
private constructor();
get id(): string;
pub<K extends keyof T>(key: K, value: T[K]): void;
sub<K extends keyof T>(key: K, callback: (value: T[K]) => void, init?: boolean): Unsubscriber;
read<K extends keyof T>(key: K): T[K];
add<K extends keyof T>(key: K, value: T[K], rewrite?: boolean): void;
has(key: keyof T): boolean;
get store(): T;
static registerCtx<T extends Record<string, unknown>>(initialValue: T, ctxId: string): PubSub<T>;
static deleteCtx(ctxId: string): void;
static getCtx<T extends Record<string, unknown> = Record<string, unknown>>(ctxId: string): PubSub<T> | null;
static hasCtx(ctxId: string): boolean;
}
type Constructor<T = unknown> = new (...args: any[]) => T;
type SymbioteStateBag<T extends Record<string, unknown>> = T;
/**
* Interface for components using SymbioteMixin
*/
declare class SymbioteComponent<TState extends Record<string, unknown> = Record<string, unknown>> {
$: SymbioteStateBag<TState>;
sub<TKey extends keyof TState>(key: TKey, callback: (value: TState[TKey]) => void, init?: boolean): () => void;
pub<TKey extends keyof TState>(key: TKey, value: TState[TKey]): void;
set$<T extends {
[K in keyof T]: K extends keyof TState ? TState[K] : never;
}>(obj: T): void;
has<TKey extends keyof TState>(key: TKey): boolean;
add<TKey extends keyof TState>(key: TKey, val: TState[TKey], rewrite?: boolean): void;
add$<T extends {
[K in keyof T]: K extends keyof TState ? TState[K] : never;
}>(obj: T, rewrite?: boolean): void;
initCallback(): void;
sharedCtx: PubSub<TState>;
ctxName: string;
ctxOwner: boolean;
}
declare const BaseComponent_base: typeof LitElement & Constructor<{
willYield: boolean;
yield(slot: string, defaultContent?: unknown): unknown;
}> & Constructor<{
getCssData(propName: string, silentCheck?: boolean): string | number | boolean | null | undefined;
}> & Constructor<SymbioteComponent<Record<string, unknown>>> & Constructor<LitElement> & {
reg(tagName: string): void;
};
declare class BaseComponent extends BaseComponent_base {
}
type Uid = string & {
__uid: true;
};
declare class UID {
static generateFastUid(): Uid;
static generateRandomUUID(): string;
}
declare function defineComponents(blockExports: Record<string, any>): void;
type LocaleDefinition = typeof _default;
type LocaleDefinitionResolver = () => Promise<LocaleDefinition>;
declare const defineLocale: (localeName: string, definitionOrResolver: LocaleDefinition | LocaleDefinitionResolver) => void;
declare class A11y implements ISharedInstance {
private _destroyKeyUX;
private readonly _scopedWindow;
constructor();
registerBlock(scope: LitBlock): void;
destroy(): void;
}
declare class LocaleManager extends SharedInstance {
private _localeName;
constructor(sharedInstancesBag: SharedInstancesBag);
}
declare class TypedData<T extends Record<string, unknown>> {
private _ctxId;
private _data;
constructor(initialValue: T);
get uid(): Uid;
setValue<K extends keyof T>(prop: K, value: T[K]): void;
setMultipleValues(updObj: Partial<T>): void;
getValue<K extends keyof T>(prop: K): T[K];
subscribe<K extends keyof T>(prop: K, handler: (newVal: T[K]) => void): Unsubscriber;
destroy(): void;
}
type ChangeMap<T extends Record<string, unknown>> = Record<keyof T, Set<Uid>>;
type TypedCollectionPropertyObserver<T extends Record<string, unknown>> = (changeMap: ChangeMap<T>) => void;
type TypedCollectionObserverHandler<T extends Record<string, unknown>> = (list: Uid[], added: Set<TypedData<T>>, removed: Set<TypedData<T>>) => void;
type TypedCollectionOptions<T extends Record<string, unknown>> = {
initialValue: T;
watchList?: (keyof T)[];
handler?: TypedCollectionObserverHandler<T>;
};
declare class TypedCollection<T extends Record<string, unknown>> {
private static readonly _destroyDelayMs;
private _ctxId;
private _data;
private _watchList;
private _subsMap;
private _propertyObservers;
private _collectionObservers;
private _items;
private _removed;
private _added;
private _markedToDestroy;
private _observeTimeout?;
private _notifyTimeout?;
private _destroyTimeout?;
private _notifyObservers;
private _initialValue;
constructor(options: TypedCollectionOptions<T>);
private _notify;
private _scheduleDestroyMarkedItems;
observeCollection(handler: TypedCollectionObserverHandler<T>): () => void;
unobserveCollection(handler: TypedCollectionObserverHandler<T>): void;
add(init: Partial<T>): Uid;
hasItem(id: Uid): boolean;
read(id: Uid): TypedData<T> | null;
readProp<K extends keyof T>(id: Uid, propName: K): T[K];
publishProp<K extends keyof T>(id: Uid, propName: K, value: T[K]): void;
remove(id: Uid): void;
clearAll(): void;
observeProperties(handler: TypedCollectionPropertyObserver<T>): () => void;
unobserveProperties(handler: TypedCollectionPropertyObserver<T>): void;
findItems(checkFn: (item: TypedData<T>) => boolean): Uid[];
items(): Uid[];
get size(): number;
destroy(): void;
}
declare const CameraSourceTypes: Readonly<{
PHOTO: "photo";
VIDEO: "video";
}>;
type ModeCameraType = (typeof CameraSourceTypes)[keyof typeof CameraSourceTypes];
declare function buildOutputCollectionState<TCollectionStatus extends OutputCollectionStatus, TGroupFlag extends GroupFlag = 'maybe-has-group'>(bag: SharedInstancesBag): OutputCollectionState<TCollectionStatus, TGroupFlag>;
interface UploadEntryData extends Record<string, unknown> {
file: File | null;
externalUrl: string | null;
fileName: string | null;
fileSize: number | null;
lastModified: number;
uploadProgress: number;
uuid: string | null;
isImage: boolean;
mimeType: string | null;
ctxName: string | null;
cdnUrl: string | null;
cdnUrlModifiers: string | null;
fileInfo: UploadcareFile | null;
isUploading: boolean;
abortController: AbortController | null;
thumbUrl: string | null;
silent: boolean;
source: string | null;
fullPath: string | null;
metadata: Metadata | null;
errors: OutputErrorFile[];
uploadError: Error | null;
isRemoved: boolean;
isQueuedForUploading: boolean;
isValidationPending: boolean;
isQueuedForValidation: boolean;
}
type UploadEntryTypedData = TypedData<UploadEntryData>;
type UploadEntryKeys = keyof UploadEntryData;
type ApiAddFileCommonOptions = {
silent?: boolean;
fileName?: string;
source?: string;
};
declare class UploaderPublicApi extends SharedInstance {
private _l10n;
get _uploadCollection(): TypedCollection<UploadEntryData>;
get cfg(): Readonly<ConfigType>;
get l10n(): (str: string, variables?: Record<string, string | number>) => string;
/**
* TODO: Probably we should not allow user to override `source` property
*/
addFileFromUrl: (url: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
addFileFromUuid: (uuid: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
addFileFromCdnUrl: (cdnUrl: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
addFileFromObject: (file: File, { silent, fileName, source, fullPath, }?: ApiAddFileCommonOptions & {
fullPath?: string;
}) => OutputFileEntry<"idle">;
removeFileByInternalId: (internalId: string) => void;
removeAllFiles(): void;
uploadAll: () => void;
openSystemDialog: (options?: {
captureCamera?: boolean;
modeCamera?: ModeCameraType;
}) => void;
getOutputItem<TStatus extends OutputFileStatus>(entryId: string): OutputFileEntry<TStatus>;
getOutputCollectionState<TStatus extends OutputCollectionStatus>(): ReturnType<typeof buildOutputCollectionState<TStatus>>;
initFlow: (force?: boolean) => void;
doneFlow: () => void;
setCurrentActivity: <T extends RegisteredActivityType>(activityType: T, ...params: T extends keyof ActivityParamsMap ? [ActivityParamsMap[T]] : T extends RegisteredActivityType ? [undefined?] : [never]) => void;
getCurrentActivity: () => ActivityType;
setModalState: (opened: boolean) => void;
private get _sourceList();
}
declare const ExternalUploadSource: Readonly<{
readonly FACEBOOK: "facebook";
readonly DROPBOX: "dropbox";
readonly DROPBOX_CHOOSER: "dropboxchooser";
readonly GDRIVE: "gdrive";
readonly GPHOTOS: "gphotos";
readonly FLICKR: "flickr";
readonly VK: "vk";
readonly EVERNOTE: "evernote";
readonly BOX: "box";
readonly ONEDRIVE: "onedrive";
readonly HUDDLE: "huddle";
}>;
declare const UploadSource: Readonly<{
readonly FACEBOOK: "facebook";
readonly DROPBOX: "dropbox";
readonly DROPBOX_CHOOSER: "dropboxchooser";
readonly GDRIVE: "gdrive";
readonly GPHOTOS: "gphotos";
readonly FLICKR: "flickr";
readonly VK: "vk";
readonly EVERNOTE: "evernote";
readonly BOX: "box";
readonly ONEDRIVE: "onedrive";
readonly HUDDLE: "huddle";
readonly MOBILE_VIDEO_CAMERA: "mobile-video-camera";
readonly MOBILE_PHOTO_CAMERA: "mobile-photo-camera";
readonly LOCAL: "local";
readonly DROP_AREA: "drop-area";
readonly CAMERA: "camera";
readonly EXTERNAL: "external";
readonly API: "js-api";
readonly URL: "url";
readonly DRAW: "draw";
}>;
type SourceTypes = (typeof UploadSource)[keyof typeof UploadSource];
declare class LitUploaderBlock extends LitActivityBlock {
static extSrcList: Readonly<typeof ExternalUploadSource>;
static sourceTypes: Readonly<typeof UploadSource>;
protected couldBeCtxOwner: boolean;
private _isCtxOwner;
private _unobserveCollection?;
private _unobserveCollectionProperties?;
init$: {
'*commonProgress': number;
'*uploadList': never[];
'*uploadQueue': _uploadcare_upload_client.Queue;
'*collectionErrors': OutputErrorCollection[];
'*collectionState': OutputCollectionState | null;
'*groupInfo': _uploadcare_upload_client.UploadcareGroup | null;
'*uploadTrigger': Set<string>;
'*currentActivity': null;
'*currentActivityParams': {};
'*history': never[];
'*historyBack': null;
'*closeModal': () => void;
};
private get _hasCtxOwner();
initCallback(): void;
getAPI(): UploaderPublicApi;
get validationManager(): ValidationManager;
get api(): UploaderPublicApi;
get uploadCollection(): TypedCollection<UploadEntryData>;
get secureUploadsManager(): SecureUploadsManager;
disconnectedCallback(): void;
connectedCallback(): void;
private _initCtxOwner;
private _observeUploadCollection;
private _unobserveUploadCollection;
private _createGroup;
private _flushOutputItems;
private _handleCollectionUpdate;
private _handleCollectionPropertiesUpdate;
private _flushCommonUploadProgress;
private _openCloudImageEditor;
private _setInitialCrop;
protected getMetadataFor(entryId: string): Promise<_uploadcare_upload_client.Metadata | undefined>;
protected getUploadClientOptions(): Promise<FileFromOptions>;
getOutputData(): OutputFileEntry[];
}
/**
* Mapping of loading resources per operation
*/
type LoadingOperations = Map<string, Map<string, boolean>>;
/**
* Image size
*/
interface ImageSize {
width: number;
height: number;
}
interface Transformations {
enhance?: number;
brightness?: number;
exposure?: number;
gamma?: number;
contrast?: number;
saturation?: number;
vibrance?: number;
warmth?: number;
rotate?: number;
mirror?: boolean;
flip?: boolean;
filter?: {
name: string;
amount: number;
};
crop?: {
dimensions: [number, number];
coords: [number, number];
};
}
interface ApplyResult {
originalUrl: string;
cdnUrlModifiers: string;
cdnUrl: string;
transformations: Transformations;
}
type ChangeResult = ApplyResult;
interface CropAspectRatio {
type: 'aspect-ratio';
width: number;
height: number;
id: string;
hasFreeform?: boolean;
}
type CropPresetList = CropAspectRatio[];
declare function initState(fnCtx: CloudImageEditorBlock): {
'*originalUrl': null;
'*loadingOperations': LoadingOperations;
'*faderEl': null;
'*cropperEl': null;
'*imgEl': null;
'*imgContainerEl': null;
'*networkProblems': boolean;
'*imageSize': null;
'*editorTransformations': {};
'*cropPresetList': never[];
'*currentAspectRatio': null;
'*tabList': readonly ["crop", "tuning", "filters"];
'*tabId': "crop";
'*on.retryNetwork': () => void;
'*on.apply': (transformations: Transformations) => void;
'*on.cancel': () => void;
};
type PresenceToggleStyle = {
transition?: string;
visible?: string;
hidden?: string;
};
declare class PresenceToggle extends LitBlock {
private _visible;
private _styles;
private _visibleStyle;
private _hiddenStyle;
private _externalTransitions;
private _initialRenderComplete;
set visible(value: boolean);
get visible(): boolean;
set styles(styles: PresenceToggleStyle);
get styles(): PresenceToggleStyle;
private _handleVisible;
private _dispatchInitialRenderEvent;
initCallback(): void;
}
declare global {
interface HTMLElementTagNameMap {
'uc-presence-toggle': PresenceToggle;
}
}
declare class LineLoaderUi extends LitBlock {
active: boolean;
private readonly _lineRef;
private _isAnimating;
private readonly _handleTransitionEndRight;
protected firstUpdated(changedProperties: PropertyValues<this>): void;
protected updated(changedProperties: PropertyValues<this>): void;
private _start;
private _stop;
private _resetLine;
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-line-loader-ui': LineLoaderUi;
}
}
declare class Icon extends LitBlock {
name: string;
private _resolvedHref;
private _iconHrefResolver;
initCallback(): void;
protected willUpdate(changedProperties: PropertyValues<this>): void;
private _updateResolvedHref;
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-icon': Icon;
}
}
type AriaRole = 'alert' | 'alertdialog' | 'button' | 'checkbox' | 'dialog' | 'gridcell' | 'link' | 'log' | 'marquee' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'option' | 'progressbar' | 'radio' | 'scrollbar' | 'searchbox' | 'slider' | 'spinbutton' | 'status' | 'switch' | 'tab' | 'tabpanel' | 'textbox' | 'timer' | 'tooltip' | 'treeitem' | 'combobox' | 'grid' | 'listbox' | 'menu' | 'menubar' | 'radiogroup' | 'tablist' | 'tree' | 'treegrid' | 'application' | 'article' | 'cell' | 'columnheader' | 'definition' | 'directory' | 'document' | 'feed' | 'figure' | 'group' | 'heading' | 'img' | 'list' | 'listitem' | 'math' | 'none' | 'note' | 'presentation' | 'region' | 'row' | 'rowgroup' | 'rowheader' | 'separator' | 'table' | 'term' | 'text' | 'toolbar' | 'banner' | 'complementary' | 'contentinfo' | 'form' | 'main' | 'navigation' | 'region' | 'search' | 'doc-abstract' | 'doc-acknowledgments' | 'doc-afterword' | 'doc-appendix' | 'doc-backlink' | 'doc-biblioentry' | 'doc-bibliography' | 'doc-biblioref' | 'doc-chapter' | 'doc-colophon' | 'doc-conclusion' | 'doc-cover' | 'doc-credit' | 'doc-credits' | 'doc-dedication' | 'doc-endnote' | 'doc-endnotes' | 'doc-epigraph' | 'doc-epilogue' | 'doc-errata' | 'doc-example' | 'doc-footnote' | 'doc-foreword' | 'doc-glossary' | 'doc-glossref' | 'doc-index' | 'doc-introduction' | 'doc-noteref' | 'doc-notice' | 'doc-pagebreak' | 'doc-pagelist' | 'doc-part' | 'doc-preface' | 'doc-prologue' | 'doc-pullquote' | 'doc-qna' | 'doc-subtitle' | 'doc-tip' | 'doc-toc';
type Theme = string | null;
declare class BtnUi extends LitBlock {
text: string;
icon: string;
reverse: boolean;
theme: Theme;
ariaRole: AriaRole | undefined;
ariaControls: string;
titleProp: string;
/**
* CSS-only attribute
*/
active: boolean;
protected firstUpdated(changed: PropertyValues<this>): void;
protected updated(changed: PropertyValues<this>): void;
private _applyReverse;
private _applyThemeClass;
private get _iconClassMap();
private get _computedIconHidden();
private get _computedIconSingle();
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-btn-ui': BtnUi;
}
}
declare class CropFrame extends LitBlock {
private _backdropMask?;
private _backdropMaskInner?;
private readonly _backdropMaskId;
private _frameThumbs?;
private _frameGuides?;
private _draggingThumb?;
private _hoverThumb?;
private _dragStartPoint?;
private _dragStartCrop?;
private _frameImage?;
private _guidesHidden;
private _draggingValue;
private readonly _svgRef;
private _svgReady;
private _pendingMaskHref;
private get _svgElement();
private get _dragging();
private set _dragging(value);
private _applyGuidesDragState;
private _shouldThumbBeDisabled;
private _createBackdrop;
/**
* @private Super Tricky workaround for the chromium bug See
* https://bugs.chromium.org/p/chromium/issues/detail?id=330815
*/
private _resizeBackdrop;
private _updateBackdrop;
private _updateFrame;
private _createThumb;
private _createThumbs;
private _createGuides;
private _createFrame;
private _handlePointerDown;
private readonly _handlePointerUp;
private readonly _handlePointerMove;
private _calcCropBox;
private readonly _handleSvgPointerMove;
private _updateCursor;
private _createMask;
private _updateMask;
private _render;
toggleThumbs(visible: boolean): void;
initCallback(): void;
protected firstUpdated(changedProperties: PropertyValues<this>): void;
private _initializeSvg;
disconnectedCallback(): void;
render(): TemplateResult;
}
declare global {
interface HTMLElementTagNameMap {
'uc-crop-frame': CropFrame;
}
}
type Operations = {
flip: boolean;
mirror: boolean;
rotate: number;
};
declare class EditorImageCropper extends LitBlock {
ctxOwner: boolean;
private _commitDebounced;
private _handleResizeThrottled;
private _imageSize;
private _canvas?;
private _ctx;
private _isActive;
private _observer?;
private _image;
private _cancelPreload?;
private readonly _canvasRef;
private readonly _frameRef;
constructor();
protected firstUpdated(changedProperties: PropertyValues<this>): void;
private _syncTransformations;
private _initCanvas;
private _alignImage;
private _alignCrop;
private _drawImage;
private _draw;
private _animateIn;
private _getCropDimensions;
private _getCropTransformation;
private _commit;
setValue<K extends keyof Operations>(operation: K, value: Operations[K]): void;
getValue<K extends keyof Operations>(operation: K): Operations[K];
activate(imageSize: ImageSize, { fromViewer }?: {
fromViewer?: boolean;
}): Promise<void>;
deactivate({ reset }?: {
reset?: boolean;
}): void;
private _transitionToCrop;
private _transitionToImage;
private _reset;
private _waitForImage;
private _handleImageLoading;
initCallback(): void;
disconnectedCallback(): void;
render(): TemplateResult;
}
declare global {
interface HTMLElementTagNameMap {
'uc-editor-image-cropper': EditorImageCropper;
}
}
declare const TabId: Readonly<{
readonly CROP: "crop";
readonly TUNING: "tuning";
readonly FILTERS: "filters";
}>;
type TabIdValue$1 = (typeof TabId)[keyof typeof TabId];
declare const ALL_COLOR_OPERATIONS: readonly ["brightness", "exposure", "gamma", "contrast", "saturation", "vibrance", "warmth", "enhance"];
type ColorOperation = (typeof ALL_COLOR_OPERATIONS)[number];
declare const ALL_FILTERS: readonly ["adaris", "briaril", "calarel", "carris", "cynarel", "cyren", "elmet", "elonni", "enzana", "erydark", "fenralan", "ferand", "galen", "gavin", "gethriel", "iorill", "iothari", "iselva", "jadis", "lavra", "misiara", "namala", "nerion", "nethari", "pamaya", "sarnar", "sedis", "sewen", "sorahel", "sorlen", "tarian", "thellassan", "varriel", "varven", "vevera", "virkas", "yedis", "yllara", "zatvel", "zevcen"];
type FilterId = (typeof ALL_FILTERS)[number];
declare const ALL_CROP_OPERATIONS: readonly ["rotate", "mirror", "flip"];
type CropOperation = (typeof ALL_CROP_OPERATIONS)[number];
/** KeypointsNumber is the number of keypoints loaded from each side of zero, not total number */
declare const COLOR_OPERATIONS_CONFIG: Readonly<{
brightness: {
zero: number;
range: readonly [-100, 100];
keypointsNumber: number;
};
exposure: {
zero: number;
range: readonly [-500, 500];
keypointsNumber: number;
};
gamma: {
zero: number;
range: readonly [0, 1000];
keypointsNumber: number;
};
contrast: {
zero: number;
range: readonly [-100, 500];
keypointsNumber: number;
};
saturation: {
zero: number;
range: readonly [-100, 500];
keypointsNumber: number;
};
vibrance: {
zero: number;
range: readonly [-100, 500];
keypointsNumber: number;
};
warmth: {
zero: number;
range: readonly [-100, 100];
keypointsNumber: number;
};
enhance: {
zero: number;
range: readonly [0, 100];
keypointsNumber: number;
};
filter: {
zero: number;
range: readonly [0, 100];
keypointsNumber: number;
};
}>;
type OperationKey = keyof typeof COLOR_OPERATIONS_CONFIG;
declare class EditorImageFader extends LitBlock {
private _isActive;
private _hidden;
private _operation;
private _filter;
private _value?;
private _transformations;
private _keypoints;
private _previewImage?;
private _cancelLastImages?;
private _cancelBatchPreload?;
private _url?;
private _fromViewer?;
private _raf;
private _addKeypointDebounced;
private readonly _previewHostRef;
private readonly _layersHostRef;
constructor();
private _handleImageLoading;
private _flush;
private _imageSrc;
private _constructKeypoint;
/**
* Check if current operation and filter equals passed ones
*/
private _isSame;
set(value: string | number): void;
private _update;
private _createPreviewImage;
private _initNodes;
setTransformations(transformations: Transformations): Promise<void>;
preload({ url, filter, operation, value, }: {
url: string;
filter?: string;
operation?: OperationKey;
value?: number;
}): Promise<void>;
private _setOriginalSrc;
activate({ url, operation, value, filter, fromViewer, }: {
url: string;
operation?: OperationKey;
value?: number;
filter?: string;
fromViewer?: boolean;
}): Promise<void>;
deactivate({ hide }?: {
hide?: boolean;
}): void;
private _ensurePreviewAttached;
private _clearLayersHost;
render(): TemplateResult;
}
declare global {
interface HTMLElementTagNameMap {
'uc-editor-image-fader': EditorImageFader;
}
}
declare class EditorButtonControl extends LitBlock {
active: boolean;
title: string;
protected icon: string;
protected titleProp: string;
protected get buttonClasses(): Record<string, boolean>;
private _updateHostStateClasses;
protected onClick(_event: MouseEvent): void;
connectedCallback(): void;
protected updated(changedProperties: PropertyValues<this>): void;
render(): lit_html.TemplateResult<1>;
}
declare class EditorFreeformButtonControl extends EditorButtonControl {
initCallback(): void;
onClick(): void;
private _computeTitle;
render(): lit_html.TemplateResult<1>;
}
declare class EditorAspectRatioButtonControl extends EditorButtonControl {
private _aspectRatio;
get aspectRatio(): CropAspectRatio | null;
set aspectRatio(value: CropAspectRatio | null);
initCallback(): void;
protected onClick(): void;
private _updateAspectRatioPresentation;
private _renderIcon;
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-editor-freeform-button-control': EditorFreeformButtonControl;
'uc-editor-aspect-ratio-button-control': EditorAspectRatioButtonControl;
}
}
declare class EditorCropButtonControl extends EditorButtonControl {
operation: CropOperation | undefined;
protected willUpdate(changedProperties: PropertyValues<this>): void;
protected onClick(e: MouseEvent): void;
}
declare global {
interface HTMLElementTagNameMap {
'uc-editor-crop-button-control': EditorCropButtonControl;
}
}
declare class EditorFilterControl extends EditorButtonControl {
private _operation;
private _filter;
private _originalUrl;
private _observer?;
private _cancelPreload?;
private _lastPreviewRequestId;
private _previewVisibilityCheckRaf?;
private _previewVisibilityCheckTimeout?;
private _previewImage;
private _previewLoaded;
isOriginal: boolean;
private _iconSize;
get filter(): string;
set filter(value: string);
onClick(e: MouseEvent): void;
private _previewSrc;
private _observerCallback;
initCallback(): void;
disconnectedCallback(): void;
protected updated(changedProperties: PropertyValues<this>): void;
private _updateFilterLabels;
private _loadPreview;
private _schedulePreviewVisibilityCheck;
private _clearPreviewVisibilityChecks;
private get _shouldShowPreview();
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-editor-filter-control': EditorFilterControl;
}
}
declare class EditorOperationControl extends EditorButtonControl {
private _operation;
get operation(): ColorOperation | '';
set operation(value: ColorOperation | '');
private _updateOperationMetadata;
initCallback(): void;
protected onClick(e: MouseEvent): void;
}
declare global {
interface HTMLElementTagNameMap {
'uc-editor-operation-control': EditorOperationControl;
}
}
declare class EditorScroller extends LitBlock {
/**
* CSS-only attribute
*/
hiddenScrollbar: boolean;
private readonly _handleWheel;
connectedCallback(): void;
disconnectedCallback(): void;
}
declare global {
interface HTMLElementTagNameMap {
'uc-editor-scroller': EditorScroller;
}
}
declare class SliderUi extends LitBlock {
private _observer?;
private _thumbSize;
private _zeroDotEl?;
private _stepsCount?;
private readonly _inputRef;
private readonly _thumbRef;
private readonly _stepsRef;
disabled: boolean;
min: number;
max: number;
defaultValue: number;
zero: number;
private _currentValue;
constructor();
private _emitSliderEvent;
private readonly _handleSliderInput;
private readonly _handleSliderChange;
private readonly _handleInputFocus;
private readonly _handleInputBlur;
protected firstUpdated(changedProperties: PropertyValues<this>): void;
protected willUpdate(changedProperties: PropertyValues<this>): void;
private _updateValue;
private _updateZeroDot;
private _updateSteps;
disconnectedCallback(): void;
private _setCurrentValue;
private _syncInputValue;
private _extractEventValue;
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-slider-ui': SliderUi;
}
}
type SliderOperation = ColorOperation | 'filter';
type SliderFilter = FilterId | typeof FAKE_ORIGINAL_FILTER;
declare const FAKE_ORIGINAL_FILTER = "original";
declare class EditorSlider extends LitBlock {
state: {
operation: SliderOperation;
filter: SliderFilter | undefined;
originalUrl: string;
disabled: boolean;
min: number;
max: number;
value: number;
defaultValue: number;
zero: number;
};
private _handleInput;
setOperation(operation: SliderOperation, filter?: SliderFilter): void;
private _initializeValues;
apply(): void;
cancel(): void;
initCallback(): void;
protected updated(changedProperties: PropertyValues<this>): void;
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-editor-slider': EditorSlider;
}
}
type TabIdValue = (typeof TabId)[keyof typeof TabId];
declare class EditorToolbar extends LitBlock {
private _showLoader;
showMainToolbar: boolean;
showSubToolbar: boolean;
private _showTabToggles;
tabList: readonly TabIdValue[];
activeTab: TabIdValue;
private _useSliderPanel;
private _tooltipVisible;
private _operationTooltip;
private _tabIndicatorOffset;
private _tabIndicatorWidth;
private readonly _sliderRef;
private readonly _tabIndicatorRef;
protected readonly tabToggleRefs: Record<TabIdValue, Ref<HTMLElement>>;
private readonly _handleWindowResize;
private _cropPresets;
private _cancelPreload?;
private readonly _debouncedShowLoader;
private readonly _updateInfoTooltip;
private readonly _subTopToolbarStyles;
private readonly _subBottomToolbarStyles;
private readonly _tabToggleStyles;
private readonly _tabTogglesStyles;
init$: Record<string, unknown>;
private _onSliderClose;
private _activateTab;
private _applyTabState;
private _syncTabIndicator;
private get _hasAspectRatioPicker();
private _renderControlsByTab;
private _renderCropTabControls;
private _renderFilterTabControls;
private _renderTuningTabControls;
private _renderControlGroup;
private _renderFreeformControl;
private _renderAspectRatioControl;
private _renderCropOperationControl;
private _renderFilterControl;
private _renderOperationControl;
private _renderAspectRatioList;
private _preloadEditedImage;
initCallback(): void;
connectedCallback(): void;
firstUpdated(changedProperties: PropertyValues<this>): void;
protected updated(changedProperties: PropertyValues<this>): void;
disconnectedCallback(): void;
private _assignSharedElements;
private readonly _handleCancel;
private readonly _handleApply;
private readonly _handleApplySlider;
private readonly _handleCancelSlider;
private readonly _handleTabClick;
private _renderTabToggle;
private _renderTabContent;
render(): TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-editor-toolbar': EditorToolbar;
}
}
declare class CloudImageEditorBlock extends LitBlock {
attributesMeta: ({
uuid: string;
} | {
'cdn-url': string;
}) & Partial<{
tabs: string;
'crop-preset': string;
}> & {
'ctx-name': string;
};
ctxOwner: boolean;
static styleAttrs: string[];
private _statusMessage;
private _imageSrc;
private _fileType;
private _showLoader;
uuid: string | null;
cdnUrl: string | null;
cropPreset: string;
tabs: string | null;
private _hasNetworkProblems;
private _isInitialized;
private _pendingInitUpdate;
private readonly _debouncedShowLoader;
private readonly _imgRef;
private readonly _cropperRef;
private readonly _faderRef;
private readonly _imgContainerRef;
private readonly _handleImageLoad;
private readonly _handleImageError;
private readonly _handleRetryNetwork;
private _scheduleInitialization;
init$: ReturnType<typeof initState>;
initCallback(): void;
private _assignSharedElements;
private _attachImageListeners;
private _detachImageListeners;
private get _imageClassName();
/**
* To proper work, we need non-zero size the element. So, we'll wait for it.
*/
private _waitForSize;
firstUpdated(changedProperties: PropertyValues<this>): void;
disconnectedCallback(): void;
render(): lit_html.TemplateResult<1>;
protected updated(changedProperties: PropertyValues<this>): void;
private _syncTabListFromProp;
private _syncCropPresetState;
updateImage(): Promise<void>;
initEditor(): Promise<void>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-cloud-image-editor-block': CloudImageEditorBlock;
}
}
declare class CloudImageEditor extends CloudImageEditorBlock {
static styleAttrs: string[];
constructor();
initCallback(): void;
}
declare global {
interface HTMLElementTagNameMap {
'uc-cloud-image-editor': CloudImageEditor;
}
}
type ActivityParams$1 = {
internalId: string;
};
declare class CloudImageEditorActivity extends LitUploaderBlock {
couldBeCtxOwner: boolean;
activityType: "cloud-image-edit";
private _entry?;
private _editorConfig;
get activityParams(): ActivityParams$1;
initCallback(): void;
private _handleApply;
private _handleCancel;
handleChange(event: CustomEvent<ChangeResult>): void;
private _mountEditor;
private _unmountEditor;
render(): lit_html.TemplateResult<1> | typeof nothing;
private _createEditorConfig;
}
declare global {
interface HTMLElementTagNameMap {
'uc-cloud-image-editor-activity': CloudImageEditorActivity;
}
}
declare class ActivityHeader extends LitActivityBlock {
}
declare global {
interface HTMLElementTagNameMap {
'uc-activity-header': ActivityHeader;
}
}
declare class Spinner extends LitBlock {
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-spinner': Spinner;
}
}
type ActivityParams = {
externalSourceType: string;
};
declare class ExternalSource extends LitUploaderBlock {
couldBeCtxOwner: boolean;
activityType: "external";
private _messageBridge?;
private _iframeRef;
private _latestSelectionSummary;
private _selectedList;
private _isSelectionReady;
private _isDoneBtnEnabled;
private _couldSelectAll;
private _couldDeselectAll;
private _showSelectionStatus;
private _showDoneBtn;
private _doneBtnTextClass;
private _toolbarVisible;
private get _counterText();
get activityParams(): ActivityParams;
initCallback(): void;
private _extractUrlFromSelectedFile;
private _handleToolbarStateChange;
private _handleSelectedFilesChange;
private _handleIframeLoad;
private _applyTheme;
private _applyEmbedCss;
private _setupL10n;
private _remoteUrl;
private _handleDone;
private _handleCancel;
private _handleSelectAll;
private _handleDeselectAll;
private _setSelectionSummary;
private _mountIframe;
private _unmountIframe;
private _resetSelectionStatus;
disconnectedCallback(): void;
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-external-source': ExternalSource;
}
}
declare const ACTIVITY_TYPES: Readonly<{
START_FROM: "start-from";
CAMERA: "camera";
DRAW: "draw";
UPLOAD_LIST: "upload-list";
URL: "url";
CLOUD_IMG_EDIT: "cloud-image-edit";
EXTERNAL: "external";
}>;
type RegisteredActivityType = (typeof ACTIVITY_TYPES)[keyof typeof ACTIVITY_TYPES];
type ActivityType = RegisteredActivityType | (string & {}) | null;
declare const ACTIVE_PROP = "___ACTIVITY_IS_ACTIVE___";
type ActivityParamsMap = {
'cloud-image-edit': ActivityParams$1;
external: ActivityParams;
};
declare class LitActivityBlock extends LitBlock {
protected historyTracked: boolean;
private [ACTIVE_PROP]?;
init$: {
'*currentActivity': null;
'*currentActivityParams': {};
'*history': never[];
'*historyBack': null;
'*closeModal': () => void;
};
private _debouncedHistoryFlush;
private _deactivate;
private _activate;
initCallback(): void;
private _historyFlush;
private _isActivityRegistered;
private static _activityCallbacks;
static activities: Readonly<{
START_FROM: 'start-from';
CAMERA: 'camera';
DRAW: 'draw';
UPLOAD_LIST: 'upload-list';
URL: 'url';
CLOUD_IMG_EDIT: 'cloud-image-edit';
EXTERNAL: 'external';
}>;
protected get isActivityActive(): boolean;
get couldOpenActivity(): boolean;
/** TODO: remove name argument */
protected registerActivity(_name: string, options?: {
onActivate?: () => void;
onDeactivate?: () => void;
}): void;
private _unregisterActivity;
disconnectedCallback(): void;
get activityParams(): ActivityParamsMap[keyof ActivityParamsMap];
get initActivity(): string | null;
get doneActivity(): string | null;
historyBack(): void;
}
declare const InternalEventType: Readonly<{
readonly INIT_SOLUTION: "init-solution";
readonly CHANGE_CONFIG: "change-config";
readonly ACTION_EVENT: "action-event";
readonly ERROR_EVENT: "error-event";
}>;
declare const EventType: Readonly<{
readonly FILE_ADDED: "file-added";
readonly FILE_REMOVED: "file-removed";
readonly FILE_UPLOAD_START: "file-upload-start";
readonly FILE_UPLOAD_PROGRESS: "file-upload-progress";
readonly FILE_UPLOAD_SUCCESS: "file-upload-success";
readonly FILE_UPLOAD_FAILED: "file-upload-failed";
readonly FILE_URL_CHANGED: "file-url-changed";
readonly MODAL_OPEN: "modal-open";
readonly MODAL_CLOSE: "modal-close";
readonly DONE_CLICK: "done-click";
readonly UPLOAD_CLICK: "upload-click";
readonly ACTIVITY_CHANGE: "activity-change";
readonly COMMON_UPLOAD_START: "common-upload-start";
readonly COMMON_UPLOAD_PROGRESS: "common-upload-progress";
readonly COMMON_UPLOAD_SUCCESS: "common-upload-success";
readonly COMMON_UPLOAD_FAILED: "common-upload-failed";
readonly CHANGE: "change";
readonly GROUP_CREATED: "group-created";
}>;
type EventKey = (typeof EventType)[keyof typeof EventType];
type InternalEventKey = (typeof InternalEventType)[keyof typeof InternalEventType];
type EventPayload = {
[EventType.FILE_ADDED]: OutputFileEntry<'idle'>;
[EventType.FILE_REMOVED]: OutputFileEntry<'removed'>;
[EventType.FILE_UPLOAD_START]: OutputFileEntry<'uploading'>;
[EventType.FILE_UPLOAD_PROGRESS]: OutputFileEntry<'uploading'>;
[EventType.FILE_UPLOAD_SUCCESS]: OutputFileEntry<'success'>;
[EventType.FILE_UPLOAD_FAILED]: OutputFileEntry<'failed'>;
[EventType.FILE_URL_CHANGED]: OutputFileEntry<'success'>;
[EventType.MODAL_OPEN]: {
modalId: ModalId;
};
[EventType.MODAL_CLOSE]: {
modalId: ModalId;
hasActiveModals: boolean;
};
[EventType.ACTIVITY_CHANGE]: {
activity: ActivityType;
};
[EventType.UPLOAD_CLICK]: undefined;
[EventType.DONE_CLICK]: OutputCollectionState;
[EventType.COMMON_UPLOAD_START]: OutputCollectionState<'uploading'>;
[EventType.COMMON_UPLOAD_PROGRESS]: OutputCollectionState<'uploading'>;
[EventType.COMMON_UPLOAD_SUCCESS]: OutputCollectionState<'success'>;
[EventType.COMMON_UPLOAD_FAILED]: OutputCollectionState<'failed'>;
[EventType.CHANGE]: OutputCollectionState;
[EventType.GROUP_CREATED]: OutputCollectionState<'success', 'has-group'>;
};
declare class EventEmitter extends SharedInstance {
private _timeoutStore;
private _targets;
bindTarget(target: LitBlock): () => void;
private _dispatch;
emit<T extends EventKey, TDebounce extends boolean | number | undefined = undefined>(type: T, payload?: TDebounce extends false | undefined ? EventPayload[T] : () => EventPayload[T], options?: {
debounce?: TDebounce;
}): void;
destroy(): void;
}
type EventMap = {
[T in keyof EventPayload]: CustomEvent<EventPayload[T]>;
};
type PasteScope = 'local' | 'global' | false;
declare class ClipboardLayer extends SharedInstance {
private scopes;
private listener;
constructor(sharedInstancesBag: SharedInstancesBag);
private openUploadList;
private _listener;
private handlePaste;
registerBlock(scope: Node): () => void;
destroy(): void;
}
type SelectOption = {
text: string;
value: string;
};
declare class Select extends LitBlock {
value: string;
disabled: boolean;
options: SelectOption[];
render(): lit_html.TemplateResult<1>;
private _handleChange;
}
declare global {
interface HTMLElementTagNameMap {
'uc-select': Select;
}
}
type CameraMode = 'photo' | 'video';
declare class CameraSource extends LitUploaderBlock {
couldBeCtxOwner: boolean;
activityType: "camera";
private _unsubPermissions;
private _capturing;
private _chunks;
private _mediaRecorder;
private _stream;
private _selectedAudioId;
private _selectedCameraId;
private _activeTab;
private _options;
private _canvas;
private _ctx;
private _cameraDevices;
private _audioDevices;
private _permissionResponses;
private _permissionCleanupFns;
private _currentVideoSource;
private readonly _handlePreviewPlay;
private readonly _handlePreviewPause;
private _timerRef;
private _lineRef;
private _videoRef;
private _switcherRef;
private _startTime;
private _elapsedTime;
private _videoTransformCss;
private _videoHidden;
private _messageHidden;
private _requestBtnHidden;
private _cameraSelectOptions;
private _cameraSelectHidden;
private _l10nMessage;
private _timerHidden;
private _cameraHidden;
private _cameraActionsHidden;
private _audioSelectOptions;
private _audioSelectHidden;
private _audioSelectDisabled;
private _audioToggleMicrophoneHidden;
private _tabCameraHidden;
private _tabVideoHidden;
private _currentIcon;
private _currentTimelineIcon;
private _toggleMicrophoneIcon;
private _mutableClassButton;
private _chooseActionWithCamera;
private _handleCameraSelectChange;
private _handleAudioSelectChange;
private _handleRequestPermissions;
private _handleStartCamera;
private _handleToggleRecording;
private _handleToggleAudio;
private _handleRetake;
private _handleAccept;
private _handleClickTab;
private _updateTimer;
private _startTimer;
private _stopTimer;
private _startTimeline;
private _stopTimeline;
private _animationFrameId;
private _startRecording;
private _stopRecording;
/** This method is used to toggle recording pause/resume */
private _toggleRecording;
private _toggleEnableAudio;
/**
* Previewing the video that was recorded on the camera
*/
private _previewVideo;
private _attachPreviewListeners;
private _detachPreviewListeners;
private _setVideoSource;
/**
* Do not bind srcObject directly in the template, because it stops video pausing on shot.
* I really don'y know why but that's how it is. Assigning srcObject manually fixes the issue.
*/
private _applyVideoSource;
private _retake;
private _accept;
private _handlePhoto;
private _handleVideo;
private _setCameraState;
private _shot;
private _handleActiveTab;
private _createFile;
private _guessExtensionByMime;
/**
* The send file to the server
*/
private _toSend;
private get _cameraModes();
private _setPermissionsState;
private _makeStreamInactive;
private _stopCapture;
private _capture;
private _handlePermissionsChange;
private _permissionAccess;
private _teardownPermissionListeners;
private _requestDeviceAccess;
private _getDevices;
private _onActivate;
private _onDeactivate;
private _handleCameraModes;
initCallback(): void;
firstUpdated(changedProperties: PropertyValues<this>): void;
updated(changedProperties: PropertyValues<this>): void;
private _destroy;
disconnectedCallback(): void;
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-camera-source': CameraSource;
}
}
/**
* Config keys that can't be passed as attribute (because they are object or function)
*/
declare const complexConfigKeys: readonly ["metadata", "localeDefinitionOverride", "secureUploadsSignatureResolver", "secureDeliveryProxyUrlResolver", "iconHrefResolver", "fileValidators", "collectionValidators", "mediaRecorderOptions"];
/** Mapping of attribute names to state */
declare const attrStateMapping: Record<string, string>;
declare class Config extends LitBlock {
attributesMeta: Partial<ConfigPlainType> & {
'ctx-name': string;
};
init$: LitBlock["init$"] & ConfigType;
private _computationControllers;
private _flushValueToAttribute;
private _flushValueToState;
private _setValue;
private _getValue;
private _assertSameValueDifferentReference;
initCallback(): void;
attributeChangedCallback(name: keyof typeof attrStateMapping, oldVal: string, newVal: string): void;
static get observedAttributes(): string[];
}
interface Config extends ConfigType {
}
declare global {
interface HTMLElementTagNameMap {
'uc-config': Config;
}
}
declare class FileItemConfig extends LitUploaderBlock {
private _entrySubs;
protected entry: UploadEntryTypedData | null;
protected withEntry<A extends unknown[], R>(fn: (entry: UploadEntryTypedData, ...args: A) => R): (...args: A) => R | undefined;
protected subEntry<K extends UploadEntryKeys>(prop: K, handler: (value: UploadEntryData[K]) => void): void;
protected reset(): void;
disconnectedCallback(): void;
}
declare class Thumb extends FileItemConfig {
badgeIcon: string;
uid: Uid;
private _thumbUrl;
private _renderedGridOnce;
private _thumbRect;
private _isIntersecting;
private _firstViewMode;
private _observer?;
private _pendingThumbUpdate?;
private _calculateThumbSize;
private _generateThumbnail;
private _debouncedGenerateThumb;
private _decodeImage;
private _cancelPendingThumbUpdate;
private _scheduleThumbUpdate;
private _requestThumbGeneration;
protected firstUpdated(changedProperties: PropertyValues<this>): void;
protected updated(changedProperties: PropertyValues<this>): void;
private _observerCallback;
protected reset(): void;
private _bindToEntry;
initCallback(): void;
connectedCallback(): void;
disconnectedCallback(): void;
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-thumb': Thumb;
}
}
declare class ProgressBar extends LitBlock {
hasFileName: boolean;
value: number;
visible: boolean;
private _progressValue;
private readonly _fakeProgressLineRef;
private readonly _handleFakeProgressAnimation;
protected firstUpdated(changedProperties: PropertyValues<this>): void;
protected updated(changedProperties: PropertyValues<this>): void;
disconnectedCallback(): void;
private _normalizeProgressValue;
private _updateProgressValueStyle;
render(): lit_html.TemplateResult<1>;
}
declare global {
interface HTMLElementTagNameMap {
'uc-progress-bar': ProgressBar;
}
}
declare class FileItem extends FileItemConfig {
protected couldBeCtxOwner: boolean;
private _pauseRender;
uid: Uid;
private _itemName;
private _errorText;
private _hint;
private _progressValue;
private _progressVisible;
private _badgeIcon;
private _isFinished;
private _isFailed;
private _isUploading;
private _isFocused;
private _isEditable;
private _showFileNames;
private _ariaLabelStatusFile;
private _renderedOnce;
private _observer?;
private _handleEdit;
private _handleRemove;
private _handleUploadClick;
private _calculateState;
private _debouncedCalculateState;
private _updateHintAndProgress;
private _handleState;
protected reset(): void;
private _observerCallback;
private _handleEntryId;
private _updateShowFileNames;
protected willUpdate(changedProperties: PropertyValues<this>): void;
initCallback(): void;
connectedCallback(): void;
disconnectedCallback(): void;
private _upload;
static activeInstances: Set<FileItem>;
protected shouldUpdate(changedProp