@umodeapporg/ui 0.15.0 → 0.16.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/components/Form/ControlledImage/index.d.ts +3 -0
- package/dist/components/Form/ControlledImage/index.js +2 -1
- package/dist/components/Form/ControlledImage/index.js.map +1 -1
- package/dist/components/UI/ImageAiAdjust/ImageAiAdjustDialog.d.ts +6 -0
- package/dist/components/UI/ImageAiAdjust/ImageAiAdjustDialog.js +164 -74
- package/dist/components/UI/ImageAiAdjust/ImageAiAdjustDialog.js.map +1 -1
- package/dist/components/UI/ImageAiAdjust/ImageAiDiscardReasonDialog.d.ts +8 -0
- package/dist/components/UI/ImageAiAdjust/ImageAiDiscardReasonDialog.js +67 -0
- package/dist/components/UI/ImageAiAdjust/ImageAiDiscardReasonDialog.js.map +1 -0
- package/dist/components/UI/ImageAiAdjust/ImageAiVerificationNotice.d.ts +8 -0
- package/dist/components/UI/ImageAiAdjust/ImageAiVerificationNotice.js +39 -0
- package/dist/components/UI/ImageAiAdjust/ImageAiVerificationNotice.js.map +1 -0
- package/dist/components/UI/ImageAiAdjust/imageAiReview.d.ts +22 -0
- package/dist/components/UI/ImageAiAdjust/imageAiReview.js +37 -0
- package/dist/components/UI/ImageAiAdjust/imageAiReview.js.map +1 -0
- package/dist/components/UI/ImageAiAdjust/imageAiVerification.d.ts +19 -0
- package/dist/components/UI/ImageAiAdjust/imageAiVerification.js +25 -0
- package/dist/components/UI/ImageAiAdjust/imageAiVerification.js.map +1 -0
- package/dist/components/UI/ImageAiAdjust/useImageAiAdjust.d.ts +25 -2
- package/dist/components/UI/ImageAiAdjust/useImageAiAdjust.js +44 -19
- package/dist/components/UI/ImageAiAdjust/useImageAiAdjust.js.map +1 -1
- package/dist/components/UI/ImageMaskPainter/index.d.ts +19 -0
- package/dist/components/UI/ImageMaskPainter/index.js +267 -0
- package/dist/components/UI/ImageMaskPainter/index.js.map +1 -0
- package/dist/components/UI/ImageMaskPainter/maskStrokes.d.ts +19 -0
- package/dist/components/UI/ImageMaskPainter/maskStrokes.js +71 -0
- package/dist/components/UI/ImageMaskPainter/maskStrokes.js.map +1 -0
- package/dist/helpers/imageFile.d.ts +16 -0
- package/dist/helpers/imageFile.js +59 -10
- package/dist/helpers/imageFile.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/locales/en/ui.json.d.ts +36 -1
- package/dist/locales/en/ui.json.js +7 -1
- package/dist/locales/en/ui.json.js.map +1 -1
- package/dist/locales/index.d.ts +70 -0
- package/dist/locales/pt/ui.json.d.ts +36 -1
- package/dist/locales/pt/ui.json.js +7 -1
- package/dist/locales/pt/ui.json.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type TMaskBrushMode = 'paint' | 'erase';
|
|
2
|
+
export interface IMaskPoint {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
/** A stroke in the image's natural pixel space, so the mask never depends on the on-screen size. */
|
|
7
|
+
export interface IMaskStroke {
|
|
8
|
+
mode: TMaskBrushMode;
|
|
9
|
+
size: number;
|
|
10
|
+
points: Array<IMaskPoint>;
|
|
11
|
+
}
|
|
12
|
+
/** Draws the newest segment of a stroke that is still being painted. */
|
|
13
|
+
export declare const drawStrokeTail: (context: CanvasRenderingContext2D, stroke: IMaskStroke, color: string) => void;
|
|
14
|
+
/** Repaints the whole overlay; used after undo, clear and theme changes. */
|
|
15
|
+
export declare const redrawStrokes: (context: CanvasRenderingContext2D, strokes: ReadonlyArray<IMaskStroke>, color: string) => void;
|
|
16
|
+
/** Cheap check on a downscaled copy: thin strokes still leave a non-zero averaged alpha. */
|
|
17
|
+
export declare const overlayHasPaint: (overlay: HTMLCanvasElement) => boolean;
|
|
18
|
+
/** White where the overlay is painted, black elsewhere, at the overlay's (natural) resolution. */
|
|
19
|
+
export declare const exportMaskFile: (overlay: HTMLCanvasElement, fileName: string) => Promise<File | null>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const MASK_KEEP = "#000000";
|
|
2
|
+
const MASK_CHANGE = "#ffffff";
|
|
3
|
+
const COVERAGE_SAMPLE = 256;
|
|
4
|
+
const strokeSegment = (context, stroke, from, to) => {
|
|
5
|
+
context.globalCompositeOperation = stroke.mode === "erase" ? "destination-out" : "source-over";
|
|
6
|
+
context.lineWidth = stroke.size;
|
|
7
|
+
context.lineCap = "round";
|
|
8
|
+
context.lineJoin = "round";
|
|
9
|
+
context.beginPath();
|
|
10
|
+
context.moveTo(from.x, from.y);
|
|
11
|
+
context.lineTo(to.x + (from.x === to.x && from.y === to.y ? 0.01 : 0), to.y);
|
|
12
|
+
context.stroke();
|
|
13
|
+
};
|
|
14
|
+
const drawStrokeTail = (context, stroke, color) => {
|
|
15
|
+
const { points } = stroke;
|
|
16
|
+
if (points.length === 0) return;
|
|
17
|
+
context.save();
|
|
18
|
+
context.strokeStyle = color;
|
|
19
|
+
strokeSegment(context, stroke, points[Math.max(0, points.length - 2)], points[points.length - 1]);
|
|
20
|
+
context.restore();
|
|
21
|
+
};
|
|
22
|
+
const redrawStrokes = (context, strokes, color) => {
|
|
23
|
+
context.save();
|
|
24
|
+
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
|
|
25
|
+
context.strokeStyle = color;
|
|
26
|
+
strokes.forEach((stroke) => {
|
|
27
|
+
stroke.points.forEach((point, index) => {
|
|
28
|
+
strokeSegment(context, stroke, stroke.points[Math.max(0, index - 1)], point);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
context.restore();
|
|
32
|
+
};
|
|
33
|
+
const overlayHasPaint = (overlay) => {
|
|
34
|
+
if (!overlay.width || !overlay.height) return false;
|
|
35
|
+
const ratio = Math.min(1, COVERAGE_SAMPLE / Math.max(overlay.width, overlay.height));
|
|
36
|
+
const sample = document.createElement("canvas");
|
|
37
|
+
sample.width = Math.max(1, Math.round(overlay.width * ratio));
|
|
38
|
+
sample.height = Math.max(1, Math.round(overlay.height * ratio));
|
|
39
|
+
const context = sample.getContext("2d");
|
|
40
|
+
if (!context) return false;
|
|
41
|
+
context.drawImage(overlay, 0, 0, sample.width, sample.height);
|
|
42
|
+
const { data } = context.getImageData(0, 0, sample.width, sample.height);
|
|
43
|
+
for (let index = 3; index < data.length; index += 4) {
|
|
44
|
+
if (data[index] > 0) return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
48
|
+
const exportMaskFile = async (overlay, fileName) => {
|
|
49
|
+
const canvas = document.createElement("canvas");
|
|
50
|
+
canvas.width = overlay.width;
|
|
51
|
+
canvas.height = overlay.height;
|
|
52
|
+
const context = canvas.getContext("2d");
|
|
53
|
+
if (!context) return null;
|
|
54
|
+
context.fillStyle = MASK_CHANGE;
|
|
55
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
56
|
+
context.globalCompositeOperation = "destination-in";
|
|
57
|
+
context.drawImage(overlay, 0, 0);
|
|
58
|
+
context.globalCompositeOperation = "destination-over";
|
|
59
|
+
context.fillStyle = MASK_KEEP;
|
|
60
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
61
|
+
const blob = await new Promise((resolve) => canvas.toBlob(resolve, "image/png"));
|
|
62
|
+
if (!blob) return null;
|
|
63
|
+
return new File([blob], fileName, { type: "image/png" });
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
drawStrokeTail,
|
|
67
|
+
exportMaskFile,
|
|
68
|
+
overlayHasPaint,
|
|
69
|
+
redrawStrokes
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=maskStrokes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskStrokes.js","sources":["../../../../src/components/UI/ImageMaskPainter/maskStrokes.ts"],"sourcesContent":["export type TMaskBrushMode = 'paint' | 'erase';\n\nexport interface IMaskPoint {\n x: number;\n y: number;\n}\n\n/** A stroke in the image's natural pixel space, so the mask never depends on the on-screen size. */\nexport interface IMaskStroke {\n mode: TMaskBrushMode;\n size: number;\n points: Array<IMaskPoint>;\n}\n\n/** The export side is data, not interface colour: the backend reads white as \"may change\". */\nconst MASK_KEEP = '#000000';\nconst MASK_CHANGE = '#ffffff';\nconst COVERAGE_SAMPLE = 256;\n\nconst strokeSegment = (context: CanvasRenderingContext2D, stroke: IMaskStroke, from: IMaskPoint, to: IMaskPoint) => {\n context.globalCompositeOperation = stroke.mode === 'erase' ? 'destination-out' : 'source-over';\n context.lineWidth = stroke.size;\n context.lineCap = 'round';\n context.lineJoin = 'round';\n context.beginPath();\n context.moveTo(from.x, from.y);\n // A zero-length line still paints a round dot with a round cap in every engine but Safari.\n context.lineTo(to.x + (from.x === to.x && from.y === to.y ? 0.01 : 0), to.y);\n context.stroke();\n};\n\n/** Draws the newest segment of a stroke that is still being painted. */\nexport const drawStrokeTail = (context: CanvasRenderingContext2D, stroke: IMaskStroke, color: string): void => {\n const { points } = stroke;\n if (points.length === 0) return;\n context.save();\n context.strokeStyle = color;\n strokeSegment(context, stroke, points[Math.max(0, points.length - 2)], points[points.length - 1]);\n context.restore();\n};\n\n/** Repaints the whole overlay; used after undo, clear and theme changes. */\nexport const redrawStrokes = (\n context: CanvasRenderingContext2D,\n strokes: ReadonlyArray<IMaskStroke>,\n color: string,\n): void => {\n context.save();\n context.clearRect(0, 0, context.canvas.width, context.canvas.height);\n context.strokeStyle = color;\n strokes.forEach((stroke) => {\n stroke.points.forEach((point, index) => {\n strokeSegment(context, stroke, stroke.points[Math.max(0, index - 1)], point);\n });\n });\n context.restore();\n};\n\n/** Cheap check on a downscaled copy: thin strokes still leave a non-zero averaged alpha. */\nexport const overlayHasPaint = (overlay: HTMLCanvasElement): boolean => {\n if (!overlay.width || !overlay.height) return false;\n const ratio = Math.min(1, COVERAGE_SAMPLE / Math.max(overlay.width, overlay.height));\n const sample = document.createElement('canvas');\n sample.width = Math.max(1, Math.round(overlay.width * ratio));\n sample.height = Math.max(1, Math.round(overlay.height * ratio));\n const context = sample.getContext('2d');\n if (!context) return false;\n context.drawImage(overlay, 0, 0, sample.width, sample.height);\n const { data } = context.getImageData(0, 0, sample.width, sample.height);\n for (let index = 3; index < data.length; index += 4) {\n if (data[index] > 0) return true;\n }\n return false;\n};\n\n/** White where the overlay is painted, black elsewhere, at the overlay's (natural) resolution. */\nexport const exportMaskFile = async (overlay: HTMLCanvasElement, fileName: string): Promise<File | null> => {\n const canvas = document.createElement('canvas');\n canvas.width = overlay.width;\n canvas.height = overlay.height;\n const context = canvas.getContext('2d');\n if (!context) return null;\n\n context.fillStyle = MASK_CHANGE;\n context.fillRect(0, 0, canvas.width, canvas.height);\n context.globalCompositeOperation = 'destination-in';\n context.drawImage(overlay, 0, 0);\n context.globalCompositeOperation = 'destination-over';\n context.fillStyle = MASK_KEEP;\n context.fillRect(0, 0, canvas.width, canvas.height);\n\n const blob = await new Promise<Blob | null>((resolve) => canvas.toBlob(resolve, 'image/png'));\n if (!blob) return null;\n return new File([blob], fileName, { type: 'image/png' });\n};\n"],"names":[],"mappings":"AAeA,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,kBAAkB;AAExB,MAAM,gBAAgB,CAAC,SAAmC,QAAqB,MAAkB,OAAmB;AAClH,UAAQ,2BAA2B,OAAO,SAAS,UAAU,oBAAoB;AACjF,UAAQ,YAAY,OAAO;AAC3B,UAAQ,UAAU;AAClB,UAAQ,WAAW;AACnB,UAAQ,UAAA;AACR,UAAQ,OAAO,KAAK,GAAG,KAAK,CAAC;AAE7B,UAAQ,OAAO,GAAG,KAAK,KAAK,MAAM,GAAG,KAAK,KAAK,MAAM,GAAG,IAAI,OAAO,IAAI,GAAG,CAAC;AAC3E,UAAQ,OAAA;AACV;AAGO,MAAM,iBAAiB,CAAC,SAAmC,QAAqB,UAAwB;AAC7G,QAAM,EAAE,WAAW;AACnB,MAAI,OAAO,WAAW,EAAG;AACzB,UAAQ,KAAA;AACR,UAAQ,cAAc;AAC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B,OAAO,SAA4B,aAA2C;AAC1G,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,QAAQ,QAAQ;AACvB,SAAO,SAAS,QAAQ;AACxB,QAAM,UAAU,OAAO,WAAW,IAAI;AACtC,MAAI,CAAC,QAAS,QAAO;AAErB,UAAQ,YAAY;AACpB,UAAQ,SAAS,GAAG,GAAG,OAAO,OAAO,OAAO,MAAM;AAClD,UAAQ,2BAA2B;AACnC,UAAQ,UAAU,SAAS,GAAG,CAAC;AAC/B,UAAQ,2BAA2B;AACnC,UAAQ,YAAY;AACpB,UAAQ,SAAS,GAAG,GAAG,OAAO,OAAO,OAAO,MAAM;AAElD,QAAM,OAAO,MAAM,IAAI,QAAqB,CAAC,YAAY,OAAO,OAAO,SAAS,WAAW,CAAC;AAC5F,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,IAAI,KAAK,CAAC,IAAI,GAAG,UAAU,EAAE,MAAM,aAAa;AACzD;"}
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
+
/** Most AI upload endpoints cap files at 8 MB; this leaves room for multipart overhead. */
|
|
2
|
+
export declare const AI_UPLOAD_SAFE_BYTES: number;
|
|
3
|
+
export type TImageOutputType = 'image/jpeg' | 'image/png' | 'image/webp';
|
|
1
4
|
export interface IResizeImageOptions {
|
|
2
5
|
maxDimension?: number;
|
|
3
6
|
quality?: number;
|
|
7
|
+
/** Defaults to JPEG. PNG and WebP keep transparency. */
|
|
8
|
+
outputType?: TImageOutputType;
|
|
4
9
|
}
|
|
10
|
+
/** File extension (without dot) for an image MIME type, `jpg` when unknown. */
|
|
11
|
+
export declare const imageExtensionForType: (type: string) => string;
|
|
5
12
|
export declare const resizeImageFile: (file: File, options?: IResizeImageOptions) => Promise<File>;
|
|
13
|
+
export interface IFitImageToUploadBudgetOptions {
|
|
14
|
+
maxBytes?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Keeps the source image untouched whenever it already fits the upload budget, so an AI edit
|
|
18
|
+
* works on the original pixels. Only an oversized (or non PNG/JPEG/WebP) file is re-encoded,
|
|
19
|
+
* with high quality and the source format when possible, stepping down until it fits.
|
|
20
|
+
*/
|
|
21
|
+
export declare const fitImageToUploadBudget: (file: File, { maxBytes }?: IFitImageToUploadBudgetOptions) => Promise<File>;
|
|
6
22
|
export declare const fileFromUrl: (url: string, fileName: string, signal?: AbortSignal) => Promise<File>;
|
|
7
23
|
/**
|
|
8
24
|
* Mede a imagem sem baixá-la de novo quando o navegador já a tem em cache.
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
const MAX_DIMENSION = 1280;
|
|
2
2
|
const JPEG_QUALITY = 0.82;
|
|
3
3
|
const OUTPUT_TYPE = "image/jpeg";
|
|
4
|
+
const AI_UPLOAD_SAFE_BYTES = 7.5 * 1024 * 1024;
|
|
5
|
+
const AI_UPLOAD_MAX_DIMENSION = 4096;
|
|
6
|
+
const AI_UPLOAD_QUALITY = 0.95;
|
|
7
|
+
const AI_UPLOAD_FALLBACK_DIMENSION = 3072;
|
|
8
|
+
const AI_UPLOAD_FALLBACK_QUALITY = 0.9;
|
|
9
|
+
const AI_ACCEPTED_TYPES = /* @__PURE__ */ new Set(["image/jpeg", "image/png", "image/webp"]);
|
|
10
|
+
const EXTENSION_BY_TYPE = {
|
|
11
|
+
"image/jpeg": "jpg",
|
|
12
|
+
"image/png": "png",
|
|
13
|
+
"image/webp": "webp"
|
|
14
|
+
};
|
|
4
15
|
const loadImage = (url) => new Promise((resolve, reject) => {
|
|
5
16
|
const image = new Image();
|
|
6
17
|
image.onload = () => resolve(image);
|
|
@@ -13,29 +24,64 @@ const scaledSize = (width, height, maxDimension) => {
|
|
|
13
24
|
const ratio = maxDimension / longest;
|
|
14
25
|
return { width: Math.round(width * ratio), height: Math.round(height * ratio) };
|
|
15
26
|
};
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
27
|
+
const baseName = (name) => name.replace(/\.[^.]+$/, "") || name || "image";
|
|
28
|
+
const imageExtensionForType = (type) => type in EXTENSION_BY_TYPE ? EXTENSION_BY_TYPE[type] : "jpg";
|
|
29
|
+
const withExtension = (name, type) => `${baseName(name)}.${EXTENSION_BY_TYPE[type]}`;
|
|
30
|
+
const encodeImageFile = async (file, options) => {
|
|
20
31
|
const objectUrl = URL.createObjectURL(file);
|
|
21
32
|
try {
|
|
22
33
|
const image = await loadImage(objectUrl);
|
|
23
|
-
const { width, height } = scaledSize(image.naturalWidth, image.naturalHeight, maxDimension);
|
|
34
|
+
const { width, height } = scaledSize(image.naturalWidth, image.naturalHeight, options.maxDimension);
|
|
24
35
|
const canvas = document.createElement("canvas");
|
|
25
36
|
canvas.width = width;
|
|
26
37
|
canvas.height = height;
|
|
27
38
|
const context = canvas.getContext("2d");
|
|
28
|
-
if (!context) return
|
|
39
|
+
if (!context) return null;
|
|
40
|
+
if (options.outputType === "image/jpeg") {
|
|
41
|
+
context.fillStyle = "#ffffff";
|
|
42
|
+
context.fillRect(0, 0, width, height);
|
|
43
|
+
}
|
|
29
44
|
context.drawImage(image, 0, 0, width, height);
|
|
30
|
-
const blob = await new Promise(
|
|
31
|
-
|
|
32
|
-
|
|
45
|
+
const blob = await new Promise(
|
|
46
|
+
(resolve) => canvas.toBlob(resolve, options.outputType, options.quality)
|
|
47
|
+
);
|
|
48
|
+
if (!blob) return null;
|
|
49
|
+
return new File([blob], withExtension(file.name, options.outputType), { type: options.outputType });
|
|
33
50
|
} catch {
|
|
34
|
-
return
|
|
51
|
+
return null;
|
|
35
52
|
} finally {
|
|
36
53
|
URL.revokeObjectURL(objectUrl);
|
|
37
54
|
}
|
|
38
55
|
};
|
|
56
|
+
const resizeImageFile = async (file, options = {}) => {
|
|
57
|
+
const encoded = await encodeImageFile(file, {
|
|
58
|
+
maxDimension: options.maxDimension ?? MAX_DIMENSION,
|
|
59
|
+
quality: options.quality ?? JPEG_QUALITY,
|
|
60
|
+
outputType: options.outputType ?? OUTPUT_TYPE
|
|
61
|
+
});
|
|
62
|
+
if (!encoded || encoded.size >= file.size) return file;
|
|
63
|
+
return encoded;
|
|
64
|
+
};
|
|
65
|
+
const fitImageToUploadBudget = async (file, { maxBytes = AI_UPLOAD_SAFE_BYTES } = {}) => {
|
|
66
|
+
const isAccepted = AI_ACCEPTED_TYPES.has(file.type);
|
|
67
|
+
if (isAccepted && file.size <= maxBytes) return file;
|
|
68
|
+
const keepsAlpha = file.type === "image/png" || file.type === "image/webp" || !isAccepted;
|
|
69
|
+
const sourceType = isAccepted ? file.type : "image/png";
|
|
70
|
+
const attempts = [
|
|
71
|
+
{ maxDimension: AI_UPLOAD_MAX_DIMENSION, quality: AI_UPLOAD_QUALITY, outputType: sourceType },
|
|
72
|
+
...keepsAlpha ? [{ maxDimension: AI_UPLOAD_MAX_DIMENSION, quality: AI_UPLOAD_QUALITY, outputType: "image/webp" }] : [],
|
|
73
|
+
{ maxDimension: AI_UPLOAD_MAX_DIMENSION, quality: AI_UPLOAD_QUALITY, outputType: "image/jpeg" },
|
|
74
|
+
{ maxDimension: AI_UPLOAD_FALLBACK_DIMENSION, quality: AI_UPLOAD_FALLBACK_QUALITY, outputType: "image/jpeg" }
|
|
75
|
+
];
|
|
76
|
+
let smallest = null;
|
|
77
|
+
for (const attempt of attempts) {
|
|
78
|
+
const encoded = await encodeImageFile(file, attempt);
|
|
79
|
+
if (!encoded) continue;
|
|
80
|
+
if (encoded.size <= maxBytes) return encoded;
|
|
81
|
+
if (!smallest || encoded.size < smallest.size) smallest = encoded;
|
|
82
|
+
}
|
|
83
|
+
return smallest && smallest.size < file.size ? smallest : file;
|
|
84
|
+
};
|
|
39
85
|
const fileFromUrl = async (url, fileName, signal) => {
|
|
40
86
|
const blob = await (await fetch(url, { cache: "reload", mode: "cors", signal })).blob();
|
|
41
87
|
const type = blob.type || "image/jpeg";
|
|
@@ -52,7 +98,10 @@ const measureImageDimensions = async (src) => {
|
|
|
52
98
|
}
|
|
53
99
|
};
|
|
54
100
|
export {
|
|
101
|
+
AI_UPLOAD_SAFE_BYTES,
|
|
55
102
|
fileFromUrl,
|
|
103
|
+
fitImageToUploadBudget,
|
|
104
|
+
imageExtensionForType,
|
|
56
105
|
measureImageDimensions,
|
|
57
106
|
resizeImageFile
|
|
58
107
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageFile.js","sources":["../../src/helpers/imageFile.ts"],"sourcesContent":["const MAX_DIMENSION = 1280;\nconst JPEG_QUALITY = 0.82;\nconst OUTPUT_TYPE = 'image/jpeg';\n\nexport interface IResizeImageOptions {\n maxDimension?: number;\n quality?: number;\n}\n\nconst loadImage = (url: string): Promise<HTMLImageElement> =>\n new Promise((resolve, reject) => {\n const image = new Image();\n image.onload = () => resolve(image);\n image.onerror = () => reject(new Error('Failed to load image'));\n image.src = url;\n });\n\nconst scaledSize = (width: number, height: number, maxDimension: number): { width: number; height: number } => {\n const longest = Math.max(width, height);\n if (longest <= maxDimension) return { width, height };\n const ratio = maxDimension / longest;\n return { width: Math.round(width * ratio), height: Math.round(height * ratio) };\n};\n\nconst
|
|
1
|
+
{"version":3,"file":"imageFile.js","sources":["../../src/helpers/imageFile.ts"],"sourcesContent":["const MAX_DIMENSION = 1280;\nconst JPEG_QUALITY = 0.82;\nconst OUTPUT_TYPE = 'image/jpeg';\n\n/** Most AI upload endpoints cap files at 8 MB; this leaves room for multipart overhead. */\nexport const AI_UPLOAD_SAFE_BYTES = 7.5 * 1024 * 1024;\nconst AI_UPLOAD_MAX_DIMENSION = 4096;\nconst AI_UPLOAD_QUALITY = 0.95;\nconst AI_UPLOAD_FALLBACK_DIMENSION = 3072;\nconst AI_UPLOAD_FALLBACK_QUALITY = 0.9;\n\nexport type TImageOutputType = 'image/jpeg' | 'image/png' | 'image/webp';\n\nconst AI_ACCEPTED_TYPES = new Set<string>(['image/jpeg', 'image/png', 'image/webp']);\n\nconst EXTENSION_BY_TYPE: Record<TImageOutputType, string> = {\n 'image/jpeg': 'jpg',\n 'image/png': 'png',\n 'image/webp': 'webp',\n};\n\nexport interface IResizeImageOptions {\n maxDimension?: number;\n quality?: number;\n /** Defaults to JPEG. PNG and WebP keep transparency. */\n outputType?: TImageOutputType;\n}\n\nconst loadImage = (url: string): Promise<HTMLImageElement> =>\n new Promise((resolve, reject) => {\n const image = new Image();\n image.onload = () => resolve(image);\n image.onerror = () => reject(new Error('Failed to load image'));\n image.src = url;\n });\n\nconst scaledSize = (width: number, height: number, maxDimension: number): { width: number; height: number } => {\n const longest = Math.max(width, height);\n if (longest <= maxDimension) return { width, height };\n const ratio = maxDimension / longest;\n return { width: Math.round(width * ratio), height: Math.round(height * ratio) };\n};\n\nconst baseName = (name: string): string => name.replace(/\\.[^.]+$/, '') || name || 'image';\n\n/** File extension (without dot) for an image MIME type, `jpg` when unknown. */\nexport const imageExtensionForType = (type: string): string =>\n type in EXTENSION_BY_TYPE ? EXTENSION_BY_TYPE[type as TImageOutputType] : 'jpg';\n\nconst withExtension = (name: string, type: TImageOutputType): string => `${baseName(name)}.${EXTENSION_BY_TYPE[type]}`;\n\nconst encodeImageFile = async (file: File, options: Required<IResizeImageOptions>): Promise<File | null> => {\n const objectUrl = URL.createObjectURL(file);\n try {\n const image = await loadImage(objectUrl);\n const { width, height } = scaledSize(image.naturalWidth, image.naturalHeight, options.maxDimension);\n\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n const context = canvas.getContext('2d');\n if (!context) return null;\n // JPEG has no alpha: without a fill, transparent pixels would turn black.\n if (options.outputType === 'image/jpeg') {\n context.fillStyle = '#ffffff';\n context.fillRect(0, 0, width, height);\n }\n context.drawImage(image, 0, 0, width, height);\n\n const blob = await new Promise<Blob | null>((resolve) =>\n canvas.toBlob(resolve, options.outputType, options.quality),\n );\n if (!blob) return null;\n\n return new File([blob], withExtension(file.name, options.outputType), { type: options.outputType });\n } catch {\n return null;\n } finally {\n URL.revokeObjectURL(objectUrl);\n }\n};\n\nexport const resizeImageFile = async (file: File, options: IResizeImageOptions = {}): Promise<File> => {\n const encoded = await encodeImageFile(file, {\n maxDimension: options.maxDimension ?? MAX_DIMENSION,\n quality: options.quality ?? JPEG_QUALITY,\n outputType: options.outputType ?? OUTPUT_TYPE,\n });\n if (!encoded || encoded.size >= file.size) return file;\n return encoded;\n};\n\nexport interface IFitImageToUploadBudgetOptions {\n maxBytes?: number;\n}\n\n/**\n * Keeps the source image untouched whenever it already fits the upload budget, so an AI edit\n * works on the original pixels. Only an oversized (or non PNG/JPEG/WebP) file is re-encoded,\n * with high quality and the source format when possible, stepping down until it fits.\n */\nexport const fitImageToUploadBudget = async (\n file: File,\n { maxBytes = AI_UPLOAD_SAFE_BYTES }: IFitImageToUploadBudgetOptions = {},\n): Promise<File> => {\n const isAccepted = AI_ACCEPTED_TYPES.has(file.type);\n if (isAccepted && file.size <= maxBytes) return file;\n\n const keepsAlpha = file.type === 'image/png' || file.type === 'image/webp' || !isAccepted;\n const sourceType: TImageOutputType = isAccepted ? (file.type as TImageOutputType) : 'image/png';\n const attempts: Array<Required<IResizeImageOptions>> = [\n { maxDimension: AI_UPLOAD_MAX_DIMENSION, quality: AI_UPLOAD_QUALITY, outputType: sourceType },\n ...(keepsAlpha\n ? [{ maxDimension: AI_UPLOAD_MAX_DIMENSION, quality: AI_UPLOAD_QUALITY, outputType: 'image/webp' as const }]\n : []),\n { maxDimension: AI_UPLOAD_MAX_DIMENSION, quality: AI_UPLOAD_QUALITY, outputType: 'image/jpeg' },\n { maxDimension: AI_UPLOAD_FALLBACK_DIMENSION, quality: AI_UPLOAD_FALLBACK_QUALITY, outputType: 'image/jpeg' },\n ];\n\n let smallest: File | null = null;\n for (const attempt of attempts) {\n const encoded = await encodeImageFile(file, attempt);\n if (!encoded) continue;\n if (encoded.size <= maxBytes) return encoded;\n if (!smallest || encoded.size < smallest.size) smallest = encoded;\n }\n\n return smallest && smallest.size < file.size ? smallest : file;\n};\n\n// `reload` em vez de `force-cache`: a mesma imagem costuma já ter sido baixada por um <img>\n// comum, que não manda `Origin` e por isso é guardada sem `Access-Control-Allow-Origin`.\n// Reaproveitar essa entrada é o que faz o CORS falhar \"hora sim, hora não\".\nexport const fileFromUrl = async (url: string, fileName: string, signal?: AbortSignal): Promise<File> => {\n const blob = await (await fetch(url, { cache: 'reload', mode: 'cors', signal })).blob();\n const type = blob.type || 'image/jpeg';\n return new File([blob], fileName, { type });\n};\n\n/**\n * Mede a imagem sem baixá-la de novo quando o navegador já a tem em cache.\n *\n * Devolve `null` em vez de lançar: medir é para AVISAR o usuário, então uma imagem que não carrega\n * aqui não pode derrubar a tela nem virar um alerta falso.\n */\nexport const measureImageDimensions = async (src: string): Promise<{ width: number; height: number } | null> => {\n if (!src) return null;\n try {\n const image = await loadImage(src);\n if (!image.naturalWidth || !image.naturalHeight) return null;\n return { width: image.naturalWidth, height: image.naturalHeight };\n } catch {\n return null;\n }\n};\n"],"names":[],"mappings":"AAAA,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,cAAc;AAGb,MAAM,uBAAuB,MAAM,OAAO;AACjD,MAAM,0BAA0B;AAChC,MAAM,oBAAoB;AAC1B,MAAM,+BAA+B;AACrC,MAAM,6BAA6B;AAInC,MAAM,oBAAoB,oBAAI,IAAY,CAAC,cAAc,aAAa,YAAY,CAAC;AAEnF,MAAM,oBAAsD;AAAA,EAC1D,cAAc;AAAA,EACd,aAAa;AAAA,EACb,cAAc;AAChB;AASA,MAAM,YAAY,CAAC,QACjB,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,QAAM,QAAQ,IAAI,MAAA;AAClB,QAAM,SAAS,MAAM,QAAQ,KAAK;AAClC,QAAM,UAAU,MAAM,OAAO,IAAI,MAAM,sBAAsB,CAAC;AAC9D,QAAM,MAAM;AACd,CAAC;AAEH,MAAM,aAAa,CAAC,OAAe,QAAgB,iBAA4D;AAC7G,QAAM,UAAU,KAAK,IAAI,OAAO,MAAM;AACtC,MAAI,WAAW,aAAc,QAAO,EAAE,OAAO,OAAA;AAC7C,QAAM,QAAQ,e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,QAAQ;AAC1B,SAAO,IAAI,KAAK,CAAC,IAAI,GAAG,UAAU,EAAE,MAAM;AAC5C;AAQO,MAAM,yBAAyB,OAAO,QAAmE;AAC9G,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI;AACF,UAAM,QAAQ,MAAM,UAAU,GAAG;AACjC,QAAI,CAAC,MAAM,gBAAgB,CAAC,MAAM,cAAe,QAAO;AACxD,WAAO,EAAE,OAAO,MAAM,cAAc,QAAQ,MAAM,cAAA;AAAA,EACpD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export { default as ControlledSlider } from './components/UI/ControlledSlider';
|
|
|
35
35
|
export { default as ControlledTooltip } from './components/UI/ControlledTooltip';
|
|
36
36
|
export { default as CustomBadge } from './components/UI/CustomBadge';
|
|
37
37
|
export { default as CustomCard } from './components/UI/CustomCard';
|
|
38
|
+
export type { IImageMaskPainterProps } from './components/UI/ImageMaskPainter/index';
|
|
39
|
+
export { default as ImageMaskPainter } from './components/UI/ImageMaskPainter/index';
|
|
38
40
|
export { default as InformationCard } from './components/UI/InformationCard';
|
|
39
41
|
export { default as LoadingSpinner } from './components/UI/LoadingSpinner';
|
|
40
42
|
export * from './components/UI/MaterialSymbol/index';
|
package/dist/index.js
CHANGED
|
@@ -35,12 +35,13 @@ import { default as default30 } from "./components/UI/ControlledSlider.js";
|
|
|
35
35
|
import { default as default31 } from "./components/UI/ControlledTooltip.js";
|
|
36
36
|
import { default as default32 } from "./components/UI/CustomBadge.js";
|
|
37
37
|
import { default as default33 } from "./components/UI/CustomCard.js";
|
|
38
|
-
import { default as default34 } from "./components/UI/
|
|
39
|
-
import { default as default35 } from "./components/UI/
|
|
38
|
+
import { default as default34 } from "./components/UI/ImageMaskPainter/index.js";
|
|
39
|
+
import { default as default35 } from "./components/UI/InformationCard.js";
|
|
40
|
+
import { default as default36 } from "./components/UI/LoadingSpinner.js";
|
|
40
41
|
import { MaterialSymbol, combineClasses } from "./components/UI/MaterialSymbol/index.js";
|
|
41
|
-
import { default as
|
|
42
|
-
import { default as
|
|
43
|
-
import { default as
|
|
42
|
+
import { default as default37 } from "./components/UI/NoDataFound/index.js";
|
|
43
|
+
import { default as default38 } from "./components/UI/SkeletonLoading.js";
|
|
44
|
+
import { default as default39 } from "./components/UI/UserMenu.js";
|
|
44
45
|
import { composeRefs } from "./helpers/composeRefs.js";
|
|
45
46
|
import { LAYERED_SURFACE_ATTRIBUTE, LAYERED_SURFACE_DATA_ATTRIBUTE, LAYERED_SURFACE_SELECTOR, isPressOnLayeredSurface } from "./helpers/layeredSurfaces.js";
|
|
46
47
|
import { readThemeToken, useThemeChartTokens } from "./helpers/themeTokens.js";
|
|
@@ -85,25 +86,26 @@ export {
|
|
|
85
86
|
default32 as CustomBadge,
|
|
86
87
|
default33 as CustomCard,
|
|
87
88
|
default14 as ErrorPage,
|
|
88
|
-
default34 as
|
|
89
|
+
default34 as ImageMaskPainter,
|
|
90
|
+
default35 as InformationCard,
|
|
89
91
|
LAYERED_SURFACE_ATTRIBUTE,
|
|
90
92
|
LAYERED_SURFACE_DATA_ATTRIBUTE,
|
|
91
93
|
LAYERED_SURFACE_SELECTOR,
|
|
92
94
|
default15 as LinkButton,
|
|
93
|
-
|
|
95
|
+
default36 as LoadingSpinner,
|
|
94
96
|
MOTION_OFFSET_PX,
|
|
95
97
|
MaterialSymbol,
|
|
96
|
-
|
|
98
|
+
default37 as NoDataFound,
|
|
97
99
|
default22 as OutlinedChip,
|
|
98
100
|
default16 as PageTitle,
|
|
99
101
|
PageTitleNavigationProvider,
|
|
100
102
|
default19 as ShellLanguageToggle,
|
|
101
103
|
default20 as ShellThemeToggle,
|
|
102
|
-
|
|
104
|
+
default38 as SkeletonLoading,
|
|
103
105
|
UiAccessProvider,
|
|
104
106
|
UiNavigationProvider,
|
|
105
107
|
default17 as UnifiedSearchBar,
|
|
106
|
-
|
|
108
|
+
default39 as UserMenu,
|
|
107
109
|
collapseVariants,
|
|
108
110
|
combineClasses,
|
|
109
111
|
composeRefs,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -311,7 +311,42 @@ declare const _default: {
|
|
|
311
311
|
"tryAgain": "Generate another",
|
|
312
312
|
"useResult": "Use this image",
|
|
313
313
|
"errorGenerate": "Could not adjust the image with AI",
|
|
314
|
-
"errorSave": "Could not save the adjusted image"
|
|
314
|
+
"errorSave": "Could not save the adjusted image",
|
|
315
|
+
"errorRefused": "The AI could not make this adjustment: {{reason}}",
|
|
316
|
+
"mask": {
|
|
317
|
+
"start": "Mark the area",
|
|
318
|
+
"stop": "Use the whole image",
|
|
319
|
+
"hint": "Paint the area the AI may change. The rest of the image is kept."
|
|
320
|
+
},
|
|
321
|
+
"verification": {
|
|
322
|
+
"changedMoreThanRequested": "The AI changed more than requested. Check the areas outside the adjustment before using it.",
|
|
323
|
+
"colorMismatch": "The garment color ({{dominant}}) differs from the requested color ({{target}})."
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"imageMaskPainter": {
|
|
327
|
+
"paint": "Paint",
|
|
328
|
+
"erase": "Erase",
|
|
329
|
+
"brushSize": "Brush size",
|
|
330
|
+
"undo": "Undo",
|
|
331
|
+
"clear": "Clear",
|
|
332
|
+
"surfaceLabel": "Mask painting area over the image"
|
|
333
|
+
},
|
|
334
|
+
"imageAiReview": {
|
|
335
|
+
"discardTitle": "Why are you discarding this result?",
|
|
336
|
+
"discardSubtitle": "Your answer helps us improve the AI. The image is discarded either way.",
|
|
337
|
+
"discardConfirm": "Discard",
|
|
338
|
+
"reasonLabel": "Reason",
|
|
339
|
+
"detailsLabel": "Details",
|
|
340
|
+
"detailsPlaceholder": "Optional: tell us what went wrong",
|
|
341
|
+
"reasons": {
|
|
342
|
+
"changed_the_product": "Changed the product",
|
|
343
|
+
"wrong_color": "Wrong color",
|
|
344
|
+
"bad_quality": "Bad quality",
|
|
345
|
+
"person_changed": "The person changed",
|
|
346
|
+
"text_or_logo": "Text or logo problem",
|
|
347
|
+
"not_what_i_asked": "Not what I asked for",
|
|
348
|
+
"other": "Other"
|
|
349
|
+
}
|
|
315
350
|
},
|
|
316
351
|
"imageAnnotator": {
|
|
317
352
|
"title": "Annotate image",
|
|
@@ -14,7 +14,9 @@ const filters = { "activeFilters": "Applied filters", "appliedCount_one": "{{cou
|
|
|
14
14
|
const filtersDrawer = { "selectedFilters": "Selected filters:", "pendingChanges": "Pending changes", "discardChangesTitle": "Discard changes?", "discardChangesMessage": "You have unapplied filter changes. Discard them?", "keepEditing": "Keep editing", "discard": "Discard" };
|
|
15
15
|
const followUp = { "messages": "Messages", "chat": { "loadingMessages": "Loading messages", "placeholder": "Write a message...", "invalidMessage": "Please enter a valid message", "noMessagesYet": "No messages yet", "startConversation": "Start a conversation by adding the first message", "loadError": "Messages could not be loaded", "sendFailed": "The message could not be sent. Try again.", "sendFailedInline": "Failed to send", "resend": "Resend", "discard": "Discard", "today": "Today", "yesterday": "Yesterday", "typingOne": "{{name}} is typing...", "typingMany": "{{count}} people are typing...", "someone": "Someone", "you": "You", "newMessages": "New messages", "backToLatest": "Back to latest", "deletedMessage": "Message deleted", "edited": "edited", "readBy": "Read by {{names}}", "copied": "Message copied", "replyingTo": "Replying to {{name}}", "attachmentFallback": "Attachment", "editTitle": "Edit message", "deleteTitle": "Delete message?", "deleteSubtitle": "The message will be shown as deleted for every participant", "sendHint": "Enter sends, Shift+Enter adds a line break", "formatting": "Formatting" }, "actions": { "reply": "Reply", "copy": "Copy text", "edit": "Edit", "delete": "Delete" }, "attachments": { "attach": "Attach", "pickFile": "File", "pickImage": "Image", "takePhoto": "Take photo", "dropHere": "Drop files to attach", "tooMany": "Limit of {{max}} attachments per message", "tooLarge": "The file {{name}} exceeds the 50 MB limit", "uploadFailed": "Upload failed", "uploading": "Uploading attachments...", "imagePreview": "Preview image", "showTranscript": "Show transcript", "hideTranscript": "Hide transcript" }, "voice": { "record": "Record audio", "recording": "Recording", "stop": "Finish recording", "cancel": "Cancel recording", "rerecord": "Record again", "attach": "Add to message", "discard": "Discard", "transcriptLabel": "Transcript", "transcriptPlaceholder": "The speech transcript appears here and can be edited" }, "camera": { "title": "Take photo", "unavailable": "Camera unavailable", "unavailableHint": "Check the browser camera permission", "switch": "Switch camera", "capture": "Capture photo" }, "search": { "open": "Search in conversation", "placeholder": "Search messages", "noResults": "No messages found", "error": "Messages could not be searched" } };
|
|
16
16
|
const generatedByAI = { "tooltip": "Generated by AI" };
|
|
17
|
-
const imageAiAdjust = { "action": "Adjust with AI", "title": "Adjust image with AI", "subtitle": "Describe the adjustment. The AI changes only what you ask and preserves the rest of the image.", "original": "Original", "result": "Result", "resultHint": "Describe the adjustment and click Generate to see the result here.", "promptLabel": "Desired adjustment", "promptPlaceholder": "E.g. remove the background and make it white, smooth the sleeve creases, brighten the lighting", "generate": "Generate", "generating": "Generating the image...", "tryAgain": "Generate another", "useResult": "Use this image", "errorGenerate": "Could not adjust the image with AI", "errorSave": "Could not save the adjusted image" };
|
|
17
|
+
const imageAiAdjust = { "action": "Adjust with AI", "title": "Adjust image with AI", "subtitle": "Describe the adjustment. The AI changes only what you ask and preserves the rest of the image.", "original": "Original", "result": "Result", "resultHint": "Describe the adjustment and click Generate to see the result here.", "promptLabel": "Desired adjustment", "promptPlaceholder": "E.g. remove the background and make it white, smooth the sleeve creases, brighten the lighting", "generate": "Generate", "generating": "Generating the image...", "tryAgain": "Generate another", "useResult": "Use this image", "errorGenerate": "Could not adjust the image with AI", "errorSave": "Could not save the adjusted image", "errorRefused": "The AI could not make this adjustment: {{reason}}", "mask": { "start": "Mark the area", "stop": "Use the whole image", "hint": "Paint the area the AI may change. The rest of the image is kept." }, "verification": { "changedMoreThanRequested": "The AI changed more than requested. Check the areas outside the adjustment before using it.", "colorMismatch": "The garment color ({{dominant}}) differs from the requested color ({{target}})." } };
|
|
18
|
+
const imageMaskPainter = { "paint": "Paint", "erase": "Erase", "brushSize": "Brush size", "undo": "Undo", "clear": "Clear", "surfaceLabel": "Mask painting area over the image" };
|
|
19
|
+
const imageAiReview = { "discardTitle": "Why are you discarding this result?", "discardSubtitle": "Your answer helps us improve the AI. The image is discarded either way.", "discardConfirm": "Discard", "reasonLabel": "Reason", "detailsLabel": "Details", "detailsPlaceholder": "Optional: tell us what went wrong", "reasons": { "changed_the_product": "Changed the product", "wrong_color": "Wrong color", "bad_quality": "Bad quality", "person_changed": "The person changed", "text_or_logo": "Text or logo problem", "not_what_i_asked": "Not what I asked for", "other": "Other" } };
|
|
18
20
|
const imageAnnotator = { "title": "Annotate image", "annotate": "Annotate image", "tools": { "select": "Select", "pen": "Freehand pen", "eraser": "Eraser", "arrow": "Arrow", "line": "Line", "rectangle": "Rectangle", "ellipse": "Ellipse", "text": "Text", "image": "Insert image" }, "stroke": { "thin": "Thin stroke", "medium": "Medium stroke", "thick": "Thick stroke" }, "style": { "none": "No colour", "fill": "Fill", "textBackground": "Text background", "bold": "Bold", "italic": "Italic", "alignLeft": "Align left", "alignCenter": "Align centre", "alignRight": "Align right", "border": "Image border", "shadow": "Image shadow", "font": { "small": "Small text", "medium": "Medium text", "large": "Large text" } }, "layers": { "forward": "Bring forward", "backward": "Send backward" }, "actions": { "duplicate": "Duplicate", "delete": "Delete" }, "undo": "Undo", "redo": "Redo", "clear": "Clear annotations", "textPlaceholder": "Type the text", "loadError": "Could not load the image for editing", "imageInsertFailed": "Could not insert the selected image", "sendFailed": "Could not upload the annotated image", "save": "Save annotations", "saving": "Saving..." };
|
|
19
21
|
const imageZoom = { "title": "Enlarged image", "close": "Close" };
|
|
20
22
|
const informationCard = { "defaultTitle": "Indicators Summary" };
|
|
@@ -51,6 +53,8 @@ const en = {
|
|
|
51
53
|
followUp,
|
|
52
54
|
generatedByAI,
|
|
53
55
|
imageAiAdjust,
|
|
56
|
+
imageMaskPainter,
|
|
57
|
+
imageAiReview,
|
|
54
58
|
imageAnnotator,
|
|
55
59
|
imageZoom,
|
|
56
60
|
informationCard,
|
|
@@ -89,7 +93,9 @@ export {
|
|
|
89
93
|
followUp,
|
|
90
94
|
generatedByAI,
|
|
91
95
|
imageAiAdjust,
|
|
96
|
+
imageAiReview,
|
|
92
97
|
imageAnnotator,
|
|
98
|
+
imageMaskPainter,
|
|
93
99
|
imageZoom,
|
|
94
100
|
informationCard,
|
|
95
101
|
inputField,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ui.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/locales/index.d.ts
CHANGED
|
@@ -314,6 +314,41 @@ export declare const uiLocales: {
|
|
|
314
314
|
useResult: string;
|
|
315
315
|
errorGenerate: string;
|
|
316
316
|
errorSave: string;
|
|
317
|
+
errorRefused: string;
|
|
318
|
+
mask: {
|
|
319
|
+
start: string;
|
|
320
|
+
stop: string;
|
|
321
|
+
hint: string;
|
|
322
|
+
};
|
|
323
|
+
verification: {
|
|
324
|
+
changedMoreThanRequested: string;
|
|
325
|
+
colorMismatch: string;
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
imageMaskPainter: {
|
|
329
|
+
paint: string;
|
|
330
|
+
erase: string;
|
|
331
|
+
brushSize: string;
|
|
332
|
+
undo: string;
|
|
333
|
+
clear: string;
|
|
334
|
+
surfaceLabel: string;
|
|
335
|
+
};
|
|
336
|
+
imageAiReview: {
|
|
337
|
+
discardTitle: string;
|
|
338
|
+
discardSubtitle: string;
|
|
339
|
+
discardConfirm: string;
|
|
340
|
+
reasonLabel: string;
|
|
341
|
+
detailsLabel: string;
|
|
342
|
+
detailsPlaceholder: string;
|
|
343
|
+
reasons: {
|
|
344
|
+
changed_the_product: string;
|
|
345
|
+
wrong_color: string;
|
|
346
|
+
bad_quality: string;
|
|
347
|
+
person_changed: string;
|
|
348
|
+
text_or_logo: string;
|
|
349
|
+
not_what_i_asked: string;
|
|
350
|
+
other: string;
|
|
351
|
+
};
|
|
317
352
|
};
|
|
318
353
|
imageAnnotator: {
|
|
319
354
|
title: string;
|
|
@@ -832,6 +867,41 @@ export declare const uiLocales: {
|
|
|
832
867
|
useResult: string;
|
|
833
868
|
errorGenerate: string;
|
|
834
869
|
errorSave: string;
|
|
870
|
+
errorRefused: string;
|
|
871
|
+
mask: {
|
|
872
|
+
start: string;
|
|
873
|
+
stop: string;
|
|
874
|
+
hint: string;
|
|
875
|
+
};
|
|
876
|
+
verification: {
|
|
877
|
+
changedMoreThanRequested: string;
|
|
878
|
+
colorMismatch: string;
|
|
879
|
+
};
|
|
880
|
+
};
|
|
881
|
+
imageMaskPainter: {
|
|
882
|
+
paint: string;
|
|
883
|
+
erase: string;
|
|
884
|
+
brushSize: string;
|
|
885
|
+
undo: string;
|
|
886
|
+
clear: string;
|
|
887
|
+
surfaceLabel: string;
|
|
888
|
+
};
|
|
889
|
+
imageAiReview: {
|
|
890
|
+
discardTitle: string;
|
|
891
|
+
discardSubtitle: string;
|
|
892
|
+
discardConfirm: string;
|
|
893
|
+
reasonLabel: string;
|
|
894
|
+
detailsLabel: string;
|
|
895
|
+
detailsPlaceholder: string;
|
|
896
|
+
reasons: {
|
|
897
|
+
changed_the_product: string;
|
|
898
|
+
wrong_color: string;
|
|
899
|
+
bad_quality: string;
|
|
900
|
+
person_changed: string;
|
|
901
|
+
text_or_logo: string;
|
|
902
|
+
not_what_i_asked: string;
|
|
903
|
+
other: string;
|
|
904
|
+
};
|
|
835
905
|
};
|
|
836
906
|
imageAnnotator: {
|
|
837
907
|
title: string;
|
|
@@ -311,7 +311,42 @@ declare const _default: {
|
|
|
311
311
|
"tryAgain": "Gerar outra",
|
|
312
312
|
"useResult": "Usar esta imagem",
|
|
313
313
|
"errorGenerate": "Não foi possível ajustar a imagem com IA",
|
|
314
|
-
"errorSave": "Não foi possível salvar a imagem ajustada"
|
|
314
|
+
"errorSave": "Não foi possível salvar a imagem ajustada",
|
|
315
|
+
"errorRefused": "A IA não conseguiu fazer este ajuste: {{reason}}",
|
|
316
|
+
"mask": {
|
|
317
|
+
"start": "Marcar a área",
|
|
318
|
+
"stop": "Usar a imagem toda",
|
|
319
|
+
"hint": "Pinte a área que a IA pode alterar. O resto da imagem é mantido."
|
|
320
|
+
},
|
|
321
|
+
"verification": {
|
|
322
|
+
"changedMoreThanRequested": "A IA mudou mais do que o pedido. Confira as áreas fora do ajuste antes de usar.",
|
|
323
|
+
"colorMismatch": "A cor da peça ({{dominant}}) ficou diferente da cor pedida ({{target}})."
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"imageMaskPainter": {
|
|
327
|
+
"paint": "Pintar",
|
|
328
|
+
"erase": "Apagar",
|
|
329
|
+
"brushSize": "Tamanho do pincel",
|
|
330
|
+
"undo": "Desfazer",
|
|
331
|
+
"clear": "Limpar",
|
|
332
|
+
"surfaceLabel": "Área de pintura da máscara sobre a imagem"
|
|
333
|
+
},
|
|
334
|
+
"imageAiReview": {
|
|
335
|
+
"discardTitle": "Por que descartar este resultado?",
|
|
336
|
+
"discardSubtitle": "Sua resposta ajuda a melhorar a IA. A imagem é descartada de qualquer forma.",
|
|
337
|
+
"discardConfirm": "Descartar",
|
|
338
|
+
"reasonLabel": "Motivo",
|
|
339
|
+
"detailsLabel": "Detalhes",
|
|
340
|
+
"detailsPlaceholder": "Opcional: conte o que deu errado",
|
|
341
|
+
"reasons": {
|
|
342
|
+
"changed_the_product": "Alterou o produto",
|
|
343
|
+
"wrong_color": "Cor errada",
|
|
344
|
+
"bad_quality": "Baixa qualidade",
|
|
345
|
+
"person_changed": "A pessoa mudou",
|
|
346
|
+
"text_or_logo": "Problema com texto ou logo",
|
|
347
|
+
"not_what_i_asked": "Não é o que pedi",
|
|
348
|
+
"other": "Outro"
|
|
349
|
+
}
|
|
315
350
|
},
|
|
316
351
|
"imageAnnotator": {
|
|
317
352
|
"title": "Anotar imagem",
|
|
@@ -14,7 +14,9 @@ const filters = { "activeFilters": "Filtros aplicados", "appliedCount_one": "{{c
|
|
|
14
14
|
const filtersDrawer = { "selectedFilters": "Filtros Selecionados:", "pendingChanges": "Alterações pendentes", "discardChangesTitle": "Descartar alterações?", "discardChangesMessage": "Você tem alterações de filtro não aplicadas. Deseja descartá-las?", "keepEditing": "Continuar editando", "discard": "Descartar" };
|
|
15
15
|
const followUp = { "messages": "Mensagens", "chat": { "loadingMessages": "Carregando mensagens", "placeholder": "Escrever mensagem...", "invalidMessage": "Por favor, insira uma mensagem válida", "noMessagesYet": "Nenhuma mensagem por enquanto", "startConversation": "Inicie uma conversa adicionando a primeira mensagem", "loadError": "Não foi possível carregar as mensagens", "sendFailed": "Não foi possível enviar a mensagem. Tente novamente.", "sendFailedInline": "Falha no envio", "resend": "Reenviar", "discard": "Descartar", "today": "Hoje", "yesterday": "Ontem", "typingOne": "{{name}} está digitando...", "typingMany": "{{count}} pessoas estão digitando...", "someone": "Alguém", "you": "Você", "newMessages": "Novas mensagens", "backToLatest": "Voltar para as recentes", "deletedMessage": "Mensagem apagada", "edited": "editada", "readBy": "Lida por {{names}}", "copied": "Mensagem copiada", "replyingTo": "Respondendo a {{name}}", "attachmentFallback": "Anexo", "editTitle": "Editar mensagem", "deleteTitle": "Apagar mensagem?", "deleteSubtitle": "A mensagem será marcada como apagada para todos os participantes", "sendHint": "Enter envia, Shift+Enter quebra a linha", "formatting": "Formatação" }, "actions": { "reply": "Responder", "copy": "Copiar texto", "edit": "Editar", "delete": "Apagar" }, "attachments": { "attach": "Anexar", "pickFile": "Arquivo", "pickImage": "Imagem", "takePhoto": "Tirar foto", "dropHere": "Solte os arquivos para anexar", "tooMany": "Limite de {{max}} anexos por mensagem", "tooLarge": "O arquivo {{name}} passa do limite de 50 MB", "uploadFailed": "Falha no upload", "uploading": "Enviando anexos...", "imagePreview": "Visualizar imagem", "showTranscript": "Ver transcrição", "hideTranscript": "Ocultar transcrição" }, "voice": { "record": "Gravar áudio", "recording": "Gravando", "stop": "Concluir gravação", "cancel": "Cancelar gravação", "rerecord": "Regravar", "attach": "Adicionar ao envio", "discard": "Descartar", "transcriptLabel": "Transcrição", "transcriptPlaceholder": "A transcrição da fala aparece aqui e pode ser editada" }, "camera": { "title": "Tirar foto", "unavailable": "Câmera indisponível", "unavailableHint": "Verifique a permissão de câmera do navegador", "switch": "Alternar câmera", "capture": "Capturar foto" }, "search": { "open": "Buscar na conversa", "placeholder": "Buscar mensagens", "noResults": "Nenhuma mensagem encontrada", "error": "Não foi possível buscar as mensagens" } };
|
|
16
16
|
const generatedByAI = { "tooltip": "Gerado por IA" };
|
|
17
|
-
const imageAiAdjust = { "action": "Ajustar com IA", "title": "Ajustar imagem com IA", "subtitle": "Descreva o ajuste. A IA altera só o que você pedir e preserva o resto da imagem.", "original": "Original", "result": "Resultado", "resultHint": "Descreva o ajuste e clique em Gerar para ver o resultado aqui.", "promptLabel": "Ajuste desejado", "promptPlaceholder": "Ex.: remover o fundo e deixar branco, tirar os vincos da manga, clarear a iluminação", "generate": "Gerar", "generating": "Gerando a imagem...", "tryAgain": "Gerar outra", "useResult": "Usar esta imagem", "errorGenerate": "Não foi possível ajustar a imagem com IA", "errorSave": "Não foi possível salvar a imagem ajustada" };
|
|
17
|
+
const imageAiAdjust = { "action": "Ajustar com IA", "title": "Ajustar imagem com IA", "subtitle": "Descreva o ajuste. A IA altera só o que você pedir e preserva o resto da imagem.", "original": "Original", "result": "Resultado", "resultHint": "Descreva o ajuste e clique em Gerar para ver o resultado aqui.", "promptLabel": "Ajuste desejado", "promptPlaceholder": "Ex.: remover o fundo e deixar branco, tirar os vincos da manga, clarear a iluminação", "generate": "Gerar", "generating": "Gerando a imagem...", "tryAgain": "Gerar outra", "useResult": "Usar esta imagem", "errorGenerate": "Não foi possível ajustar a imagem com IA", "errorSave": "Não foi possível salvar a imagem ajustada", "errorRefused": "A IA não conseguiu fazer este ajuste: {{reason}}", "mask": { "start": "Marcar a área", "stop": "Usar a imagem toda", "hint": "Pinte a área que a IA pode alterar. O resto da imagem é mantido." }, "verification": { "changedMoreThanRequested": "A IA mudou mais do que o pedido. Confira as áreas fora do ajuste antes de usar.", "colorMismatch": "A cor da peça ({{dominant}}) ficou diferente da cor pedida ({{target}})." } };
|
|
18
|
+
const imageMaskPainter = { "paint": "Pintar", "erase": "Apagar", "brushSize": "Tamanho do pincel", "undo": "Desfazer", "clear": "Limpar", "surfaceLabel": "Área de pintura da máscara sobre a imagem" };
|
|
19
|
+
const imageAiReview = { "discardTitle": "Por que descartar este resultado?", "discardSubtitle": "Sua resposta ajuda a melhorar a IA. A imagem é descartada de qualquer forma.", "discardConfirm": "Descartar", "reasonLabel": "Motivo", "detailsLabel": "Detalhes", "detailsPlaceholder": "Opcional: conte o que deu errado", "reasons": { "changed_the_product": "Alterou o produto", "wrong_color": "Cor errada", "bad_quality": "Baixa qualidade", "person_changed": "A pessoa mudou", "text_or_logo": "Problema com texto ou logo", "not_what_i_asked": "Não é o que pedi", "other": "Outro" } };
|
|
18
20
|
const imageAnnotator = { "title": "Anotar imagem", "annotate": "Anotar imagem", "tools": { "select": "Selecionar", "pen": "Caneta livre", "eraser": "Borracha", "arrow": "Seta", "line": "Linha", "rectangle": "Retângulo", "ellipse": "Elipse", "text": "Texto", "image": "Inserir imagem" }, "stroke": { "thin": "Traço fino", "medium": "Traço médio", "thick": "Traço grosso" }, "style": { "none": "Sem cor", "fill": "Preenchimento", "textBackground": "Fundo do texto", "bold": "Negrito", "italic": "Itálico", "alignLeft": "Alinhar à esquerda", "alignCenter": "Centralizar", "alignRight": "Alinhar à direita", "border": "Borda da imagem", "shadow": "Sombra da imagem", "font": { "small": "Texto pequeno", "medium": "Texto médio", "large": "Texto grande" } }, "layers": { "forward": "Trazer para frente", "backward": "Enviar para trás" }, "actions": { "duplicate": "Duplicar", "delete": "Excluir" }, "undo": "Desfazer", "redo": "Refazer", "clear": "Limpar anotações", "textPlaceholder": "Digite o texto", "loadError": "Não foi possível carregar a imagem para edição", "imageInsertFailed": "Não foi possível inserir a imagem selecionada", "sendFailed": "Não foi possível enviar a imagem anotada", "save": "Salvar anotações", "saving": "Salvando..." };
|
|
19
21
|
const imageZoom = { "title": "Imagem ampliada", "close": "Fechar" };
|
|
20
22
|
const informationCard = { "defaultTitle": "Resumo dos Indicadores" };
|
|
@@ -51,6 +53,8 @@ const pt = {
|
|
|
51
53
|
followUp,
|
|
52
54
|
generatedByAI,
|
|
53
55
|
imageAiAdjust,
|
|
56
|
+
imageMaskPainter,
|
|
57
|
+
imageAiReview,
|
|
54
58
|
imageAnnotator,
|
|
55
59
|
imageZoom,
|
|
56
60
|
informationCard,
|
|
@@ -89,7 +93,9 @@ export {
|
|
|
89
93
|
followUp,
|
|
90
94
|
generatedByAI,
|
|
91
95
|
imageAiAdjust,
|
|
96
|
+
imageAiReview,
|
|
92
97
|
imageAnnotator,
|
|
98
|
+
imageMaskPainter,
|
|
93
99
|
imageZoom,
|
|
94
100
|
informationCard,
|
|
95
101
|
inputField,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ui.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|