@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
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import _default from './locales/file-uploader/en.js';
|
|
|
4
4
|
import * as lit_html from 'lit-html';
|
|
5
5
|
import * as lit_html_directives_ref_js from 'lit-html/directives/ref.js';
|
|
6
6
|
import * as _uploadcare_upload_client from '@uploadcare/upload-client';
|
|
7
|
-
import {
|
|
7
|
+
import { FileFromOptions, Metadata, UploadcareFile, UploadError, NetworkError, UploadcareGroup, Queue } from '@uploadcare/upload-client';
|
|
8
8
|
export { Metadata, NetworkError, UploadError, UploadcareError, UploadcareFile, UploadcareGroup } from '@uploadcare/upload-client';
|
|
9
9
|
import { Ref } from 'lit/directives/ref.js';
|
|
10
10
|
import { TelemetryRequest } from '@uploadcare/quality-insights';
|
|
@@ -90,8 +90,72 @@ declare class A11y implements ISharedInstance {
|
|
|
90
90
|
declare class LocaleManager extends SharedInstance {
|
|
91
91
|
private _localeName;
|
|
92
92
|
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
93
|
+
private _applyOverrides;
|
|
94
|
+
private _applyPluginLocales;
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Custom configuration options registration system for plugins
|
|
99
|
+
*/
|
|
100
|
+
type CustomConfigDefinition<T = unknown> = {
|
|
101
|
+
/**
|
|
102
|
+
* Config option name (will be used as property and optionally as attribute)
|
|
103
|
+
*/
|
|
104
|
+
name: string;
|
|
105
|
+
/**
|
|
106
|
+
* Default value for the config option
|
|
107
|
+
*/
|
|
108
|
+
defaultValue: T;
|
|
109
|
+
/**
|
|
110
|
+
* Whether this config can be set via HTML attribute
|
|
111
|
+
* @default true
|
|
112
|
+
*/
|
|
113
|
+
attribute?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Convert attribute string to config value
|
|
116
|
+
* Only used if attribute is true
|
|
117
|
+
*/
|
|
118
|
+
fromAttribute?: (value: string | null) => T;
|
|
119
|
+
/**
|
|
120
|
+
* Convert config value to attribute string
|
|
121
|
+
* Only used if attribute is true
|
|
122
|
+
*/
|
|
123
|
+
toAttribute?: (value: T) => string | null;
|
|
124
|
+
/**
|
|
125
|
+
* Normalize/validate the config value
|
|
126
|
+
*/
|
|
127
|
+
normalize?: (value: unknown) => T;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Registry for custom config options defined by plugins
|
|
131
|
+
* This is managed by the PluginManager as a shared instance property
|
|
132
|
+
*/
|
|
133
|
+
declare class CustomConfigRegistry {
|
|
134
|
+
private _definitions;
|
|
135
|
+
register<T = unknown>(pluginId: string, definition: CustomConfigDefinition<T>): void;
|
|
136
|
+
unregister(name: string): void;
|
|
137
|
+
unregisterByPlugin(pluginId: string): void;
|
|
138
|
+
get(name: string): CustomConfigDefinition<any> | undefined;
|
|
139
|
+
getAll(): Map<string, CustomConfigDefinition<any>>;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Interface for TypeScript module augmentation
|
|
143
|
+
* Plugins should extend this interface to add their custom config types
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* declare module '@uploadcare/file-uploader' {
|
|
148
|
+
* interface CustomConfig {
|
|
149
|
+
* 'my-custom-option': string;
|
|
150
|
+
* }
|
|
151
|
+
* }
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
interface CustomConfig {
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
declare function buildOutputCollectionState<TCollectionStatus extends OutputCollectionStatus, TGroupFlag extends GroupFlag = 'maybe-has-group'>(bag: SharedInstancesBag): OutputCollectionState<TCollectionStatus, TGroupFlag>;
|
|
158
|
+
|
|
95
159
|
declare class TypedData<T extends Record<string, unknown>> {
|
|
96
160
|
private _ctxId;
|
|
97
161
|
private _data;
|
|
@@ -104,6 +168,41 @@ declare class TypedData<T extends Record<string, unknown>> {
|
|
|
104
168
|
destroy(): void;
|
|
105
169
|
}
|
|
106
170
|
|
|
171
|
+
type FuncFileValidator = (outputEntry: OutputFileEntry, api: UploaderPublicApi, options?: {
|
|
172
|
+
signal?: AbortSignal;
|
|
173
|
+
}) => undefined | OutputErrorFile | Promise<undefined | OutputErrorFile>;
|
|
174
|
+
type FileValidatorDescriptor = {
|
|
175
|
+
runOn: 'add' | 'upload' | 'change';
|
|
176
|
+
validator: FuncFileValidator;
|
|
177
|
+
};
|
|
178
|
+
type FileValidator = FileValidatorDescriptor | FuncFileValidator;
|
|
179
|
+
type FuncCollectionValidator = (collection: ReturnType<typeof buildOutputCollectionState<OutputCollectionStatus>>, api: UploaderPublicApi) => undefined | OutputErrorCollection;
|
|
180
|
+
declare class ValidationManager extends SharedInstance {
|
|
181
|
+
private get _uploadCollection();
|
|
182
|
+
private _commonFileValidators;
|
|
183
|
+
private _commonCollectionValidators;
|
|
184
|
+
private _queue;
|
|
185
|
+
private _runQueueDebounced;
|
|
186
|
+
private _isDestroyed;
|
|
187
|
+
private _entryValidationState;
|
|
188
|
+
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
189
|
+
runFileValidators(runOn: FileValidatorDescriptor['runOn'], entryIds?: Uid[]): void;
|
|
190
|
+
runCollectionValidators(): void;
|
|
191
|
+
cleanupValidationForEntry(entry: TypedData<UploadEntryData>): void;
|
|
192
|
+
private _runFileValidatorsForEntry;
|
|
193
|
+
private _addCustomTypeToValidationError;
|
|
194
|
+
private _getEntryValidationState;
|
|
195
|
+
private _getValidatorDescriptors;
|
|
196
|
+
private _getValidatorDescriptorsForEntry;
|
|
197
|
+
destroy(): void;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
declare class SecureUploadsManager extends SharedInstance {
|
|
201
|
+
private _secureToken;
|
|
202
|
+
getSecureToken(): Promise<SecureUploadsSignatureAndExpire | null>;
|
|
203
|
+
destroy(): void;
|
|
204
|
+
}
|
|
205
|
+
|
|
107
206
|
type ChangeMap<T extends Record<string, unknown>> = Record<keyof T, Set<Uid>>;
|
|
108
207
|
type TypedCollectionPropertyObserver<T extends Record<string, unknown>> = (changeMap: ChangeMap<T>) => void;
|
|
109
208
|
type TypedCollectionObserverHandler<T extends Record<string, unknown>> = (list: Uid[], added: Set<TypedData<T>>, removed: Set<TypedData<T>>) => void;
|
|
@@ -155,157 +254,6 @@ declare const CameraSourceTypes: Readonly<{
|
|
|
155
254
|
}>;
|
|
156
255
|
type ModeCameraType = (typeof CameraSourceTypes)[keyof typeof CameraSourceTypes];
|
|
157
256
|
|
|
158
|
-
declare function buildOutputCollectionState<TCollectionStatus extends OutputCollectionStatus, TGroupFlag extends GroupFlag = 'maybe-has-group'>(bag: SharedInstancesBag): OutputCollectionState<TCollectionStatus, TGroupFlag>;
|
|
159
|
-
|
|
160
|
-
interface UploadEntryData extends Record<string, unknown> {
|
|
161
|
-
file: File | null;
|
|
162
|
-
externalUrl: string | null;
|
|
163
|
-
fileName: string | null;
|
|
164
|
-
fileSize: number | null;
|
|
165
|
-
lastModified: number;
|
|
166
|
-
uploadProgress: number;
|
|
167
|
-
uuid: string | null;
|
|
168
|
-
isImage: boolean;
|
|
169
|
-
mimeType: string | null;
|
|
170
|
-
ctxName: string | null;
|
|
171
|
-
cdnUrl: string | null;
|
|
172
|
-
cdnUrlModifiers: string | null;
|
|
173
|
-
fileInfo: UploadcareFile | null;
|
|
174
|
-
isUploading: boolean;
|
|
175
|
-
abortController: AbortController | null;
|
|
176
|
-
thumbUrl: string | null;
|
|
177
|
-
silent: boolean;
|
|
178
|
-
source: string | null;
|
|
179
|
-
fullPath: string | null;
|
|
180
|
-
metadata: Metadata | null;
|
|
181
|
-
errors: OutputErrorFile[];
|
|
182
|
-
uploadError: Error | null;
|
|
183
|
-
isRemoved: boolean;
|
|
184
|
-
isQueuedForUploading: boolean;
|
|
185
|
-
isValidationPending: boolean;
|
|
186
|
-
isQueuedForValidation: boolean;
|
|
187
|
-
}
|
|
188
|
-
type UploadEntryTypedData = TypedData<UploadEntryData>;
|
|
189
|
-
type UploadEntryKeys = keyof UploadEntryData;
|
|
190
|
-
|
|
191
|
-
type ApiAddFileCommonOptions = {
|
|
192
|
-
silent?: boolean;
|
|
193
|
-
fileName?: string;
|
|
194
|
-
source?: string;
|
|
195
|
-
};
|
|
196
|
-
declare class UploaderPublicApi extends SharedInstance {
|
|
197
|
-
private _l10n;
|
|
198
|
-
get _uploadCollection(): TypedCollection<UploadEntryData>;
|
|
199
|
-
get cfg(): Readonly<ConfigType>;
|
|
200
|
-
get l10n(): (str: string, variables?: Record<string, string | number>) => string;
|
|
201
|
-
/**
|
|
202
|
-
* TODO: Probably we should not allow user to override `source` property
|
|
203
|
-
*/
|
|
204
|
-
addFileFromUrl: (url: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
205
|
-
addFileFromUuid: (uuid: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
206
|
-
addFileFromCdnUrl: (cdnUrl: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
207
|
-
addFileFromObject: (file: File, { silent, fileName, source, fullPath, }?: ApiAddFileCommonOptions & {
|
|
208
|
-
fullPath?: string;
|
|
209
|
-
}) => OutputFileEntry<"idle">;
|
|
210
|
-
removeFileByInternalId: (internalId: string) => void;
|
|
211
|
-
removeAllFiles(): void;
|
|
212
|
-
uploadAll: () => void;
|
|
213
|
-
openSystemDialog: (options?: {
|
|
214
|
-
captureCamera?: boolean;
|
|
215
|
-
modeCamera?: ModeCameraType;
|
|
216
|
-
}) => void;
|
|
217
|
-
getOutputItem<TStatus extends OutputFileStatus>(entryId: string): OutputFileEntry<TStatus>;
|
|
218
|
-
getOutputCollectionState<TStatus extends OutputCollectionStatus>(): ReturnType<typeof buildOutputCollectionState<TStatus>>;
|
|
219
|
-
initFlow: (force?: boolean) => void;
|
|
220
|
-
doneFlow: () => void;
|
|
221
|
-
setCurrentActivity: <T extends RegisteredActivityType>(activityType: T, ...params: T extends keyof ActivityParamsMap ? [ActivityParamsMap[T]] : T extends RegisteredActivityType ? [undefined?] : [never]) => void;
|
|
222
|
-
getCurrentActivity: () => ActivityType;
|
|
223
|
-
setModalState: (opened: boolean) => void;
|
|
224
|
-
private get _sourceList();
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
declare const ExternalUploadSource: Readonly<{
|
|
228
|
-
readonly FACEBOOK: "facebook";
|
|
229
|
-
readonly DROPBOX: "dropbox";
|
|
230
|
-
readonly DROPBOX_CHOOSER: "dropboxchooser";
|
|
231
|
-
readonly GDRIVE: "gdrive";
|
|
232
|
-
readonly GPHOTOS: "gphotos";
|
|
233
|
-
readonly FLICKR: "flickr";
|
|
234
|
-
readonly VK: "vk";
|
|
235
|
-
readonly EVERNOTE: "evernote";
|
|
236
|
-
readonly BOX: "box";
|
|
237
|
-
readonly ONEDRIVE: "onedrive";
|
|
238
|
-
readonly HUDDLE: "huddle";
|
|
239
|
-
}>;
|
|
240
|
-
declare const UploadSource: Readonly<{
|
|
241
|
-
readonly FACEBOOK: "facebook";
|
|
242
|
-
readonly DROPBOX: "dropbox";
|
|
243
|
-
readonly DROPBOX_CHOOSER: "dropboxchooser";
|
|
244
|
-
readonly GDRIVE: "gdrive";
|
|
245
|
-
readonly GPHOTOS: "gphotos";
|
|
246
|
-
readonly FLICKR: "flickr";
|
|
247
|
-
readonly VK: "vk";
|
|
248
|
-
readonly EVERNOTE: "evernote";
|
|
249
|
-
readonly BOX: "box";
|
|
250
|
-
readonly ONEDRIVE: "onedrive";
|
|
251
|
-
readonly HUDDLE: "huddle";
|
|
252
|
-
readonly MOBILE_VIDEO_CAMERA: "mobile-video-camera";
|
|
253
|
-
readonly MOBILE_PHOTO_CAMERA: "mobile-photo-camera";
|
|
254
|
-
readonly LOCAL: "local";
|
|
255
|
-
readonly DROP_AREA: "drop-area";
|
|
256
|
-
readonly CAMERA: "camera";
|
|
257
|
-
readonly EXTERNAL: "external";
|
|
258
|
-
readonly API: "js-api";
|
|
259
|
-
readonly URL: "url";
|
|
260
|
-
readonly DRAW: "draw";
|
|
261
|
-
}>;
|
|
262
|
-
type SourceTypes = (typeof UploadSource)[keyof typeof UploadSource];
|
|
263
|
-
|
|
264
|
-
declare class LitUploaderBlock extends LitActivityBlock {
|
|
265
|
-
static extSrcList: Readonly<typeof ExternalUploadSource>;
|
|
266
|
-
static sourceTypes: Readonly<typeof UploadSource>;
|
|
267
|
-
protected couldBeCtxOwner: boolean;
|
|
268
|
-
private _isCtxOwner;
|
|
269
|
-
private _unobserveCollection?;
|
|
270
|
-
private _unobserveCollectionProperties?;
|
|
271
|
-
init$: {
|
|
272
|
-
'*commonProgress': number;
|
|
273
|
-
'*uploadList': never[];
|
|
274
|
-
'*uploadQueue': _uploadcare_upload_client.Queue;
|
|
275
|
-
'*collectionErrors': OutputErrorCollection[];
|
|
276
|
-
'*collectionState': OutputCollectionState | null;
|
|
277
|
-
'*groupInfo': _uploadcare_upload_client.UploadcareGroup | null;
|
|
278
|
-
'*uploadTrigger': Set<string>;
|
|
279
|
-
'*currentActivity': null;
|
|
280
|
-
'*currentActivityParams': {};
|
|
281
|
-
'*history': never[];
|
|
282
|
-
'*historyBack': null;
|
|
283
|
-
'*closeModal': () => void;
|
|
284
|
-
};
|
|
285
|
-
private get _hasCtxOwner();
|
|
286
|
-
initCallback(): void;
|
|
287
|
-
getAPI(): UploaderPublicApi;
|
|
288
|
-
get validationManager(): ValidationManager;
|
|
289
|
-
get api(): UploaderPublicApi;
|
|
290
|
-
get uploadCollection(): TypedCollection<UploadEntryData>;
|
|
291
|
-
get secureUploadsManager(): SecureUploadsManager;
|
|
292
|
-
disconnectedCallback(): void;
|
|
293
|
-
connectedCallback(): void;
|
|
294
|
-
private _initCtxOwner;
|
|
295
|
-
private _observeUploadCollection;
|
|
296
|
-
private _unobserveUploadCollection;
|
|
297
|
-
private _createGroup;
|
|
298
|
-
private _flushOutputItems;
|
|
299
|
-
private _handleCollectionUpdate;
|
|
300
|
-
private _handleCollectionPropertiesUpdate;
|
|
301
|
-
private _flushCommonUploadProgress;
|
|
302
|
-
private _openCloudImageEditor;
|
|
303
|
-
private _setInitialCrop;
|
|
304
|
-
protected getMetadataFor(entryId: string): Promise<_uploadcare_upload_client.Metadata | undefined>;
|
|
305
|
-
protected getUploadClientOptions(): Promise<FileFromOptions>;
|
|
306
|
-
getOutputData(): OutputFileEntry[];
|
|
307
|
-
}
|
|
308
|
-
|
|
309
257
|
/**
|
|
310
258
|
* Mapping of loading resources per operation
|
|
311
259
|
*/
|
|
@@ -420,11 +368,14 @@ declare global {
|
|
|
420
368
|
declare class Icon extends LitBlock {
|
|
421
369
|
name: string;
|
|
422
370
|
private _resolvedHref;
|
|
371
|
+
private _pluginSvg;
|
|
423
372
|
private _iconHrefResolver;
|
|
373
|
+
private _unsubscribePlugins?;
|
|
424
374
|
initCallback(): void;
|
|
425
375
|
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
426
376
|
private _updateResolvedHref;
|
|
427
377
|
render(): lit_html.TemplateResult<1>;
|
|
378
|
+
disconnectedCallback(): void;
|
|
428
379
|
}
|
|
429
380
|
declare global {
|
|
430
381
|
interface HTMLElementTagNameMap {
|
|
@@ -955,6 +906,7 @@ declare class CloudImageEditorBlock extends LitBlock {
|
|
|
955
906
|
private _hasNetworkProblems;
|
|
956
907
|
private _isInitialized;
|
|
957
908
|
private _pendingInitUpdate;
|
|
909
|
+
private _pendingSizeWait;
|
|
958
910
|
private readonly _debouncedShowLoader;
|
|
959
911
|
private readonly _imgRef;
|
|
960
912
|
private readonly _cropperRef;
|
|
@@ -1004,12 +956,11 @@ type ActivityParams$1 = {
|
|
|
1004
956
|
internalId: string;
|
|
1005
957
|
};
|
|
1006
958
|
declare class CloudImageEditorActivity extends LitUploaderBlock {
|
|
1007
|
-
couldBeCtxOwner: boolean;
|
|
1008
|
-
activityType: "cloud-image-edit";
|
|
1009
959
|
private _entry?;
|
|
1010
960
|
private _editorConfig;
|
|
1011
961
|
get activityParams(): ActivityParams$1;
|
|
1012
962
|
initCallback(): void;
|
|
963
|
+
disconnectedCallback(): void;
|
|
1013
964
|
private _handleApply;
|
|
1014
965
|
private _handleCancel;
|
|
1015
966
|
handleChange(event: CustomEvent<ChangeResult>): void;
|
|
@@ -1046,7 +997,6 @@ type ActivityParams = {
|
|
|
1046
997
|
};
|
|
1047
998
|
declare class ExternalSource extends LitUploaderBlock {
|
|
1048
999
|
couldBeCtxOwner: boolean;
|
|
1049
|
-
activityType: "external";
|
|
1050
1000
|
private _messageBridge?;
|
|
1051
1001
|
private _iframeRef;
|
|
1052
1002
|
private _latestSelectionSummary;
|
|
@@ -1090,22 +1040,26 @@ declare global {
|
|
|
1090
1040
|
declare const ACTIVITY_TYPES: Readonly<{
|
|
1091
1041
|
START_FROM: "start-from";
|
|
1092
1042
|
CAMERA: "camera";
|
|
1093
|
-
DRAW: "draw";
|
|
1094
1043
|
UPLOAD_LIST: "upload-list";
|
|
1095
1044
|
URL: "url";
|
|
1096
1045
|
CLOUD_IMG_EDIT: "cloud-image-edit";
|
|
1097
1046
|
EXTERNAL: "external";
|
|
1098
1047
|
}>;
|
|
1099
|
-
type RegisteredActivityType = (typeof ACTIVITY_TYPES)[keyof typeof ACTIVITY_TYPES];
|
|
1100
|
-
type ActivityType = RegisteredActivityType |
|
|
1048
|
+
type RegisteredActivityType = (typeof ACTIVITY_TYPES)[keyof typeof ACTIVITY_TYPES] | keyof CustomActivities;
|
|
1049
|
+
type ActivityType = RegisteredActivityType | null;
|
|
1101
1050
|
|
|
1102
1051
|
declare const ACTIVE_PROP = "___ACTIVITY_IS_ACTIVE___";
|
|
1052
|
+
interface CustomActivities {
|
|
1053
|
+
}
|
|
1103
1054
|
type ActivityParamsMap = {
|
|
1104
1055
|
'cloud-image-edit': ActivityParams$1;
|
|
1105
1056
|
external: ActivityParams;
|
|
1057
|
+
} & {
|
|
1058
|
+
[Key in keyof CustomActivities]: CustomActivities[Key]['params'];
|
|
1106
1059
|
};
|
|
1107
1060
|
declare class LitActivityBlock extends LitBlock {
|
|
1108
1061
|
protected historyTracked: boolean;
|
|
1062
|
+
activityType: ActivityType;
|
|
1109
1063
|
private [ACTIVE_PROP]?;
|
|
1110
1064
|
init$: {
|
|
1111
1065
|
'*currentActivity': null;
|
|
@@ -1119,12 +1073,11 @@ declare class LitActivityBlock extends LitBlock {
|
|
|
1119
1073
|
private _activate;
|
|
1120
1074
|
initCallback(): void;
|
|
1121
1075
|
private _historyFlush;
|
|
1122
|
-
|
|
1076
|
+
protected _isActivityRegistered(): boolean;
|
|
1123
1077
|
private static _activityCallbacks;
|
|
1124
1078
|
static activities: Readonly<{
|
|
1125
1079
|
START_FROM: 'start-from';
|
|
1126
1080
|
CAMERA: 'camera';
|
|
1127
|
-
DRAW: 'draw';
|
|
1128
1081
|
UPLOAD_LIST: 'upload-list';
|
|
1129
1082
|
URL: 'url';
|
|
1130
1083
|
CLOUD_IMG_EDIT: 'cloud-image-edit';
|
|
@@ -1140,8 +1093,8 @@ declare class LitActivityBlock extends LitBlock {
|
|
|
1140
1093
|
private _unregisterActivity;
|
|
1141
1094
|
disconnectedCallback(): void;
|
|
1142
1095
|
get activityParams(): ActivityParamsMap[keyof ActivityParamsMap];
|
|
1143
|
-
get initActivity():
|
|
1144
|
-
get doneActivity():
|
|
1096
|
+
get initActivity(): RegisteredActivityType | null;
|
|
1097
|
+
get doneActivity(): RegisteredActivityType | null;
|
|
1145
1098
|
historyBack(): void;
|
|
1146
1099
|
}
|
|
1147
1100
|
|
|
@@ -1203,7 +1156,9 @@ type EventPayload = {
|
|
|
1203
1156
|
declare class EventEmitter extends SharedInstance {
|
|
1204
1157
|
private _timeoutStore;
|
|
1205
1158
|
private _targets;
|
|
1159
|
+
private _listeners;
|
|
1206
1160
|
bindTarget(target: LitBlock): () => void;
|
|
1161
|
+
on<T extends EventKey>(type: T, handler: (payload: EventPayload[T]) => void): () => void;
|
|
1207
1162
|
private _dispatch;
|
|
1208
1163
|
emit<T extends EventKey, TDebounce extends boolean | number | undefined = undefined>(type: T, payload?: TDebounce extends false | undefined ? EventPayload[T] : () => EventPayload[T], options?: {
|
|
1209
1164
|
debounce?: TDebounce;
|
|
@@ -1211,20 +1166,123 @@ declare class EventEmitter extends SharedInstance {
|
|
|
1211
1166
|
destroy(): void;
|
|
1212
1167
|
}
|
|
1213
1168
|
|
|
1214
|
-
type
|
|
1215
|
-
|
|
1169
|
+
type ApiAddFileCommonOptions = {
|
|
1170
|
+
silent?: boolean;
|
|
1171
|
+
fileName?: string;
|
|
1172
|
+
source?: string;
|
|
1216
1173
|
};
|
|
1174
|
+
declare class UploaderPublicApi extends SharedInstance {
|
|
1175
|
+
private _l10n;
|
|
1176
|
+
get _uploadCollection(): TypedCollection<UploadEntryData>;
|
|
1177
|
+
get cfg(): Readonly<ConfigType>;
|
|
1178
|
+
get l10n(): (str: string, variables?: Record<string, string | number>) => string;
|
|
1179
|
+
/**
|
|
1180
|
+
* TODO: Probably we should not allow user to override `source` property
|
|
1181
|
+
*/
|
|
1182
|
+
addFileFromUrl: (url: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
1183
|
+
addFileFromUuid: (uuid: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
1184
|
+
addFileFromCdnUrl: (cdnUrl: string, { silent, fileName, source }?: ApiAddFileCommonOptions) => OutputFileEntry<"idle">;
|
|
1185
|
+
addFileFromObject: (file: File, { silent, fileName, source, fullPath, }?: ApiAddFileCommonOptions & {
|
|
1186
|
+
fullPath?: string;
|
|
1187
|
+
}) => OutputFileEntry<"idle">;
|
|
1188
|
+
removeFileByInternalId: (internalId: string) => void;
|
|
1189
|
+
removeAllFiles(): void;
|
|
1190
|
+
uploadAll: () => void;
|
|
1191
|
+
openSystemDialog: (options?: {
|
|
1192
|
+
captureCamera?: boolean;
|
|
1193
|
+
modeCamera?: ModeCameraType;
|
|
1194
|
+
}) => void;
|
|
1195
|
+
getOutputItem<TStatus extends OutputFileStatus>(entryId: string): OutputFileEntry<TStatus>;
|
|
1196
|
+
getOutputCollectionState<TStatus extends OutputCollectionStatus>(): ReturnType<typeof buildOutputCollectionState<TStatus>>;
|
|
1197
|
+
initFlow: (force?: boolean) => void;
|
|
1198
|
+
doneFlow: () => void;
|
|
1199
|
+
private _pluginsReady;
|
|
1200
|
+
setCurrentActivity: <T extends ActivityType>(activityType: T, ...params: T extends keyof ActivityParamsMap ? [ActivityParamsMap[T]] extends [never] ? [] : [ActivityParamsMap[T]] : []) => void;
|
|
1201
|
+
on: <T extends EventKey>(type: T, handler: (payload: EventPayload[T]) => void) => (() => void);
|
|
1202
|
+
getCurrentActivity: () => ActivityType;
|
|
1203
|
+
historyBack: () => void;
|
|
1204
|
+
setModalState: (opened: boolean) => void;
|
|
1205
|
+
private get _sourceList();
|
|
1206
|
+
}
|
|
1217
1207
|
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1208
|
+
declare const ExternalUploadSource: Readonly<{
|
|
1209
|
+
readonly FACEBOOK: "facebook";
|
|
1210
|
+
readonly DROPBOX: "dropbox";
|
|
1211
|
+
readonly DROPBOX_CHOOSER: "dropboxchooser";
|
|
1212
|
+
readonly GDRIVE: "gdrive";
|
|
1213
|
+
readonly GPHOTOS: "gphotos";
|
|
1214
|
+
readonly FLICKR: "flickr";
|
|
1215
|
+
readonly VK: "vk";
|
|
1216
|
+
readonly EVERNOTE: "evernote";
|
|
1217
|
+
readonly BOX: "box";
|
|
1218
|
+
readonly ONEDRIVE: "onedrive";
|
|
1219
|
+
readonly HUDDLE: "huddle";
|
|
1220
|
+
}>;
|
|
1221
|
+
declare const UploadSource: Readonly<{
|
|
1222
|
+
readonly FACEBOOK: "facebook";
|
|
1223
|
+
readonly DROPBOX: "dropbox";
|
|
1224
|
+
readonly DROPBOX_CHOOSER: "dropboxchooser";
|
|
1225
|
+
readonly GDRIVE: "gdrive";
|
|
1226
|
+
readonly GPHOTOS: "gphotos";
|
|
1227
|
+
readonly FLICKR: "flickr";
|
|
1228
|
+
readonly VK: "vk";
|
|
1229
|
+
readonly EVERNOTE: "evernote";
|
|
1230
|
+
readonly BOX: "box";
|
|
1231
|
+
readonly ONEDRIVE: "onedrive";
|
|
1232
|
+
readonly HUDDLE: "huddle";
|
|
1233
|
+
readonly MOBILE_VIDEO_CAMERA: "mobile-video-camera";
|
|
1234
|
+
readonly MOBILE_PHOTO_CAMERA: "mobile-photo-camera";
|
|
1235
|
+
readonly LOCAL: "local";
|
|
1236
|
+
readonly DROP_AREA: "drop-area";
|
|
1237
|
+
readonly CAMERA: "camera";
|
|
1238
|
+
readonly EXTERNAL: "external";
|
|
1239
|
+
readonly API: "js-api";
|
|
1240
|
+
readonly URL: "url";
|
|
1241
|
+
}>;
|
|
1242
|
+
type SourceTypes = (typeof UploadSource)[keyof typeof UploadSource];
|
|
1243
|
+
|
|
1244
|
+
declare class LitUploaderBlock extends LitActivityBlock {
|
|
1245
|
+
static extSrcList: Readonly<typeof ExternalUploadSource>;
|
|
1246
|
+
static sourceTypes: Readonly<typeof UploadSource>;
|
|
1247
|
+
protected couldBeCtxOwner: boolean;
|
|
1248
|
+
private _isCtxOwner;
|
|
1249
|
+
private _unobserveCollection?;
|
|
1250
|
+
private _unobserveCollectionProperties?;
|
|
1251
|
+
init$: {
|
|
1252
|
+
'*commonProgress': number;
|
|
1253
|
+
'*uploadList': never[];
|
|
1254
|
+
'*uploadQueue': _uploadcare_upload_client.Queue;
|
|
1255
|
+
'*collectionErrors': OutputErrorCollection[];
|
|
1256
|
+
'*collectionState': OutputCollectionState | null;
|
|
1257
|
+
'*groupInfo': _uploadcare_upload_client.UploadcareGroup | null;
|
|
1258
|
+
'*uploadTrigger': Set<string>;
|
|
1259
|
+
'*currentActivity': null;
|
|
1260
|
+
'*currentActivityParams': {};
|
|
1261
|
+
'*history': never[];
|
|
1262
|
+
'*historyBack': null;
|
|
1263
|
+
'*closeModal': () => void;
|
|
1264
|
+
};
|
|
1265
|
+
private get _hasCtxOwner();
|
|
1266
|
+
initCallback(): void;
|
|
1267
|
+
getAPI(): UploaderPublicApi;
|
|
1268
|
+
get validationManager(): ValidationManager;
|
|
1269
|
+
get api(): UploaderPublicApi;
|
|
1270
|
+
get uploadCollection(): TypedCollection<UploadEntryData>;
|
|
1271
|
+
get secureUploadsManager(): SecureUploadsManager;
|
|
1272
|
+
disconnectedCallback(): void;
|
|
1273
|
+
connectedCallback(): void;
|
|
1274
|
+
private _initCtxOwner;
|
|
1275
|
+
private _observeUploadCollection;
|
|
1276
|
+
private _unobserveUploadCollection;
|
|
1277
|
+
private _createGroup;
|
|
1278
|
+
private _flushOutputItems;
|
|
1279
|
+
private _handleCollectionUpdate;
|
|
1280
|
+
private _handleCollectionPropertiesUpdate;
|
|
1281
|
+
private _flushCommonUploadProgress;
|
|
1282
|
+
private _setInitialCrop;
|
|
1283
|
+
protected getMetadataFor(entryId: string): Promise<_uploadcare_upload_client.Metadata | undefined>;
|
|
1284
|
+
protected getUploadClientOptions(): Promise<FileFromOptions>;
|
|
1285
|
+
getOutputData(): OutputFileEntry[];
|
|
1228
1286
|
}
|
|
1229
1287
|
|
|
1230
1288
|
type SelectOption = {
|
|
@@ -1247,7 +1305,6 @@ declare global {
|
|
|
1247
1305
|
type CameraMode = 'photo' | 'video';
|
|
1248
1306
|
declare class CameraSource extends LitUploaderBlock {
|
|
1249
1307
|
couldBeCtxOwner: boolean;
|
|
1250
|
-
activityType: "camera";
|
|
1251
1308
|
private _unsubPermissions;
|
|
1252
1309
|
private _capturing;
|
|
1253
1310
|
private _chunks;
|
|
@@ -1367,25 +1424,54 @@ declare global {
|
|
|
1367
1424
|
/**
|
|
1368
1425
|
* Config keys that can't be passed as attribute (because they are object or function)
|
|
1369
1426
|
*/
|
|
1370
|
-
declare const complexConfigKeys: readonly ["metadata", "localeDefinitionOverride", "secureUploadsSignatureResolver", "secureDeliveryProxyUrlResolver", "iconHrefResolver", "fileValidators", "collectionValidators", "mediaRecorderOptions"];
|
|
1371
|
-
/** Mapping of attribute names to state */
|
|
1372
|
-
declare const attrStateMapping: Record<string, string>;
|
|
1427
|
+
declare const complexConfigKeys: readonly ["metadata", "plugins", "localeDefinitionOverride", "secureUploadsSignatureResolver", "secureDeliveryProxyUrlResolver", "iconHrefResolver", "fileValidators", "collectionValidators", "mediaRecorderOptions"];
|
|
1373
1428
|
declare class Config extends LitBlock {
|
|
1374
1429
|
attributesMeta: Partial<ConfigPlainType> & {
|
|
1375
1430
|
'ctx-name': string;
|
|
1376
1431
|
};
|
|
1377
1432
|
init$: LitBlock["init$"] & ConfigType;
|
|
1378
1433
|
private _computationControllers;
|
|
1434
|
+
private _pluginChangeUnsubscribe?;
|
|
1435
|
+
private _mutationObserver?;
|
|
1436
|
+
/**
|
|
1437
|
+
* Mapping of attribute names to custom config keys for plugin-registered configs.
|
|
1438
|
+
* Updated dynamically when plugins are registered or changed.
|
|
1439
|
+
* Similar to builtinAttrKeyMapping but for custom configs.
|
|
1440
|
+
*/
|
|
1441
|
+
private _customAttrKeyMapping;
|
|
1442
|
+
/** Set of all custom config names registered by plugins */
|
|
1443
|
+
private _customConfigKeys;
|
|
1444
|
+
/**
|
|
1445
|
+
* Map of custom config subscriptions (config name -> unsubscribe function)
|
|
1446
|
+
* Used to track and clean up subscriptions when plugins change
|
|
1447
|
+
*/
|
|
1448
|
+
private _customConfigSubscriptions;
|
|
1449
|
+
/**
|
|
1450
|
+
* Check if a key is a custom config (registered by plugins)
|
|
1451
|
+
*/
|
|
1452
|
+
private _isCustomConfig;
|
|
1453
|
+
/**
|
|
1454
|
+
* Get the custom config definition for a key
|
|
1455
|
+
*/
|
|
1456
|
+
private _getCustomConfigDefinition;
|
|
1457
|
+
/**
|
|
1458
|
+
* Get attribute names for a config key (kebab-case and lowercase)
|
|
1459
|
+
*/
|
|
1460
|
+
private _getAttributeNames;
|
|
1379
1461
|
private _flushValueToAttribute;
|
|
1380
1462
|
private _flushValueToState;
|
|
1381
1463
|
private _setValue;
|
|
1382
1464
|
private _getValue;
|
|
1383
1465
|
private _assertSameValueDifferentReference;
|
|
1466
|
+
private _processCustomConfigs;
|
|
1467
|
+
private _setupCustomConfigs;
|
|
1468
|
+
private _setupMutationObserver;
|
|
1384
1469
|
initCallback(): void;
|
|
1385
|
-
attributeChangedCallback(name:
|
|
1470
|
+
attributeChangedCallback(name: string, oldVal: string, newVal: string): void;
|
|
1471
|
+
disconnectedCallback(): void;
|
|
1386
1472
|
static get observedAttributes(): string[];
|
|
1387
1473
|
}
|
|
1388
|
-
interface Config extends ConfigType {
|
|
1474
|
+
interface Config extends ConfigType, CustomConfig {
|
|
1389
1475
|
}
|
|
1390
1476
|
declare global {
|
|
1391
1477
|
interface HTMLElementTagNameMap {
|
|
@@ -1469,12 +1555,12 @@ declare class FileItem extends FileItemConfig {
|
|
|
1469
1555
|
private _isFailed;
|
|
1470
1556
|
private _isUploading;
|
|
1471
1557
|
private _isFocused;
|
|
1472
|
-
private _isEditable;
|
|
1473
1558
|
private _showFileNames;
|
|
1474
1559
|
private _ariaLabelStatusFile;
|
|
1560
|
+
private _pluginFileActions;
|
|
1475
1561
|
private _renderedOnce;
|
|
1476
1562
|
private _observer?;
|
|
1477
|
-
private
|
|
1563
|
+
private _unsubscribePlugins?;
|
|
1478
1564
|
private _handleRemove;
|
|
1479
1565
|
private _handleUploadClick;
|
|
1480
1566
|
private _calculateState;
|
|
@@ -1486,6 +1572,8 @@ declare class FileItem extends FileItemConfig {
|
|
|
1486
1572
|
private _handleEntryId;
|
|
1487
1573
|
private _updateShowFileNames;
|
|
1488
1574
|
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
1575
|
+
private _updatePluginFileActions;
|
|
1576
|
+
private _handlePluginFileAction;
|
|
1489
1577
|
initCallback(): void;
|
|
1490
1578
|
connectedCallback(): void;
|
|
1491
1579
|
disconnectedCallback(): void;
|
|
@@ -1794,6 +1882,10 @@ type ConfigType = {
|
|
|
1794
1882
|
* Expiry threshold for secure uploads.
|
|
1795
1883
|
*/
|
|
1796
1884
|
secureUploadsExpireThreshold: number;
|
|
1885
|
+
/**
|
|
1886
|
+
* Array of plugins to register with the uploader instance.
|
|
1887
|
+
*/
|
|
1888
|
+
plugins: UploaderPlugin[];
|
|
1797
1889
|
/**
|
|
1798
1890
|
* Metadata for the file.
|
|
1799
1891
|
*/
|
|
@@ -2054,10 +2146,237 @@ type OutputCollectionState<TStatus extends OutputCollectionStatus = OutputCollec
|
|
|
2054
2146
|
allEntries: OutputFileEntry[];
|
|
2055
2147
|
});
|
|
2056
2148
|
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2149
|
+
type PluginIconRegistration = {
|
|
2150
|
+
name: string;
|
|
2151
|
+
svg: string;
|
|
2152
|
+
};
|
|
2153
|
+
type PluginI18nRegistration = Record<string, Record<string, string>>;
|
|
2154
|
+
type PluginSourceRegistration = {
|
|
2155
|
+
id: string;
|
|
2156
|
+
label: string;
|
|
2157
|
+
icon?: string;
|
|
2158
|
+
/**
|
|
2159
|
+
* @internal
|
|
2160
|
+
*
|
|
2161
|
+
* Optional expansion function. When present, SourceList calls this to determine
|
|
2162
|
+
* which source IDs should actually be rendered in place of this source.
|
|
2163
|
+
* Useful for sources that map to multiple device-specific variants (e.g. camera
|
|
2164
|
+
* expanding to separate photo/video buttons on mobile).
|
|
2165
|
+
* Return `[id]` (the source's own id) to render it as-is.
|
|
2166
|
+
*/
|
|
2167
|
+
expand?: () => string[];
|
|
2168
|
+
onSelect: () => Promise<void> | void;
|
|
2169
|
+
};
|
|
2170
|
+
type PluginRenderDispose = () => void;
|
|
2171
|
+
type PluginRender = (el: HTMLElement, activityParams: Record<string, unknown>) => PluginRenderDispose | undefined;
|
|
2172
|
+
type PluginActivityRegistration = {
|
|
2173
|
+
id: string;
|
|
2174
|
+
render: PluginRender;
|
|
2175
|
+
};
|
|
2176
|
+
type PluginFileActionRegistration = {
|
|
2177
|
+
/** Unique action identifier. */
|
|
2178
|
+
id: string;
|
|
2179
|
+
/** Icon name to display in the action button. */
|
|
2180
|
+
icon: string;
|
|
2181
|
+
/** Label shown next to the icon in the action button. Accepts a plain string or an i18n key registered via `registerI18n`. */
|
|
2182
|
+
label: string;
|
|
2183
|
+
/** Return `true` to show the action button for the given file entry. */
|
|
2184
|
+
shouldRender: (fileEntry: OutputFileEntry) => boolean;
|
|
2185
|
+
onClick: (fileEntry: OutputFileEntry) => void | Promise<void>;
|
|
2186
|
+
};
|
|
2187
|
+
type PluginFileHookResult = {
|
|
2188
|
+
/** The (optionally transformed) file */
|
|
2189
|
+
file: File | Blob;
|
|
2190
|
+
};
|
|
2191
|
+
type PluginFileHookContext = PluginFileHookResult & {
|
|
2192
|
+
/**
|
|
2193
|
+
* An AbortSignal that fires when the operation is cancelled (e.g. upload aborted or file removed).
|
|
2194
|
+
* Hooks should respect this signal to avoid doing unnecessary work.
|
|
2195
|
+
*/
|
|
2196
|
+
signal: AbortSignal;
|
|
2197
|
+
};
|
|
2198
|
+
type PluginFileHookRegistration = {
|
|
2199
|
+
/**
|
|
2200
|
+
* When the hook is called:
|
|
2201
|
+
* - `'beforeUpload'`: called right before the file is uploaded.
|
|
2202
|
+
* - `'onAdd'`: called after the file is added to the upload list.
|
|
2203
|
+
*
|
|
2204
|
+
* Return the (optionally transformed) file. After the hook runs, `mimeType`,
|
|
2205
|
+
* `isImage`, `fileSize`, and `fileName` are all re-derived from the returned file.
|
|
2206
|
+
*/
|
|
2207
|
+
type: 'beforeUpload' | 'onAdd';
|
|
2208
|
+
handler: (context: PluginFileHookContext) => PluginFileHookResult | Promise<PluginFileHookResult>;
|
|
2209
|
+
/**
|
|
2210
|
+
* Maximum time in milliseconds to wait for the hook to complete before skipping it.
|
|
2211
|
+
* @default 30000
|
|
2212
|
+
*/
|
|
2213
|
+
timeout?: number;
|
|
2214
|
+
};
|
|
2215
|
+
type PluginRegistryApi = {
|
|
2216
|
+
registerSource: (source: PluginSourceRegistration) => void;
|
|
2217
|
+
registerActivity: (activity: PluginActivityRegistration) => void;
|
|
2218
|
+
registerFileAction: (fileAction: PluginFileActionRegistration) => void;
|
|
2219
|
+
registerFileHook: (hook: PluginFileHookRegistration) => void;
|
|
2220
|
+
registerIcon: (icon: PluginIconRegistration) => void;
|
|
2221
|
+
registerI18n: (i18n: PluginI18nRegistration) => void;
|
|
2222
|
+
registerConfig: <T = unknown>(definition: CustomConfigDefinition<T>) => void;
|
|
2223
|
+
};
|
|
2224
|
+
/**
|
|
2225
|
+
* API for managing plugin config subscriptions
|
|
2226
|
+
*/
|
|
2227
|
+
type PluginConfigApi = {
|
|
2228
|
+
get: <TKey extends keyof (ConfigType & CustomConfig)>(configName: TKey) => (ConfigType & CustomConfig)[TKey];
|
|
2229
|
+
subscribe: <TKey extends keyof (ConfigType & CustomConfig)>(configName: TKey, callback: (value: (ConfigType & CustomConfig)[TKey]) => void) => () => void;
|
|
2230
|
+
};
|
|
2231
|
+
/**
|
|
2232
|
+
* API for managing plugin activity interactions
|
|
2233
|
+
*/
|
|
2234
|
+
type PluginActivityApi = {
|
|
2235
|
+
/**
|
|
2236
|
+
* Get the current activity parameters.
|
|
2237
|
+
*
|
|
2238
|
+
* @returns The current activity parameters object
|
|
2239
|
+
*
|
|
2240
|
+
* @example
|
|
2241
|
+
* ```typescript
|
|
2242
|
+
* const params = pluginApi.activity.getParams();
|
|
2243
|
+
* console.log('Current params:', params);
|
|
2244
|
+
* ```
|
|
2245
|
+
*/
|
|
2246
|
+
getParams: () => Record<string, unknown>;
|
|
2247
|
+
/**
|
|
2248
|
+
* Subscribe to changes in activity parameters.
|
|
2249
|
+
* The callback will be called immediately with the current params,
|
|
2250
|
+
* and then whenever the params change.
|
|
2251
|
+
*
|
|
2252
|
+
* Subscriptions are automatically cleaned up when the plugin is disposed.
|
|
2253
|
+
*
|
|
2254
|
+
* @param callback - Function to call with the new params
|
|
2255
|
+
* @returns Unsubscribe function
|
|
2256
|
+
*
|
|
2257
|
+
* @example
|
|
2258
|
+
* ```typescript
|
|
2259
|
+
* pluginApi.activity.subscribeToParams((params) => {
|
|
2260
|
+
* console.log('Activity params changed:', params);
|
|
2261
|
+
* });
|
|
2262
|
+
* // Cleanup happens automatically on plugin disposal
|
|
2263
|
+
* ```
|
|
2264
|
+
*/
|
|
2265
|
+
subscribeToParams: (callback: (params: Record<string, unknown>) => void) => () => void;
|
|
2266
|
+
};
|
|
2267
|
+
type PluginFileEntryUpdate = {
|
|
2268
|
+
file?: File | Blob;
|
|
2269
|
+
cdnUrl?: string | null;
|
|
2270
|
+
cdnUrlModifiers?: string | null;
|
|
2271
|
+
mimeType?: string | null;
|
|
2272
|
+
};
|
|
2273
|
+
type PluginFilesApi = {
|
|
2274
|
+
/**
|
|
2275
|
+
* Update mutable properties of a file entry by its internalId.
|
|
2276
|
+
* `fileSize` is recalculated automatically when `file` is provided.
|
|
2277
|
+
*/
|
|
2278
|
+
update: (internalId: string, changes: PluginFileEntryUpdate) => void;
|
|
2279
|
+
};
|
|
2280
|
+
type PluginApi = {
|
|
2281
|
+
registry: PluginRegistryApi;
|
|
2282
|
+
config: PluginConfigApi;
|
|
2283
|
+
activity: PluginActivityApi;
|
|
2284
|
+
files: PluginFilesApi;
|
|
2285
|
+
};
|
|
2286
|
+
type PluginUploaderApi = UploaderPublicApi;
|
|
2287
|
+
type PluginSetupResult = (() => void) | void | Promise<(() => void) | void>;
|
|
2288
|
+
type PluginSetupParams = {
|
|
2289
|
+
pluginApi: PluginApi;
|
|
2290
|
+
uploaderApi: PluginUploaderApi;
|
|
2291
|
+
};
|
|
2292
|
+
type UploaderPlugin = {
|
|
2293
|
+
id: string;
|
|
2294
|
+
setup: (params: PluginSetupParams) => PluginSetupResult;
|
|
2295
|
+
};
|
|
2296
|
+
type Owned<T> = T & {
|
|
2297
|
+
pluginId: string;
|
|
2298
|
+
};
|
|
2299
|
+
type PluginRegistrySnapshot = {
|
|
2300
|
+
sources: Owned<PluginSourceRegistration>[];
|
|
2301
|
+
activities: Owned<PluginActivityRegistration>[];
|
|
2302
|
+
fileActions: Owned<PluginFileActionRegistration>[];
|
|
2303
|
+
fileHooks: Owned<PluginFileHookRegistration>[];
|
|
2304
|
+
icons: Owned<PluginIconRegistration>[];
|
|
2305
|
+
i18n: Owned<PluginI18nRegistration>[];
|
|
2306
|
+
};
|
|
2307
|
+
|
|
2308
|
+
type EventMap = {
|
|
2309
|
+
[T in keyof EventPayload]: CustomEvent<EventPayload[T]>;
|
|
2310
|
+
};
|
|
2311
|
+
|
|
2312
|
+
interface UploadEntryData extends Record<string, unknown> {
|
|
2313
|
+
file: File | null;
|
|
2314
|
+
externalUrl: string | null;
|
|
2315
|
+
fileName: string | null;
|
|
2316
|
+
fileSize: number | null;
|
|
2317
|
+
lastModified: number;
|
|
2318
|
+
uploadProgress: number;
|
|
2319
|
+
uuid: string | null;
|
|
2320
|
+
isImage: boolean;
|
|
2321
|
+
mimeType: string | null;
|
|
2322
|
+
ctxName: string | null;
|
|
2323
|
+
cdnUrl: string | null;
|
|
2324
|
+
cdnUrlModifiers: string | null;
|
|
2325
|
+
fileInfo: UploadcareFile | null;
|
|
2326
|
+
isUploading: boolean;
|
|
2327
|
+
abortController: AbortController | null;
|
|
2328
|
+
thumbUrl: string | null;
|
|
2329
|
+
silent: boolean;
|
|
2330
|
+
source: string | null;
|
|
2331
|
+
fullPath: string | null;
|
|
2332
|
+
metadata: Metadata | null;
|
|
2333
|
+
errors: OutputErrorFile[];
|
|
2334
|
+
uploadError: Error | null;
|
|
2335
|
+
isRemoved: boolean;
|
|
2336
|
+
isQueuedForUploading: boolean;
|
|
2337
|
+
isValidationPending: boolean;
|
|
2338
|
+
isQueuedForValidation: boolean;
|
|
2339
|
+
}
|
|
2340
|
+
type UploadEntryTypedData = TypedData<UploadEntryData>;
|
|
2341
|
+
type UploadEntryKeys = keyof UploadEntryData;
|
|
2342
|
+
|
|
2343
|
+
declare class PluginRegistry {
|
|
2344
|
+
private _sources;
|
|
2345
|
+
private _activities;
|
|
2346
|
+
private _fileActions;
|
|
2347
|
+
private _fileHooks;
|
|
2348
|
+
private _icons;
|
|
2349
|
+
private _i18n;
|
|
2350
|
+
readonly config: CustomConfigRegistry;
|
|
2351
|
+
private _own;
|
|
2352
|
+
addSource(pluginId: string, item: PluginSourceRegistration): void;
|
|
2353
|
+
addActivity(pluginId: string, item: PluginActivityRegistration): void;
|
|
2354
|
+
addFileAction(pluginId: string, item: PluginFileActionRegistration): void;
|
|
2355
|
+
addFileHook(pluginId: string, item: PluginFileHookRegistration): void;
|
|
2356
|
+
addIcon(pluginId: string, item: PluginIconRegistration): void;
|
|
2357
|
+
addI18n(pluginId: string, item: PluginI18nRegistration): void;
|
|
2358
|
+
addConfig<T>(pluginId: string, definition: CustomConfigDefinition<T>): void;
|
|
2359
|
+
purge(pluginId: string): void;
|
|
2360
|
+
snapshot(): PluginRegistrySnapshot;
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
declare class PluginManager extends SharedInstance {
|
|
2364
|
+
private _plugins;
|
|
2365
|
+
private _subscribers;
|
|
2366
|
+
private _pluginsUpdate;
|
|
2367
|
+
private _lazyPluginLoader;
|
|
2368
|
+
readonly registry: PluginRegistry;
|
|
2369
|
+
get configRegistry(): CustomConfigRegistry;
|
|
2370
|
+
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
2371
|
+
pluginsReady(): Promise<void>;
|
|
2372
|
+
onPluginsChange(callback: Unsubscriber): Unsubscriber;
|
|
2373
|
+
private _syncPlugins;
|
|
2374
|
+
private _registerPlugin;
|
|
2375
|
+
private _unregisterPlugin;
|
|
2376
|
+
snapshot(): PluginRegistrySnapshot;
|
|
2377
|
+
runOnAddHooks(entry: UploadEntryTypedData): Promise<void>;
|
|
2060
2378
|
destroy(): void;
|
|
2379
|
+
private _notifySubscribers;
|
|
2061
2380
|
}
|
|
2062
2381
|
|
|
2063
2382
|
type CommonEventType = InternalEventKey | EventKey;
|
|
@@ -2098,14 +2417,87 @@ declare class TelemetryManager extends SharedInstance {
|
|
|
2098
2417
|
private get _location();
|
|
2099
2418
|
}
|
|
2100
2419
|
|
|
2420
|
+
interface ISharedInstance {
|
|
2421
|
+
destroy?(): void;
|
|
2422
|
+
}
|
|
2423
|
+
declare class SharedInstance {
|
|
2424
|
+
protected _ctx: PubSub<SharedState>;
|
|
2425
|
+
protected _sharedInstancesBag: SharedInstancesBag;
|
|
2426
|
+
private _subscriptions;
|
|
2427
|
+
private _cfgProxy;
|
|
2428
|
+
protected _debugPrint: (...args: unknown[]) => void;
|
|
2429
|
+
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
2430
|
+
protected addSub(unsub: () => void): void;
|
|
2431
|
+
protected get _cfg(): Readonly<ConfigType>;
|
|
2432
|
+
destroy(): void;
|
|
2433
|
+
}
|
|
2434
|
+
declare const instanceKeyMap: {
|
|
2435
|
+
modalManager: "*modalManager";
|
|
2436
|
+
pluginManager: "*pluginManager";
|
|
2437
|
+
telemetryManager: "*telemetryManager";
|
|
2438
|
+
localeManager: "*localeManager";
|
|
2439
|
+
a11y: "*a11y";
|
|
2440
|
+
clipboard: "*clipboard";
|
|
2441
|
+
blocksRegistry: "*blocksRegistry";
|
|
2442
|
+
eventEmitter: "*eventEmitter";
|
|
2443
|
+
uploadCollection: "*uploadCollection";
|
|
2444
|
+
secureUploadsManager: "*secureUploadsManager";
|
|
2445
|
+
api: "*publicApi";
|
|
2446
|
+
validationManager: "*validationManager";
|
|
2447
|
+
};
|
|
2448
|
+
type InstanceTypeMap = {
|
|
2449
|
+
[key in keyof typeof instanceKeyMap]: SharedState[(typeof instanceKeyMap)[key]];
|
|
2450
|
+
};
|
|
2451
|
+
type InstanceName = keyof typeof instanceKeyMap;
|
|
2452
|
+
type SharedInstancesState = Pick<SharedState, (typeof instanceKeyMap)[keyof typeof instanceKeyMap]>;
|
|
2453
|
+
type SharedInstancesBag = ReturnType<typeof createSharedInstancesBag>;
|
|
2454
|
+
declare const createSharedInstancesBag: (getCtx: () => PubSub<SharedState>) => {
|
|
2455
|
+
readonly ctx: PubSub<SharedState>;
|
|
2456
|
+
readonly modalManager: ModalManager | null;
|
|
2457
|
+
readonly pluginManager: PluginManager;
|
|
2458
|
+
readonly telemetryManager: TelemetryManager;
|
|
2459
|
+
readonly localeManager: LocaleManager;
|
|
2460
|
+
readonly a11y: A11y;
|
|
2461
|
+
readonly blocksRegistry: Set<LitBlock>;
|
|
2462
|
+
readonly eventEmitter: EventEmitter;
|
|
2463
|
+
readonly uploadCollection: TypedCollection<UploadEntryData>;
|
|
2464
|
+
readonly secureUploadsManager: SecureUploadsManager;
|
|
2465
|
+
readonly api: UploaderPublicApi;
|
|
2466
|
+
readonly validationManager: ValidationManager;
|
|
2467
|
+
when<TName extends InstanceName>(name: TName, callback: (instance: NonNullable<InstanceTypeMap[TName]>) => void): () => void;
|
|
2468
|
+
wait<TName extends InstanceName>(name: TName): Promise<NonNullable<InstanceTypeMap[TName]>>;
|
|
2469
|
+
};
|
|
2470
|
+
|
|
2471
|
+
type PasteScope = 'local' | 'global' | false;
|
|
2472
|
+
declare class ClipboardLayer extends SharedInstance {
|
|
2473
|
+
private scopes;
|
|
2474
|
+
private listener;
|
|
2475
|
+
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
2476
|
+
private openUploadList;
|
|
2477
|
+
private _listener;
|
|
2478
|
+
private handlePaste;
|
|
2479
|
+
registerBlock(scope: Node): () => void;
|
|
2480
|
+
destroy(): void;
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2483
|
+
type ConfigGetter = <K extends keyof ConfigType>(key: K) => ConfigType[K];
|
|
2484
|
+
type LazyPluginEntry = {
|
|
2485
|
+
configDeps: readonly (keyof ConfigType)[];
|
|
2486
|
+
isEnabled: (get: ConfigGetter) => boolean;
|
|
2487
|
+
load: () => UploaderPlugin | undefined | Promise<UploaderPlugin | undefined>;
|
|
2488
|
+
};
|
|
2489
|
+
|
|
2101
2490
|
type SharedConfigState = {
|
|
2102
2491
|
[K in keyof ConfigType as `*cfg/${K}`]: ConfigType[K];
|
|
2103
2492
|
};
|
|
2493
|
+
type SharedCustomConfigState = {
|
|
2494
|
+
[K in keyof CustomConfig as `*cfg/${K}`]: CustomConfig[K];
|
|
2495
|
+
};
|
|
2104
2496
|
type BlocksRegistry = Set<LitBlock>;
|
|
2105
2497
|
type ActivityBlockCtxState = {
|
|
2106
|
-
'*currentActivity':
|
|
2498
|
+
'*currentActivity': RegisteredActivityType | null;
|
|
2107
2499
|
'*currentActivityParams': Record<string, unknown>;
|
|
2108
|
-
'*history': (
|
|
2500
|
+
'*history': (RegisteredActivityType | null)[];
|
|
2109
2501
|
'*historyBack': (() => void) | null;
|
|
2110
2502
|
'*closeModal': () => void;
|
|
2111
2503
|
};
|
|
@@ -2122,6 +2514,7 @@ type UploaderBlockCtxState = ActivityBlockCtxState & {
|
|
|
2122
2514
|
};
|
|
2123
2515
|
type SolutionBlockCtxState = UploaderBlockCtxState & {
|
|
2124
2516
|
'*solution': string | null;
|
|
2517
|
+
'*lazyPlugins': LazyPluginEntry[] | null;
|
|
2125
2518
|
};
|
|
2126
2519
|
type CloudImageEditorState = {
|
|
2127
2520
|
'*originalUrl': string | null;
|
|
@@ -2172,7 +2565,9 @@ type EditorToolbarState = {
|
|
|
2172
2565
|
'*currentOperation': string | null;
|
|
2173
2566
|
'*operationTooltip': string | null;
|
|
2174
2567
|
};
|
|
2568
|
+
type SharedContextInstances = Map<string, ISharedInstance>;
|
|
2175
2569
|
type DynamicBlockState = {
|
|
2570
|
+
'*sharedContextInstances': SharedContextInstances;
|
|
2176
2571
|
'*blocksRegistry': BlocksRegistry;
|
|
2177
2572
|
'*eventEmitter': EventEmitter;
|
|
2178
2573
|
'*localeManager': LocaleManager;
|
|
@@ -2180,6 +2575,7 @@ type DynamicBlockState = {
|
|
|
2180
2575
|
'*a11y': A11y;
|
|
2181
2576
|
'*modalManager': ModalManager | null;
|
|
2182
2577
|
'*clipboard': ClipboardLayer;
|
|
2578
|
+
'*pluginManager': PluginManager;
|
|
2183
2579
|
};
|
|
2184
2580
|
type DynamicUploaderBlockState = {
|
|
2185
2581
|
'*uploadCollection': TypedCollection<UploadEntryData>;
|
|
@@ -2190,66 +2586,7 @@ type DynamicUploaderBlockState = {
|
|
|
2190
2586
|
type LocaleState = {
|
|
2191
2587
|
[K in keyof LocaleDefinition as `*l10n/${K}`]: string;
|
|
2192
2588
|
};
|
|
2193
|
-
type SharedState = SolutionBlockCtxState & SharedConfigState & CloudImageEditorState & EditorImageCropperState & EditorToolbarState & DynamicBlockState & DynamicUploaderBlockState & LocaleState;
|
|
2194
|
-
|
|
2195
|
-
interface ISharedInstance {
|
|
2196
|
-
destroy?(): void;
|
|
2197
|
-
}
|
|
2198
|
-
declare class SharedInstance {
|
|
2199
|
-
protected _ctx: PubSub<SharedState>;
|
|
2200
|
-
protected _sharedInstancesBag: SharedInstancesBag;
|
|
2201
|
-
private _subscriptions;
|
|
2202
|
-
private _cfgProxy;
|
|
2203
|
-
protected _debugPrint: (...args: unknown[]) => void;
|
|
2204
|
-
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
2205
|
-
protected addSub(unsub: () => void): void;
|
|
2206
|
-
protected get _cfg(): Readonly<ConfigType>;
|
|
2207
|
-
destroy(): void;
|
|
2208
|
-
}
|
|
2209
|
-
type SharedInstancesState = Pick<SharedState, '*blocksRegistry' | '*eventEmitter' | '*localeManager' | '*telemetryManager' | '*a11y' | '*clipboard' | '*modalManager' | '*uploadCollection' | '*publicApi' | '*validationManager' | '*secureUploadsManager'>;
|
|
2210
|
-
type SharedInstancesBag = ReturnType<typeof createSharedInstancesBag>;
|
|
2211
|
-
declare const createSharedInstancesBag: (getCtx: () => PubSub<SharedState>) => {
|
|
2212
|
-
readonly ctx: PubSub<SharedState>;
|
|
2213
|
-
readonly modalManager: ModalManager | null;
|
|
2214
|
-
readonly telemetryManager: TelemetryManager;
|
|
2215
|
-
readonly localeManager: LocaleManager;
|
|
2216
|
-
readonly a11y: A11y;
|
|
2217
|
-
readonly blocksRegistry: Set<LitBlock>;
|
|
2218
|
-
readonly eventEmitter: EventEmitter;
|
|
2219
|
-
readonly uploadCollection: TypedCollection<UploadEntryData>;
|
|
2220
|
-
readonly secureUploadsManager: SecureUploadsManager;
|
|
2221
|
-
readonly api: UploaderPublicApi;
|
|
2222
|
-
readonly validationManager: ValidationManager;
|
|
2223
|
-
};
|
|
2224
|
-
|
|
2225
|
-
type FuncFileValidator = (outputEntry: OutputFileEntry, api: UploaderPublicApi, options?: {
|
|
2226
|
-
signal?: AbortSignal;
|
|
2227
|
-
}) => undefined | OutputErrorFile | Promise<undefined | OutputErrorFile>;
|
|
2228
|
-
type FileValidatorDescriptor = {
|
|
2229
|
-
runOn: 'add' | 'upload' | 'change';
|
|
2230
|
-
validator: FuncFileValidator;
|
|
2231
|
-
};
|
|
2232
|
-
type FileValidator = FileValidatorDescriptor | FuncFileValidator;
|
|
2233
|
-
type FuncCollectionValidator = (collection: ReturnType<typeof buildOutputCollectionState<OutputCollectionStatus>>, api: UploaderPublicApi) => undefined | OutputErrorCollection;
|
|
2234
|
-
declare class ValidationManager extends SharedInstance {
|
|
2235
|
-
private get _uploadCollection();
|
|
2236
|
-
private _commonFileValidators;
|
|
2237
|
-
private _commonCollectionValidators;
|
|
2238
|
-
private _queue;
|
|
2239
|
-
private _runQueueDebounced;
|
|
2240
|
-
private _isDestroyed;
|
|
2241
|
-
private _entryValidationState;
|
|
2242
|
-
constructor(sharedInstancesBag: SharedInstancesBag);
|
|
2243
|
-
runFileValidators(runOn: FileValidatorDescriptor['runOn'], entryIds?: Uid[]): void;
|
|
2244
|
-
runCollectionValidators(): void;
|
|
2245
|
-
cleanupValidationForEntry(entry: TypedData<UploadEntryData>): void;
|
|
2246
|
-
private _runFileValidatorsForEntry;
|
|
2247
|
-
private _addCustomTypeToValidationError;
|
|
2248
|
-
private _getEntryValidationState;
|
|
2249
|
-
private _getValidatorDescriptors;
|
|
2250
|
-
private _getValidatorDescriptorsForEntry;
|
|
2251
|
-
destroy(): void;
|
|
2252
|
-
}
|
|
2589
|
+
type SharedState = SolutionBlockCtxState & SharedConfigState & SharedCustomConfigState & CloudImageEditorState & EditorImageCropperState & EditorToolbarState & DynamicBlockState & DynamicUploaderBlockState & LocaleState;
|
|
2253
2590
|
|
|
2254
2591
|
declare const LitBlockBase: typeof LitElement & Constructor<{
|
|
2255
2592
|
willYield: boolean;
|
|
@@ -2261,9 +2598,7 @@ declare const LitBlockBase: typeof LitElement & Constructor<{
|
|
|
2261
2598
|
};
|
|
2262
2599
|
declare class LitBlock extends LitBlockBase {
|
|
2263
2600
|
private _cfgProxy;
|
|
2264
|
-
protected _sharedContextInstances: Map<keyof SharedInstancesState, ISharedInstance>;
|
|
2265
2601
|
static styleAttrs: string[];
|
|
2266
|
-
activityType: ActivityType;
|
|
2267
2602
|
init$: {};
|
|
2268
2603
|
constructor();
|
|
2269
2604
|
l10n: (str: string, variables?: Record<string, string | number>) => string;
|
|
@@ -2271,6 +2606,7 @@ declare class LitBlock extends LitBlockBase {
|
|
|
2271
2606
|
protected _sharedInstancesBag: {
|
|
2272
2607
|
readonly ctx: PubSub<SharedState>;
|
|
2273
2608
|
readonly modalManager: ModalManager | null;
|
|
2609
|
+
readonly pluginManager: PluginManager;
|
|
2274
2610
|
readonly telemetryManager: TelemetryManager;
|
|
2275
2611
|
readonly localeManager: LocaleManager;
|
|
2276
2612
|
readonly a11y: A11y;
|
|
@@ -2280,6 +2616,34 @@ declare class LitBlock extends LitBlockBase {
|
|
|
2280
2616
|
readonly secureUploadsManager: SecureUploadsManager;
|
|
2281
2617
|
readonly api: UploaderPublicApi;
|
|
2282
2618
|
readonly validationManager: ValidationManager;
|
|
2619
|
+
when<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "api" | "validationManager">(name: TName, callback: (instance: NonNullable<{
|
|
2620
|
+
modalManager: ModalManager | null;
|
|
2621
|
+
pluginManager: PluginManager;
|
|
2622
|
+
telemetryManager: TelemetryManager;
|
|
2623
|
+
localeManager: LocaleManager;
|
|
2624
|
+
a11y: A11y;
|
|
2625
|
+
clipboard: ClipboardLayer;
|
|
2626
|
+
blocksRegistry: BlocksRegistry;
|
|
2627
|
+
eventEmitter: EventEmitter;
|
|
2628
|
+
uploadCollection: TypedCollection<UploadEntryData>;
|
|
2629
|
+
secureUploadsManager: SecureUploadsManager;
|
|
2630
|
+
api: UploaderPublicApi;
|
|
2631
|
+
validationManager: ValidationManager;
|
|
2632
|
+
}[TName]>) => void): () => void;
|
|
2633
|
+
wait<TName extends "modalManager" | "pluginManager" | "telemetryManager" | "localeManager" | "a11y" | "clipboard" | "blocksRegistry" | "eventEmitter" | "uploadCollection" | "secureUploadsManager" | "api" | "validationManager">(name: TName): Promise<NonNullable<{
|
|
2634
|
+
modalManager: ModalManager | null;
|
|
2635
|
+
pluginManager: PluginManager;
|
|
2636
|
+
telemetryManager: TelemetryManager;
|
|
2637
|
+
localeManager: LocaleManager;
|
|
2638
|
+
a11y: A11y;
|
|
2639
|
+
clipboard: ClipboardLayer;
|
|
2640
|
+
blocksRegistry: BlocksRegistry;
|
|
2641
|
+
eventEmitter: EventEmitter;
|
|
2642
|
+
uploadCollection: TypedCollection<UploadEntryData>;
|
|
2643
|
+
secureUploadsManager: SecureUploadsManager;
|
|
2644
|
+
api: UploaderPublicApi;
|
|
2645
|
+
validationManager: ValidationManager;
|
|
2646
|
+
}[TName]>>;
|
|
2283
2647
|
};
|
|
2284
2648
|
emit(type: Parameters<EventEmitter['emit']>[0], payload?: Parameters<EventEmitter['emit']>[1], options?: Parameters<EventEmitter['emit']>[2]): void;
|
|
2285
2649
|
hasBlockInCtx(callback: (block: LitBlock) => boolean): boolean;
|
|
@@ -2298,11 +2662,7 @@ declare class LitBlock extends LitBlockBase {
|
|
|
2298
2662
|
* Called when the last block is removed from the context. Note that inheritors must run their callback before that.
|
|
2299
2663
|
*/
|
|
2300
2664
|
private destroyCtxCallback;
|
|
2301
|
-
|
|
2302
|
-
* Adds a shared context instance if it does not exist yet.
|
|
2303
|
-
* @param key The shared state key.
|
|
2304
|
-
* @param resolver The resolver function that creates the instance.
|
|
2305
|
-
*/
|
|
2665
|
+
private _getSharedContextInstances;
|
|
2306
2666
|
protected _addSharedContextInstance<TKey extends keyof SharedInstancesState>(key: TKey, resolver: (sharedInstancesBag: SharedInstancesBag) => NonNullable<SharedInstancesState[TKey]>): void;
|
|
2307
2667
|
private _destroySharedContextInstances;
|
|
2308
2668
|
protected _getSharedContextInstance<TKey extends keyof SharedState, TRequired extends boolean = true>(key: TKey, isRequired?: TRequired): TRequired extends true ? NonNullable<SharedState[TKey]> : SharedState[TKey];
|
|
@@ -2329,7 +2689,7 @@ declare class Modal extends LitBlock {
|
|
|
2329
2689
|
private _handleDialogClose;
|
|
2330
2690
|
private _handleDialogMouseDown;
|
|
2331
2691
|
private _handleDialogMouseUp;
|
|
2332
|
-
show(): void
|
|
2692
|
+
show(): Promise<void>;
|
|
2333
2693
|
hide(): void;
|
|
2334
2694
|
private _handleModalOpen;
|
|
2335
2695
|
private _handleModalClose;
|
|
@@ -2401,8 +2761,10 @@ declare const toKebabCase: <T extends string>(str: T) => KebabCase<T>;
|
|
|
2401
2761
|
|
|
2402
2762
|
declare class LitSolutionBlock extends LitBlock {
|
|
2403
2763
|
static styleAttrs: string[];
|
|
2764
|
+
static lazyPlugins: LazyPluginEntry[] | null;
|
|
2404
2765
|
init$: {
|
|
2405
2766
|
'*solution': string | null;
|
|
2767
|
+
'*lazyPlugins': LazyPluginEntry[] | null;
|
|
2406
2768
|
'*commonProgress': number;
|
|
2407
2769
|
'*uploadList': never[];
|
|
2408
2770
|
'*uploadQueue': _uploadcare_upload_client.Queue;
|
|
@@ -2534,18 +2896,20 @@ declare global {
|
|
|
2534
2896
|
}
|
|
2535
2897
|
}
|
|
2536
2898
|
|
|
2899
|
+
type SourceButtonConfig = {
|
|
2900
|
+
id: string;
|
|
2901
|
+
label: string;
|
|
2902
|
+
icon?: string;
|
|
2903
|
+
onClick: () => void | Promise<void>;
|
|
2904
|
+
};
|
|
2537
2905
|
declare class SourceBtn extends LitUploaderBlock {
|
|
2538
2906
|
couldBeCtxOwner: boolean;
|
|
2539
|
-
|
|
2540
|
-
type?: string;
|
|
2907
|
+
source?: SourceButtonConfig;
|
|
2541
2908
|
private _iconName;
|
|
2542
2909
|
private _srcTypeKey;
|
|
2543
|
-
private _initTypes;
|
|
2544
|
-
initCallback(): void;
|
|
2545
|
-
private _registerType;
|
|
2546
|
-
activate(): void;
|
|
2547
|
-
private _applyType;
|
|
2548
2910
|
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
2911
|
+
private _applySource;
|
|
2912
|
+
activate(): void;
|
|
2549
2913
|
render(): lit_html.TemplateResult<1>;
|
|
2550
2914
|
}
|
|
2551
2915
|
declare global {
|
|
@@ -2554,9 +2918,10 @@ declare global {
|
|
|
2554
2918
|
}
|
|
2555
2919
|
}
|
|
2556
2920
|
|
|
2557
|
-
declare class SourceList extends
|
|
2921
|
+
declare class SourceList extends LitUploaderBlock {
|
|
2558
2922
|
private _rawSourceList;
|
|
2559
|
-
private
|
|
2923
|
+
private _unsubscribePlugins?;
|
|
2924
|
+
private _sources;
|
|
2560
2925
|
/**
|
|
2561
2926
|
* CSS-only attribute
|
|
2562
2927
|
*/
|
|
@@ -2564,8 +2929,10 @@ declare class SourceList extends LitBlock {
|
|
|
2564
2929
|
initCallback(): void;
|
|
2565
2930
|
protected updated(changedProperties: PropertyValues<this>): void;
|
|
2566
2931
|
private _updateSources;
|
|
2567
|
-
private
|
|
2932
|
+
private _expandSource;
|
|
2933
|
+
private _makePluginSourceConfig;
|
|
2568
2934
|
render(): lit_html.TemplateResult<1>;
|
|
2935
|
+
disconnectedCallback(): void;
|
|
2569
2936
|
}
|
|
2570
2937
|
declare global {
|
|
2571
2938
|
interface HTMLElementTagNameMap {
|
|
@@ -2629,38 +2996,65 @@ declare global {
|
|
|
2629
2996
|
}
|
|
2630
2997
|
}
|
|
2631
2998
|
|
|
2632
|
-
declare class
|
|
2999
|
+
declare class SimpleBtn extends LitUploaderBlock {
|
|
3000
|
+
static styleAttrs: string[];
|
|
2633
3001
|
couldBeCtxOwner: boolean;
|
|
2634
|
-
|
|
2635
|
-
private
|
|
3002
|
+
dropzone: boolean;
|
|
3003
|
+
private _buttonTextKey;
|
|
3004
|
+
private readonly _handleClick;
|
|
2636
3005
|
initCallback(): void;
|
|
2637
|
-
private _inputRef;
|
|
2638
|
-
private _handleInput;
|
|
2639
|
-
private _handleUpload;
|
|
2640
3006
|
render(): lit_html.TemplateResult<1>;
|
|
2641
3007
|
}
|
|
2642
3008
|
declare global {
|
|
2643
3009
|
interface HTMLElementTagNameMap {
|
|
2644
|
-
'uc-
|
|
3010
|
+
'uc-simple-btn': SimpleBtn;
|
|
2645
3011
|
}
|
|
2646
3012
|
}
|
|
2647
3013
|
|
|
2648
|
-
declare class
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
3014
|
+
declare class PluginActivityHost extends LitActivityBlock {
|
|
3015
|
+
registration: Owned<PluginActivityRegistration>;
|
|
3016
|
+
private _dispose?;
|
|
3017
|
+
private _containerRef;
|
|
3018
|
+
initCallback(): void;
|
|
3019
|
+
protected willUpdate(changedProperties: PropertyValues<this>): void;
|
|
3020
|
+
private _ensureRegistered;
|
|
3021
|
+
private _renderActivity;
|
|
3022
|
+
private _disposeActivity;
|
|
3023
|
+
disconnectedCallback(): void;
|
|
3024
|
+
render(): lit_html.TemplateResult<1>;
|
|
3025
|
+
}
|
|
3026
|
+
declare class PluginActivityRenderer extends LitBlock {
|
|
3027
|
+
mode: 'modal' | 'inline';
|
|
3028
|
+
private _activities;
|
|
3029
|
+
private _unsubscribePlugins?;
|
|
2654
3030
|
initCallback(): void;
|
|
3031
|
+
private _syncActivities;
|
|
3032
|
+
disconnectedCallback(): void;
|
|
2655
3033
|
render(): lit_html.TemplateResult<1>;
|
|
2656
3034
|
}
|
|
2657
3035
|
declare global {
|
|
2658
3036
|
interface HTMLElementTagNameMap {
|
|
2659
|
-
'uc-
|
|
3037
|
+
'uc-plugin-activity-host': PluginActivityHost;
|
|
3038
|
+
'uc-plugin-activity-renderer': PluginActivityRenderer;
|
|
3039
|
+
}
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
declare class UrlSource extends LitUploaderBlock {
|
|
3043
|
+
private _formState;
|
|
3044
|
+
private _inputRef;
|
|
3045
|
+
private _handleInput;
|
|
3046
|
+
private _handleUpload;
|
|
3047
|
+
firstUpdated(): void;
|
|
3048
|
+
render(): lit_html.TemplateResult<1>;
|
|
3049
|
+
}
|
|
3050
|
+
declare global {
|
|
3051
|
+
interface HTMLElementTagNameMap {
|
|
3052
|
+
'uc-url-source': UrlSource;
|
|
2660
3053
|
}
|
|
2661
3054
|
}
|
|
2662
3055
|
|
|
2663
3056
|
declare class FileUploaderRegular extends LitSolutionBlock {
|
|
3057
|
+
static lazyPlugins: LazyPluginEntry[];
|
|
2664
3058
|
attributesMeta: {
|
|
2665
3059
|
headless?: boolean;
|
|
2666
3060
|
'ctx-name': string;
|
|
@@ -2678,6 +3072,7 @@ declare global {
|
|
|
2678
3072
|
}
|
|
2679
3073
|
|
|
2680
3074
|
declare class FileUploaderInline extends LitSolutionBlock {
|
|
3075
|
+
static lazyPlugins: LazyPluginEntry[];
|
|
2681
3076
|
attributesMeta: {
|
|
2682
3077
|
'ctx-name': string;
|
|
2683
3078
|
};
|
|
@@ -2698,6 +3093,7 @@ declare global {
|
|
|
2698
3093
|
}
|
|
2699
3094
|
|
|
2700
3095
|
declare class FileUploaderMinimal extends LitSolutionBlock {
|
|
3096
|
+
static lazyPlugins: LazyPluginEntry[];
|
|
2701
3097
|
attributesMeta: {
|
|
2702
3098
|
'ctx-name': string;
|
|
2703
3099
|
};
|
|
@@ -2721,4 +3117,4 @@ declare global {
|
|
|
2721
3117
|
}
|
|
2722
3118
|
}
|
|
2723
3119
|
|
|
2724
|
-
export { LitActivityBlock as ActivityBlock, ActivityHeader, type ApiAddFileCommonOptions, BaseComponent, LitBlock as Block, BtnUi, CameraSource, CloudImageEditor, CloudImageEditorActivity, CloudImageEditorBlock, type CollectionValidators, Config, type ConfigAttributesType, type ConfigComplexType, type ConfigPlainType, type ConfigType, Copyright, CropFrame, PubSub as Data, DropArea, EditorAspectRatioButtonControl, EditorCropButtonControl, EditorFilterControl, EditorFreeformButtonControl, EditorImageCropper, EditorImageFader, EditorOperationControl, EditorScroller, EditorSlider, EditorToolbar, type EventMap, type EventPayload, EventType, ExternalSource, ExternalUploadSource, FileItem, FileUploaderInline, FileUploaderMinimal, FileUploaderRegular, type FileValidator, type FileValidatorDescriptor, type FileValidators, FormInput, type FuncCollectionValidator, type FuncFileValidator, type GroupFlag, Icon, type IconHrefResolver, Img, type KebabCase$1 as KebabCase, type KebabCaseKeys, LineLoaderUi, type LocaleDefinitionOverride, type LowerCase, type LowerCaseKeys, type MetadataCallback, Modal, ModalEvents, type ModalId, type OutputCollectionErrorType, type OutputCollectionState, type OutputCollectionStatus, type OutputCustomErrorType, type OutputError, type OutputErrorCollection, type OutputErrorFile, type OutputErrorTypePayload, type OutputFileEntry, type OutputFileErrorPayload, type OutputFileErrorType, type OutputFileStatus, PresenceToggle, ProgressBar, ProgressBarCommon, type SecureDeliveryProxyUrlResolver, type SecureUploadsSignatureAndExpire, type SecureUploadsSignatureResolver, Select, SimpleBtn, SliderUi, LitSolutionBlock as SolutionBlock, SourceBtn, SourceList, type SourceTypes, Spinner, StartFrom, Thumb, UID, UploadCtxProvider, UploadList, UploadSource, LitUploaderBlock as UploaderBlock, UploaderPublicApi, UrlSource, defineComponents, defineLocale, toKebabCase };
|
|
3120
|
+
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, 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, toKebabCase };
|