@uploadcare/ai-enhancer 0.1.1 → 0.1.3
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/README.md +102 -288
- package/dist/UcAiEnhancer-Co-HZ72E.cjs +444 -0
- package/dist/{UcAiEnhancer-D1z2-v9q.js → UcAiEnhancer-DK6rhHp7.js} +498 -489
- package/dist/ai-enhancer.cjs +1 -1
- package/dist/ai-enhancer.d.ts +73 -54
- package/dist/ai-enhancer.js +5 -3
- package/dist/errors.cjs +1 -0
- package/dist/errors.d.ts +81 -0
- package/dist/errors.js +8 -0
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +11 -3
- package/dist/UcAiEnhancer-D0mic9eT.cjs +0 -444
package/dist/ai-enhancer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./UcAiEnhancer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./UcAiEnhancer-Co-HZ72E.cjs"),r=require("./errors.cjs");Object.defineProperty(exports,"UcAiEnhancer",{enumerable:!0,get:()=>e.UcAiEnhancer});exports.enLocale=e.enLocale;exports.AiEnhancerError=r.AiEnhancerError;
|
package/dist/ai-enhancer.d.ts
CHANGED
|
@@ -13,6 +13,35 @@ import { UploadcareFile } from '@uploadcare/upload-client';
|
|
|
13
13
|
*/
|
|
14
14
|
export declare type AiEditorMode = 'generate' | 'edit';
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The one error type carried by `uc:error`'s `detail.error`. Every value
|
|
18
|
+
* thrown out of a generation/edit run is normalized into this class at the
|
|
19
|
+
* dispatch site; the original thrown value is always preserved on `.cause`.
|
|
20
|
+
* The UI maps `code` to a localized message (`ai-enhancer-error-<code>`).
|
|
21
|
+
*/
|
|
22
|
+
export declare class AiEnhancerError extends Error {
|
|
23
|
+
readonly code: AiEnhancerErrorCode;
|
|
24
|
+
readonly source?: string;
|
|
25
|
+
readonly cause?: unknown;
|
|
26
|
+
constructor(message: string, options?: AiEnhancerErrorOptions);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The known error codes (see {@link KNOWN_ERROR_CODES} in shared/lib), plus an
|
|
31
|
+
* escape hatch: the backend can introduce codes the frontend hasn't heard of,
|
|
32
|
+
* and frontend-originated failures use their own codes (e.g. the React
|
|
33
|
+
* wrapper's `engine_load_failed`).
|
|
34
|
+
*/
|
|
35
|
+
export declare type AiEnhancerErrorCode = KnownErrorCode | (string & {});
|
|
36
|
+
|
|
37
|
+
export declare type AiEnhancerErrorOptions = {
|
|
38
|
+
code?: AiEnhancerErrorCode;
|
|
39
|
+
/** Job/platform `error_source`, when the failure reports one. */
|
|
40
|
+
source?: string;
|
|
41
|
+
/** The original thrown value. */
|
|
42
|
+
cause?: unknown;
|
|
43
|
+
};
|
|
44
|
+
|
|
16
45
|
/**
|
|
17
46
|
* A locale's strings. Core keys are required; the per-error-code messages are
|
|
18
47
|
* optional (they fall back to English / the generic message), so translations
|
|
@@ -130,26 +159,26 @@ export declare type DoneDetail = {
|
|
|
130
159
|
};
|
|
131
160
|
|
|
132
161
|
export declare const enLocale: {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
162
|
+
"ai-enhancer-error-invalid_request": string;
|
|
163
|
+
"ai-enhancer-error-invalid_source": string;
|
|
164
|
+
"ai-enhancer-error-source_not_found": string;
|
|
165
|
+
"ai-enhancer-error-source_not_image": string;
|
|
166
|
+
"ai-enhancer-error-source_url_unavailable": string;
|
|
167
|
+
"ai-enhancer-error-invalid_aspect_ratio": string;
|
|
168
|
+
"ai-enhancer-error-canvas_too_large": string;
|
|
169
|
+
"ai-enhancer-error-canvas_dimension_too_small": string;
|
|
170
|
+
"ai-enhancer-error-source_extends_beyond_canvas": string;
|
|
171
|
+
"ai-enhancer-error-derivative_disabled": string;
|
|
172
|
+
"ai-enhancer-error-job_id_required": string;
|
|
173
|
+
"ai-enhancer-error-job_not_found": string;
|
|
174
|
+
"ai-enhancer-error-content_moderated": string;
|
|
175
|
+
"ai-enhancer-error-provider_unavailable": string;
|
|
176
|
+
"ai-enhancer-error-generation_timeout": string;
|
|
177
|
+
"ai-enhancer-error-invalid_input": string;
|
|
178
|
+
"ai-enhancer-error-RequestThrottledError": string;
|
|
179
|
+
"ai-enhancer-error-DownloadFileHTTPClientError": string;
|
|
180
|
+
"ai-enhancer-error-DownloadFileNotFoundError": string;
|
|
181
|
+
"ai-enhancer-error-DownloadFileTaskFailedError": string;
|
|
153
182
|
'ai-enhancer-source-label': string;
|
|
154
183
|
'ai-enhancer-file-action-label': string;
|
|
155
184
|
'ai-enhancer-generate-title': string;
|
|
@@ -176,34 +205,18 @@ export declare const enLocale: {
|
|
|
176
205
|
'ai-enhancer-aspect-widescreen': string;
|
|
177
206
|
};
|
|
178
207
|
|
|
208
|
+
/** Detail of the `uc:error` event: the normalized {@link AiEnhancerError}. */
|
|
209
|
+
export declare type ErrorDetail = {
|
|
210
|
+
error: AiEnhancerError;
|
|
211
|
+
};
|
|
212
|
+
|
|
179
213
|
/**
|
|
180
214
|
* Friendly messages for known platform/job `error_code`s, keyed
|
|
181
215
|
* `ai-enhancer-error-<code>`. The editor looks these up by code and falls back
|
|
182
216
|
* to the generic `ai-enhancer-error`. They're optional per locale (English here
|
|
183
217
|
* is the default) and overridable via the `l10n` property like any other string.
|
|
184
218
|
*/
|
|
185
|
-
declare const errorLocale: {
|
|
186
|
-
'ai-enhancer-error-invalid_request': string;
|
|
187
|
-
'ai-enhancer-error-invalid_source': string;
|
|
188
|
-
'ai-enhancer-error-source_not_found': string;
|
|
189
|
-
'ai-enhancer-error-source_not_image': string;
|
|
190
|
-
'ai-enhancer-error-source_url_unavailable': string;
|
|
191
|
-
'ai-enhancer-error-invalid_aspect_ratio': string;
|
|
192
|
-
'ai-enhancer-error-canvas_too_large': string;
|
|
193
|
-
'ai-enhancer-error-canvas_dimension_too_small': string;
|
|
194
|
-
'ai-enhancer-error-source_extends_beyond_canvas': string;
|
|
195
|
-
'ai-enhancer-error-derivative_disabled': string;
|
|
196
|
-
'ai-enhancer-error-job_id_required': string;
|
|
197
|
-
'ai-enhancer-error-job_not_found': string;
|
|
198
|
-
'ai-enhancer-error-content_moderated': string;
|
|
199
|
-
'ai-enhancer-error-provider_unavailable': string;
|
|
200
|
-
'ai-enhancer-error-generation_timeout': string;
|
|
201
|
-
'ai-enhancer-error-invalid_input': string;
|
|
202
|
-
'ai-enhancer-error-RequestThrottledError': string;
|
|
203
|
-
'ai-enhancer-error-DownloadFileHTTPClientError': string;
|
|
204
|
-
'ai-enhancer-error-DownloadFileNotFoundError': string;
|
|
205
|
-
'ai-enhancer-error-DownloadFileTaskFailedError': string;
|
|
206
|
-
};
|
|
219
|
+
declare const errorLocale: Record<`ai-enhancer-error-${KnownErrorCode}`, string>;
|
|
207
220
|
|
|
208
221
|
/**
|
|
209
222
|
* Where the history strip sits.
|
|
@@ -212,6 +225,18 @@ declare const errorLocale: {
|
|
|
212
225
|
*/
|
|
213
226
|
export declare type HistoryPlacement = 'composer-above' | 'composer-below' | 'canvas-top' | 'canvas-bottom';
|
|
214
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Single source of truth for the known `uc:error` codes — shared between
|
|
230
|
+
* `AiEnhancerErrorCode` (entities/error) and the `ai-enhancer-error-<code>`
|
|
231
|
+
* locale keys (shared/i18n). The list mirrors what the platform/job APIs are
|
|
232
|
+
* known to send; it is not a closed contract — unknown codes still flow
|
|
233
|
+
* through as plain strings. Frontend-originated codes (e.g. the React
|
|
234
|
+
* wrapper's `engine_load_failed`) deliberately stay out of this list.
|
|
235
|
+
*/
|
|
236
|
+
declare const KNOWN_ERROR_CODES: readonly ["invalid_request", "invalid_source", "source_not_found", "source_not_image", "source_url_unavailable", "invalid_aspect_ratio", "canvas_too_large", "canvas_dimension_too_small", "source_extends_beyond_canvas", "derivative_disabled", "job_id_required", "job_not_found", "content_moderated", "provider_unavailable", "generation_timeout", "invalid_input", "RequestThrottledError", "DownloadFileHTTPClientError", "DownloadFileNotFoundError", "DownloadFileTaskFailedError"];
|
|
237
|
+
|
|
238
|
+
declare type KnownErrorCode = (typeof KNOWN_ERROR_CODES)[number];
|
|
239
|
+
|
|
215
240
|
/**
|
|
216
241
|
* Per-file metadata callback, mirroring the file uploader's `metadata` config
|
|
217
242
|
* option. Called at generation time with the source image's file info (the
|
|
@@ -257,8 +282,9 @@ export declare type ToolbarPlacement = 'bottom' | 'top';
|
|
|
257
282
|
* result (the Done button). `detail` carries the result `url`, `uuid`,
|
|
258
283
|
* `prompt`, `mode`, optional `aspectRatio`, and the `file` object.
|
|
259
284
|
* @fires uc:cancel - Fired when the user cancels (the Cancel button). No detail.
|
|
260
|
-
* @fires uc:error - A `CustomEvent<
|
|
261
|
-
* throws.
|
|
285
|
+
* @fires uc:error - A `CustomEvent<ErrorDetail>` fired when a generation
|
|
286
|
+
* throws. `detail.error` is always an `AiEnhancerError` — its `code` maps to
|
|
287
|
+
* a localized message and the original thrown value is on `.cause`.
|
|
262
288
|
*
|
|
263
289
|
* @cssprop [--uc-ai-background] - Editor surface background.
|
|
264
290
|
* @cssprop [--uc-ai-foreground] - Primary text/icon colour.
|
|
@@ -356,8 +382,7 @@ export declare class UcAiEnhancer extends LitElement {
|
|
|
356
382
|
* How the canvas sizes relative to the composer. `available` (default) shrinks
|
|
357
383
|
* the canvas to the space left by the composer, which is docked outside the
|
|
358
384
|
* image (history chips still overlay the canvas). `full` lets the canvas fill
|
|
359
|
-
* the whole area with the composer floating over it.
|
|
360
|
-
* so {@link composerAutoHide} implies `full`.
|
|
385
|
+
* the whole area with the composer floating over it.
|
|
361
386
|
*/
|
|
362
387
|
canvasFit: CanvasFit;
|
|
363
388
|
/**
|
|
@@ -366,13 +391,7 @@ export declare class UcAiEnhancer extends LitElement {
|
|
|
366
391
|
* canvas edge.
|
|
367
392
|
*/
|
|
368
393
|
historyPlacement: HistoryPlacement;
|
|
369
|
-
|
|
370
|
-
* Auto-hide ("dock") the floating composer once an image exists: it drops to a
|
|
371
|
-
* small peek at the edge and raises when the pointer approaches its edge or it
|
|
372
|
-
* gains focus. Always floats the composer (implies {@link canvasFit} `full`);
|
|
373
|
-
* off by default.
|
|
374
|
-
*/
|
|
375
|
-
composerAutoHide: boolean;
|
|
394
|
+
/* Excluded from this release type: composerAutoHide */
|
|
376
395
|
/** Where the toolbar (Cancel / Done) sits: `bottom` (default) or `top`. */
|
|
377
396
|
toolbarPlacement: ToolbarPlacement;
|
|
378
397
|
/* Excluded from this release type: shimmerConfig */
|
|
@@ -525,7 +544,7 @@ declare module '@uploadcare/file-uploader' {
|
|
|
525
544
|
}
|
|
526
545
|
|
|
527
546
|
|
|
528
|
-
declare module '
|
|
547
|
+
declare module 'vitest/browser' {
|
|
529
548
|
interface BrowserPage {
|
|
530
549
|
render: typeof render;
|
|
531
550
|
}
|
package/dist/ai-enhancer.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { U as
|
|
1
|
+
import { U as o, e as a } from "./UcAiEnhancer-DK6rhHp7.js";
|
|
2
|
+
import { AiEnhancerError as c } from "./errors.js";
|
|
2
3
|
export {
|
|
3
|
-
c as
|
|
4
|
-
|
|
4
|
+
c as AiEnhancerError,
|
|
5
|
+
o as UcAiEnhancer,
|
|
6
|
+
a as enLocale
|
|
5
7
|
};
|
package/dist/errors.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class c extends Error{constructor(e,r={}){super(e),this.name="AiEnhancerError",this.code=r.code??"unknown",this.source=r.source,this.cause=r.cause}}exports.AiEnhancerError=c;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one error type carried by `uc:error`'s `detail.error`. Every value
|
|
3
|
+
* thrown out of a generation/edit run is normalized into this class at the
|
|
4
|
+
* dispatch site; the original thrown value is always preserved on `.cause`.
|
|
5
|
+
* The UI maps `code` to a localized message (`ai-enhancer-error-<code>`).
|
|
6
|
+
*/
|
|
7
|
+
export declare class AiEnhancerError extends Error {
|
|
8
|
+
readonly code: AiEnhancerErrorCode;
|
|
9
|
+
readonly source?: string;
|
|
10
|
+
readonly cause?: unknown;
|
|
11
|
+
constructor(message: string, options?: AiEnhancerErrorOptions);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The known error codes (see {@link KNOWN_ERROR_CODES} in shared/lib), plus an
|
|
16
|
+
* escape hatch: the backend can introduce codes the frontend hasn't heard of,
|
|
17
|
+
* and frontend-originated failures use their own codes (e.g. the React
|
|
18
|
+
* wrapper's `engine_load_failed`).
|
|
19
|
+
*/
|
|
20
|
+
export declare type AiEnhancerErrorCode = KnownErrorCode | (string & {});
|
|
21
|
+
|
|
22
|
+
export declare type AiEnhancerErrorOptions = {
|
|
23
|
+
code?: AiEnhancerErrorCode;
|
|
24
|
+
/** Job/platform `error_source`, when the failure reports one. */
|
|
25
|
+
source?: string;
|
|
26
|
+
/** The original thrown value. */
|
|
27
|
+
cause?: unknown;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Single source of truth for the known `uc:error` codes — shared between
|
|
32
|
+
* `AiEnhancerErrorCode` (entities/error) and the `ai-enhancer-error-<code>`
|
|
33
|
+
* locale keys (shared/i18n). The list mirrors what the platform/job APIs are
|
|
34
|
+
* known to send; it is not a closed contract — unknown codes still flow
|
|
35
|
+
* through as plain strings. Frontend-originated codes (e.g. the React
|
|
36
|
+
* wrapper's `engine_load_failed`) deliberately stay out of this list.
|
|
37
|
+
*/
|
|
38
|
+
declare const KNOWN_ERROR_CODES: readonly ["invalid_request", "invalid_source", "source_not_found", "source_not_image", "source_url_unavailable", "invalid_aspect_ratio", "canvas_too_large", "canvas_dimension_too_small", "source_extends_beyond_canvas", "derivative_disabled", "job_id_required", "job_not_found", "content_moderated", "provider_unavailable", "generation_timeout", "invalid_input", "RequestThrottledError", "DownloadFileHTTPClientError", "DownloadFileNotFoundError", "DownloadFileTaskFailedError"];
|
|
39
|
+
|
|
40
|
+
declare type KnownErrorCode = (typeof KNOWN_ERROR_CODES)[number];
|
|
41
|
+
|
|
42
|
+
export { }
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Augment the file-uploader's type system so plugin-specific config is checked
|
|
47
|
+
* instead of cast: the custom activity params for
|
|
48
|
+
* `setCurrentActivity(AI_ENHANCER_ID, params)`, the editor's locale keys so
|
|
49
|
+
* `localeDefinitionOverride` is typed for them, and the plugin's own config
|
|
50
|
+
* options on `<uc-config>`.
|
|
51
|
+
*
|
|
52
|
+
* Importing the plugin brings these augmentations into scope. If your project
|
|
53
|
+
* doesn't pick them up automatically, reference the plugin's types once, e.g.
|
|
54
|
+
* `/// <reference types="@uploadcare/ai-enhancer/plugin" />`.
|
|
55
|
+
*/
|
|
56
|
+
declare module '@uploadcare/file-uploader' {
|
|
57
|
+
interface CustomActivities {
|
|
58
|
+
[AI_ENHANCER_ID]: {
|
|
59
|
+
params: AiEditorActivityParams;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
interface CustomLocaleDefinition extends AiEnhancerLocale {
|
|
63
|
+
}
|
|
64
|
+
interface CustomConfig {
|
|
65
|
+
/**
|
|
66
|
+
* Show the **AI Edit** file action on uploaded images (default `true`); set
|
|
67
|
+
* `false` (attribute `use-ai-editor="false"`) to hide it. Mirrors the
|
|
68
|
+
* uploader's `useCloudImageEditor`. Note: the action also hides itself for
|
|
69
|
+
* images that already carry CDN modifiers (e.g. edited with the Cloud Image
|
|
70
|
+
* Editor), regardless of this flag.
|
|
71
|
+
*/
|
|
72
|
+
useAiEditor: boolean;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
declare module 'vitest/browser' {
|
|
78
|
+
interface BrowserPage {
|
|
79
|
+
render: typeof render;
|
|
80
|
+
}
|
|
81
|
+
}
|
package/dist/errors.js
ADDED
package/dist/plugin.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./UcAiEnhancer-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./UcAiEnhancer-Co-HZ72E.cjs"),L="free";function A(o){return o?o.split(/[\s,]+/).filter(Boolean):[]}function N(o){const r=A(o);if(r.length===0)return[];const c=[];for(const e of r){const i=e.trim();if(!i)continue;const f=i===L,y=i.indexOf(":");if(y===-1&&!f){console.warn(`Invalid crop preset: ${i}`);continue}const g=f?0:Number(i.slice(0,y)),t=f?0:Number(i.slice(y+1));if(!f&&(!Number.isFinite(g)||!Number.isFinite(t)||g<=0||t<=0)){console.warn(`Invalid crop preset: ${i}`);continue}c.push({id:crypto.randomUUID(),type:"aspect-ratio",width:g,height:t,hasFreeform:f})}return c}const d="ai-enhancer",O=[["--uc-ai-foreground","--uc-foreground"],["--uc-ai-background","--uc-background"],["--uc-ai-muted","--uc-muted"],["--uc-ai-muted-foreground","--uc-muted-foreground"],["--uc-ai-primary","--uc-primary"],["--uc-ai-primary-hover","--uc-primary-hover"],["--uc-ai-primary-foreground","--uc-primary-foreground"],["--uc-ai-primary-transparent","--uc-primary-transparent"],["--uc-ai-secondary","--uc-secondary"],["--uc-ai-secondary-hover","--uc-secondary-hover"],["--uc-ai-secondary-foreground","--uc-secondary-foreground"],["--uc-ai-border","--uc-border"],["--uc-ai-destructive","--uc-destructive"],["--uc-ai-dialog-shadow","--uc-dialog-shadow"],["--uc-ai-radius","--uc-radius"],["--uc-ai-padding","--uc-padding"],["--uc-ai-button-size","--uc-button-size"],["--uc-ai-font-family","--uc-font-family"],["--uc-ai-font-size","--uc-font-size"],["--uc-ai-transition","--uc-transition"]];function R(o){for(const[r,c]of O)o.style.setProperty(r,`var(${c})`)}const P="uc-ai-enhancer-activity-size";function U(){if(typeof document>"u"||document.getElementById(P))return;const o=document.createElement("style");o.id=P,o.textContent=[`[uc-modal]:not(#\\#) > dialog:has([activity="${d}"][active]) {`," --uc-dialog-max-width: 1440px;"," --uc-dialog-max-height: 900px;"," width: 100%;"," height: 100%;","}"].join(`
|
|
2
2
|
`),document.head.appendChild(o)}function v(o){const r=N(o);if(r.length===0)return null;const c=r.some(i=>i.hasFreeform),e=r.filter(i=>!i.hasFreeform).map(i=>[i.width,i.height]).filter(m.isValidAspectRatio);return c&&e.length===0?[...m.POPULAR_ASPECT_RATIOS]:c||e.length>0?e:null}const w={id:d,setup:({pluginApi:o,uploaderApi:r})=>{const{registry:c,config:e}=o;U(),c.registerIcon({name:"ai-generate",svg:m.ICON_GENERATE}),c.registerIcon({name:"ai-edit",svg:m.ICON_EDIT_AI}),c.registerConfig({name:"useAiEditor",defaultValue:!0,fromAttribute:t=>t!=="false",toAttribute:t=>t?null:"false",normalize:t=>t!==!1}),c.registerL10n({en:m.enLocale});const i=new Map([["en",m.enLocale]]),f=new Set(["en"]),y=async t=>{const u=t,a=i.get(u);if(a)return a;const n=m.LOCALE_LOADERS[u];if(!n)return null;const l=await n();return i.set(u,l),l},g=async t=>{const u=t||"en";if(f.has(u))return;const a=await y(u);a&&(f.add(u),c.registerL10n({[u]:a}))};g(e.get("localeName")),e.subscribe("localeName",t=>{g(t)}),c.registerSource({id:d,label:"ai-enhancer-source-label",icon:"ai-generate",onSelect:()=>{r.setCurrentActivity(d,{}),r.setModalState(!0)}}),c.registerFileAction({id:d,icon:"ai-edit",label:"ai-enhancer-file-action-label",shouldRender:t=>!!(e.get("useAiEditor")&&t.isImage&&t.uuid&&!t.cdnUrlModifiers),onClick:t=>{r.setCurrentActivity(d,{sourceInternalId:t.internalId}),r.setModalState(!0)}}),c.registerActivity({id:d,render:(t,u)=>{if(!e.get("pubkey"))return console.warn("[ai-enhancer] No `pubkey` configured; the AI editor is disabled."),()=>{};const a=u??{},n=document.createElement("uc-ai-enhancer");if(a.sourceInternalId)try{const s=r.getOutputItem(a.sourceInternalId);n.sourceFileInfo=s.fileInfo??void 0}catch{}R(n);const l=()=>{n.pubkey=e.get("pubkey"),n.baseUrl=e.get("baseUrl"),n.cdnCname=e.get("cdnCname"),n.cdnCnamePrefixed=e.get("cdnCnamePrefixed"),n.secureDeliveryProxyUrlResolver=e.get("secureDeliveryProxyUrlResolver")??void 0};l();const p=()=>{const s=e.get("metadata");if(typeof s!="function"){n.metadata=s;return}const h=a.sourceInternalId;n.metadata=()=>h?s(r.getOutputItem(h)):{}};p();const b=()=>{n.localeName=e.get("localeName")||"en",n.localeDefinitionOverride=e.get("localeDefinitionOverride")??{}};b();const I=v(e.get("cropPreset")??"");I&&(n.aspectRatios=I);const F=[e.subscribe("pubkey",l),e.subscribe("baseUrl",l),e.subscribe("cdnCname",l),e.subscribe("cdnCnamePrefixed",l),e.subscribe("secureDeliveryProxyUrlResolver",l),e.subscribe("metadata",p),e.subscribe("localeName",b),e.subscribe("localeDefinitionOverride",b),e.subscribe("cropPreset",s=>{n.aspectRatios=v(s??"")})],C=s=>{const{file:h}=s.detail;if(a.sourceInternalId)try{r.replaceFile(a.sourceInternalId,h,{source:d})}catch{r.addFileFromUploadcareFile(h,{source:d})}else r.addFileFromUploadcareFile(h,{source:d});r.setCurrentActivity("upload-list"),r.setModalState(!0)},E=()=>{r.setCurrentActivity("upload-list"),r.setModalState(!0)};return n.addEventListener("uc:done",C),n.addEventListener("uc:cancel",E),t.replaceChildren(n),()=>{n.removeEventListener("uc:done",C),n.removeEventListener("uc:cancel",E);for(const s of F)s();t.replaceChildren()}}})}};exports.AiEnhancerPlugin=w;exports.aspectRatiosFromCropPreset=v;
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as L, I as N, e as C, i as O, P as R, L as w } from "./UcAiEnhancer-
|
|
1
|
+
import { a as L, I as N, e as C, i as O, P as R, L as w } from "./UcAiEnhancer-DK6rhHp7.js";
|
|
2
2
|
const A = "free";
|
|
3
3
|
function U(o) {
|
|
4
4
|
return o ? o.split(/[\s,]+/).filter(Boolean) : [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadcare/ai-enhancer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "AI image generation and editing web component for Uploadcare",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"types": "./dist/plugin.d.ts",
|
|
20
20
|
"import": "./dist/plugin.js",
|
|
21
21
|
"require": "./dist/plugin.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./errors": {
|
|
24
|
+
"types": "./dist/errors.d.ts",
|
|
25
|
+
"import": "./dist/errors.js",
|
|
26
|
+
"require": "./dist/errors.cjs"
|
|
22
27
|
}
|
|
23
28
|
},
|
|
24
29
|
"scripts": {
|
|
@@ -30,7 +35,9 @@
|
|
|
30
35
|
"docs:api": "cem analyze && node scripts/build-cem-docs.mjs && typedoc && node scripts/clean-typedoc-class.mjs",
|
|
31
36
|
"docs:dev": "npm run docs:api && vitepress dev docs",
|
|
32
37
|
"docs:build": "npm run docs:api && vitepress build docs",
|
|
33
|
-
"docs:preview": "vitepress preview docs"
|
|
38
|
+
"docs:preview": "vitepress preview docs",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"lint:lit": "lit-analyzer './src/**/*.ts' --strict --rules.no-unknown-attribute off"
|
|
34
41
|
},
|
|
35
42
|
"dependencies": {
|
|
36
43
|
"@lit-labs/motion": "^1.1.0",
|
|
@@ -51,7 +58,8 @@
|
|
|
51
58
|
"@custom-elements-manifest/analyzer": "^0.11.0",
|
|
52
59
|
"@custom-elements-manifest/to-markdown": "^0.1.0",
|
|
53
60
|
"@uploadcare/file-uploader": "1.31.2",
|
|
54
|
-
"@vitest/browser": "^
|
|
61
|
+
"@vitest/browser-playwright": "^4.1.10",
|
|
62
|
+
"lit-analyzer": "^2.0.3",
|
|
55
63
|
"playwright": "^1.49.0",
|
|
56
64
|
"typedoc": "^0.28.19",
|
|
57
65
|
"typedoc-plugin-markdown": "^4.12.0",
|