@edv4h/usketch-plugin-shape-image 1.0.0 → 3.0.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/external-content-handler.d.ts +30 -0
- package/dist/external-content-handler.d.ts.map +1 -0
- package/dist/external-content-handler.js +105 -0
- package/dist/external-content-handler.js.map +1 -0
- package/dist/image-utils.d.ts +24 -0
- package/dist/image-utils.d.ts.map +1 -0
- package/dist/image-utils.js +113 -0
- package/dist/image-utils.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +63 -17
- package/dist/plugin.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ExternalContentHandler, ExternalContentOf } from "@edv4h/usketch-shared";
|
|
2
|
+
export interface ImageFileHandlerOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Max accepted size per file. Default 4 (MB). Larger files are rejected and
|
|
5
|
+
* the handler emits an `ai:status` error event so the host UI can surface
|
|
6
|
+
* the failure.
|
|
7
|
+
*/
|
|
8
|
+
maxSizeMB?: number;
|
|
9
|
+
/** Resize threshold in pixels for the longest dimension. Default 2048. */
|
|
10
|
+
maxDimension?: number;
|
|
11
|
+
/** Default 0 (lowest, so third-party plugins win). */
|
|
12
|
+
order?: number;
|
|
13
|
+
/** Cap on the displayed shape width/height in world units. Default 400. */
|
|
14
|
+
maxRenderedSize?: number;
|
|
15
|
+
/** Horizontal gap (world units) when laying out multiple files. Default 20. */
|
|
16
|
+
gap?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Default external-content handler that turns a drop / paste of image files
|
|
20
|
+
* into image shapes on the canvas. Registered at `order: 0` (lowest) so
|
|
21
|
+
* any third-party plugin can override by registering with a higher order.
|
|
22
|
+
*
|
|
23
|
+
* The shape is placed centered on the current viewport because the
|
|
24
|
+
* external-content payload intentionally does not carry a drop/paste world
|
|
25
|
+
* point — handlers decide their own placement strategy. A future canvas-engine
|
|
26
|
+
* read API may expose the last pointer position for handlers that want it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createImageFileHandler(options?: ImageFileHandlerOptions): ExternalContentHandler<"file">;
|
|
29
|
+
export type ImageFileContent = ExternalContentOf<"file">;
|
|
30
|
+
//# sourceMappingURL=external-content-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-content-handler.d.ts","sourceRoot":"","sources":["../src/external-content-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,sBAAsB,EAEtB,iBAAiB,EACjB,MAAM,uBAAuB,CAAC;AAI/B,MAAM,WAAW,uBAAuB;IACvC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACrC,OAAO,GAAE,uBAA4B,GACnC,sBAAsB,CAAC,MAAM,CAAC,CA6BhC;AA6FD,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { generateId } from "@edv4h/usketch-shared";
|
|
2
|
+
import { fileToBase64, getImageDimensions, resizeImage, validateImage } from "./image-utils.js";
|
|
3
|
+
/**
|
|
4
|
+
* Default external-content handler that turns a drop / paste of image files
|
|
5
|
+
* into image shapes on the canvas. Registered at `order: 0` (lowest) so
|
|
6
|
+
* any third-party plugin can override by registering with a higher order.
|
|
7
|
+
*
|
|
8
|
+
* The shape is placed centered on the current viewport because the
|
|
9
|
+
* external-content payload intentionally does not carry a drop/paste world
|
|
10
|
+
* point — handlers decide their own placement strategy. A future canvas-engine
|
|
11
|
+
* read API may expose the last pointer position for handlers that want it.
|
|
12
|
+
*/
|
|
13
|
+
export function createImageFileHandler(options = {}) {
|
|
14
|
+
const { maxSizeMB = 4, maxDimension = 2048, order = 0, maxRenderedSize = 400, gap = 20, } = options;
|
|
15
|
+
return {
|
|
16
|
+
id: "usketch-plugin-shape-image:image-file",
|
|
17
|
+
kind: "file",
|
|
18
|
+
order,
|
|
19
|
+
match: (content) => content.files.length > 0 && content.files.every((f) => f.type.startsWith("image/")),
|
|
20
|
+
handle: async (content, ctx) => {
|
|
21
|
+
const base = viewportCenterToWorld(ctx);
|
|
22
|
+
let offsetX = 0;
|
|
23
|
+
for (const file of content.files) {
|
|
24
|
+
await placeImageShape(file, ctx, {
|
|
25
|
+
worldPoint: { x: base.x + offsetX, y: base.y },
|
|
26
|
+
maxSizeMB,
|
|
27
|
+
maxDimension,
|
|
28
|
+
maxRenderedSize,
|
|
29
|
+
});
|
|
30
|
+
offsetX += maxRenderedSize + gap;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Convert the visible screen center to world coordinates using the current
|
|
37
|
+
* viewport. The world-space center is `viewport-screen-center / zoom - viewport-origin`,
|
|
38
|
+
* accounting for pan and zoom so dropped/pasted images land where the user
|
|
39
|
+
* is actually looking — not at an arbitrary screen-space point.
|
|
40
|
+
*/
|
|
41
|
+
function viewportCenterToWorld(ctx) {
|
|
42
|
+
const vp = ctx.store.getViewport();
|
|
43
|
+
const screenW = typeof window !== "undefined" ? window.innerWidth : 0;
|
|
44
|
+
const screenH = typeof window !== "undefined" ? window.innerHeight : 0;
|
|
45
|
+
return {
|
|
46
|
+
x: (screenW / 2 - vp.x) / vp.zoom,
|
|
47
|
+
y: (screenH / 2 - vp.y) / vp.zoom,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async function placeImageShape(file, ctx, opts) {
|
|
51
|
+
const validation = validateImage(file, opts.maxSizeMB);
|
|
52
|
+
if (!validation.valid) {
|
|
53
|
+
// Same status channel ai-image used. Hosts that subscribe still see errors.
|
|
54
|
+
ctx.events.emit("ai:status", { status: "error", message: validation.error });
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let dataUrl;
|
|
58
|
+
try {
|
|
59
|
+
dataUrl = await fileToBase64(file);
|
|
60
|
+
dataUrl = await resizeImage(dataUrl, opts.maxDimension);
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
ctx.events.emit("ai:status", {
|
|
64
|
+
status: "error",
|
|
65
|
+
message: err instanceof Error ? err.message : "Failed to process image",
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
let dimensions;
|
|
70
|
+
try {
|
|
71
|
+
dimensions = await getImageDimensions(dataUrl);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
ctx.events.emit("ai:status", {
|
|
75
|
+
status: "error",
|
|
76
|
+
message: err instanceof Error ? err.message : "Failed to read image",
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const scale = Math.min(opts.maxRenderedSize / dimensions.width, opts.maxRenderedSize / dimensions.height, 1);
|
|
81
|
+
const w = Math.round(dimensions.width * scale);
|
|
82
|
+
const h = Math.round(dimensions.height * scale);
|
|
83
|
+
const id = generateId();
|
|
84
|
+
const shape = {
|
|
85
|
+
id,
|
|
86
|
+
type: "image",
|
|
87
|
+
x: Math.round(opts.worldPoint.x - w / 2),
|
|
88
|
+
y: Math.round(opts.worldPoint.y - h / 2),
|
|
89
|
+
width: w,
|
|
90
|
+
height: h,
|
|
91
|
+
style: {
|
|
92
|
+
fill: "#f5f5f5",
|
|
93
|
+
stroke: "#e0e0e0",
|
|
94
|
+
strokeWidth: 1,
|
|
95
|
+
opacity: 1,
|
|
96
|
+
},
|
|
97
|
+
src: dataUrl,
|
|
98
|
+
};
|
|
99
|
+
ctx.commands.execute({
|
|
100
|
+
execute: () => ctx.store.addShape(shape),
|
|
101
|
+
undo: () => ctx.store.deleteShape(id),
|
|
102
|
+
});
|
|
103
|
+
ctx.store.setSelection([id]);
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=external-content-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-content-handler.js","sourceRoot":"","sources":["../src/external-content-handler.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAmBhG;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CACrC,UAAmC,EAAE;IAErC,MAAM,EACL,SAAS,GAAG,CAAC,EACb,YAAY,GAAG,IAAI,EACnB,KAAK,GAAG,CAAC,EACT,eAAe,GAAG,GAAG,EACrB,GAAG,GAAG,EAAE,GACR,GAAG,OAAO,CAAC;IAEZ,OAAO;QACN,EAAE,EAAE,uCAAuC;QAC3C,IAAI,EAAE,MAAM;QACZ,KAAK;QACL,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAClB,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACpF,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE;YAC9B,MAAM,IAAI,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;YACxC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M,EAAE,GAAG,UAAU,EAAE,CAAC;IACxB,MAAM,KAAK,GAAG;QACb,EAAE;QACF,IAAI,EAAE,OAAO;QACb,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxC,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,KAAK,EAAE;YACN,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,SAAS;YACjB,WAAW,EAAE,CAAC;YACd,OAAO,EAAE,CAAC;SACV;QACD,GAAG,EAAE,OAAO;KACZ,CAAC;IAEF,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC;QACpB,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QACxC,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;KACrC,CAAC,CAAC;IACH,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Convert File to base64 data URL */
|
|
2
|
+
export declare function fileToBase64(file: File): Promise<string>;
|
|
3
|
+
/**
|
|
4
|
+
* Resize an image data URL if it exceeds `maxDim` along the longest side.
|
|
5
|
+
* Preserves the source MIME type (`image/jpeg`, `image/webp`, …) so a JPEG
|
|
6
|
+
* stays a JPEG instead of being re-encoded as a PNG — which would inflate
|
|
7
|
+
* board payloads (especially photos), since `validateImage` only checks the
|
|
8
|
+
* pre-resize `File.size`.
|
|
9
|
+
*
|
|
10
|
+
* `quality` is applied for lossy encoders (JPEG / WebP); PNG ignores it.
|
|
11
|
+
* MIME types the canvas can't encode fall back to JPEG.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resizeImage(dataUrl: string, maxDim: number, quality?: number): Promise<string>;
|
|
14
|
+
/** Validate image file type and size */
|
|
15
|
+
export declare function validateImage(file: File, maxSizeMB: number): {
|
|
16
|
+
valid: boolean;
|
|
17
|
+
error?: string;
|
|
18
|
+
};
|
|
19
|
+
/** Read the natural pixel dimensions of an image data URL. */
|
|
20
|
+
export declare function getImageDimensions(dataUrl: string): Promise<{
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}>;
|
|
24
|
+
//# sourceMappingURL=image-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-utils.d.ts","sourceRoot":"","sources":["../src/image-utils.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,wBAAsB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAO9D;AAED;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAChC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,OAAO,SAAO,GACZ,OAAO,CAAC,MAAM,CAAC,CAgCjB;AA0CD,wCAAwC;AACxC,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAc/F;AAED,8DAA8D;AAC9D,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAO9F"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/** Convert File to base64 data URL */
|
|
2
|
+
export async function fileToBase64(file) {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
const reader = new FileReader();
|
|
5
|
+
reader.onload = () => resolve(reader.result);
|
|
6
|
+
reader.onerror = () => reject(new Error("Failed to read file"));
|
|
7
|
+
reader.readAsDataURL(file);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resize an image data URL if it exceeds `maxDim` along the longest side.
|
|
12
|
+
* Preserves the source MIME type (`image/jpeg`, `image/webp`, …) so a JPEG
|
|
13
|
+
* stays a JPEG instead of being re-encoded as a PNG — which would inflate
|
|
14
|
+
* board payloads (especially photos), since `validateImage` only checks the
|
|
15
|
+
* pre-resize `File.size`.
|
|
16
|
+
*
|
|
17
|
+
* `quality` is applied for lossy encoders (JPEG / WebP); PNG ignores it.
|
|
18
|
+
* MIME types the canvas can't encode fall back to JPEG.
|
|
19
|
+
*/
|
|
20
|
+
export async function resizeImage(dataUrl, maxDim, quality = 0.85) {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const img = new Image();
|
|
23
|
+
img.onload = () => {
|
|
24
|
+
const { width, height } = img;
|
|
25
|
+
if (width <= maxDim && height <= maxDim) {
|
|
26
|
+
resolve(dataUrl);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const scale = Math.min(maxDim / width, maxDim / height);
|
|
30
|
+
const newWidth = Math.round(width * scale);
|
|
31
|
+
const newHeight = Math.round(height * scale);
|
|
32
|
+
const canvas = document.createElement("canvas");
|
|
33
|
+
canvas.width = newWidth;
|
|
34
|
+
canvas.height = newHeight;
|
|
35
|
+
const ctx = canvas.getContext("2d");
|
|
36
|
+
if (!ctx) {
|
|
37
|
+
reject(new Error("Failed to get canvas context"));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
ctx.drawImage(img, 0, 0, newWidth, newHeight);
|
|
41
|
+
const outputMime = pickOutputMime(dataUrl);
|
|
42
|
+
resolve(canvas.toDataURL(outputMime, quality));
|
|
43
|
+
};
|
|
44
|
+
img.onerror = () => reject(new Error("Failed to load image"));
|
|
45
|
+
img.src = dataUrl;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
let webpEncodeSupportCache = null;
|
|
49
|
+
/**
|
|
50
|
+
* Detect whether `HTMLCanvasElement.toDataURL("image/webp")` actually emits
|
|
51
|
+
* WebP in this browser. Safari < 16 silently returns PNG for unsupported
|
|
52
|
+
* MIMEs, which would defeat the "preserve format" intent of `resizeImage`.
|
|
53
|
+
* The result is cached for the lifetime of the module.
|
|
54
|
+
*/
|
|
55
|
+
function canEncodeWebp() {
|
|
56
|
+
if (webpEncodeSupportCache !== null)
|
|
57
|
+
return webpEncodeSupportCache;
|
|
58
|
+
if (typeof document === "undefined") {
|
|
59
|
+
webpEncodeSupportCache = false;
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const probe = document.createElement("canvas");
|
|
64
|
+
probe.width = 1;
|
|
65
|
+
probe.height = 1;
|
|
66
|
+
webpEncodeSupportCache = probe.toDataURL("image/webp").startsWith("data:image/webp");
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
webpEncodeSupportCache = false;
|
|
70
|
+
}
|
|
71
|
+
return webpEncodeSupportCache;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Return a MIME the canvas can encode that preserves the source format.
|
|
75
|
+
* - `image/png` stays PNG (alpha + lossless).
|
|
76
|
+
* - `image/webp` stays WebP **only if the current browser can actually encode
|
|
77
|
+
* WebP**; otherwise falls back to JPEG (avoiding the PNG silent fallback
|
|
78
|
+
* that defeats the size-saving intent).
|
|
79
|
+
* - Everything else (jpeg, heic, svg, avif, …) is re-encoded as JPEG.
|
|
80
|
+
*/
|
|
81
|
+
function pickOutputMime(dataUrl) {
|
|
82
|
+
const match = /^data:(image\/[^;]+);/.exec(dataUrl);
|
|
83
|
+
const sourceMime = match?.[1]?.toLowerCase();
|
|
84
|
+
if (sourceMime === "image/png")
|
|
85
|
+
return "image/png";
|
|
86
|
+
if (sourceMime === "image/webp" && canEncodeWebp())
|
|
87
|
+
return "image/webp";
|
|
88
|
+
return "image/jpeg";
|
|
89
|
+
}
|
|
90
|
+
/** Validate image file type and size */
|
|
91
|
+
export function validateImage(file, maxSizeMB) {
|
|
92
|
+
if (!file.type.startsWith("image/")) {
|
|
93
|
+
return { valid: false, error: `Invalid file type: ${file.type}. Expected an image.` };
|
|
94
|
+
}
|
|
95
|
+
const maxBytes = maxSizeMB * 1024 * 1024;
|
|
96
|
+
if (file.size > maxBytes) {
|
|
97
|
+
return {
|
|
98
|
+
valid: false,
|
|
99
|
+
error: `File too large: ${(file.size / 1024 / 1024).toFixed(1)}MB. Maximum is ${maxSizeMB}MB.`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return { valid: true };
|
|
103
|
+
}
|
|
104
|
+
/** Read the natural pixel dimensions of an image data URL. */
|
|
105
|
+
export function getImageDimensions(dataUrl) {
|
|
106
|
+
return new Promise((resolve, reject) => {
|
|
107
|
+
const img = new Image();
|
|
108
|
+
img.onload = () => resolve({ width: img.naturalWidth, height: img.naturalHeight });
|
|
109
|
+
img.onerror = () => reject(new Error("Failed to load image"));
|
|
110
|
+
img.src = dataUrl;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=image-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-utils.js","sourceRoot":"","sources":["../src/image-utils.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAU;IAC5C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;QACvD,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;QAChE,MAA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ist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createImageShapePlugin } from "./plugin.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":"AAAA,OAAO,EAON,KAAK,aAAa,EAElB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":"AAAA,OAAO,EAON,KAAK,aAAa,EAElB,MAAM,uBAAuB,CAAC;AA8I/B,wBAAgB,sBAAsB,IAAI,aAAa,CA6BtD"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { DEFAULT_STYLE, withRotation, } from "@edv4h/usketch-shared";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { createImageFileHandler } from "./external-content-handler.js";
|
|
4
|
+
function render(shape) {
|
|
5
|
+
const data = shape;
|
|
6
|
+
const src = data.src || undefined;
|
|
5
7
|
return (_jsx("div", { style: {
|
|
6
8
|
width: "100%",
|
|
7
9
|
height: "100%",
|
|
@@ -82,19 +84,63 @@ function createDefault(params) {
|
|
|
82
84
|
src: "",
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
87
|
+
function serializeForAi(shape) {
|
|
88
|
+
const data = shape;
|
|
89
|
+
if (!data.src)
|
|
90
|
+
return {};
|
|
91
|
+
// Image `src` can be a base64 Data URL that easily blows past LLM token
|
|
92
|
+
// budgets (and may leak embedded image bytes into prompts). Return a small
|
|
93
|
+
// summary instead — the shape's `type === "image"` already tells the AI
|
|
94
|
+
// this is an image; consumers who actually need pixel data should use
|
|
95
|
+
// `serializeForRecognition`.
|
|
96
|
+
const isDataUrl = data.src.startsWith("data:");
|
|
97
|
+
return isDataUrl
|
|
98
|
+
? { srcKind: "data", srcLength: data.src.length }
|
|
99
|
+
: { srcKind: "url", srcOrigin: safeOrigin(data.src) };
|
|
100
|
+
}
|
|
101
|
+
function safeOrigin(url) {
|
|
102
|
+
try {
|
|
103
|
+
return new URL(url).origin;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return "<invalid>";
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function serializeForRecognition(shape) {
|
|
110
|
+
const data = shape;
|
|
111
|
+
if (!data.src)
|
|
112
|
+
return null;
|
|
113
|
+
return { kind: "image", src: data.src };
|
|
114
|
+
}
|
|
115
|
+
function debugFields(shape) {
|
|
116
|
+
const data = shape;
|
|
117
|
+
return { src: data.src ?? "" };
|
|
118
|
+
}
|
|
119
|
+
export function createImageShapePlugin() {
|
|
120
|
+
return {
|
|
121
|
+
id: "usketch-plugin-shape-image",
|
|
122
|
+
name: "画像",
|
|
123
|
+
setup(ctx) {
|
|
124
|
+
ctx.shapes.register("image", {
|
|
125
|
+
render,
|
|
126
|
+
getBounds,
|
|
127
|
+
hitTest: withRotation(hitTest),
|
|
128
|
+
resize,
|
|
129
|
+
createDefault,
|
|
130
|
+
renderTarget: "html",
|
|
131
|
+
minSize: { width: 40, height: 40 },
|
|
132
|
+
serializeForAi,
|
|
133
|
+
serializeForRecognition,
|
|
134
|
+
debugFields,
|
|
135
|
+
});
|
|
136
|
+
// Self-register the default "image file → image shape" external-content
|
|
137
|
+
// handler at order 0. Apps and third-party plugins can override by
|
|
138
|
+
// registering a higher-`order` `kind: "file"` handler.
|
|
139
|
+
const unregisterHandler = ctx.externalContent.register(createImageFileHandler());
|
|
140
|
+
return () => {
|
|
141
|
+
unregisterHandler();
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
100
146
|
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEN,aAAa,EAMb,YAAY,GACZ,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEN,aAAa,EAMb,YAAY,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAGvE,SAAS,MAAM,CAAC,KAAgB;IAC/B,MAAM,IAAI,GAAG,KAAuB,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,SAAS,CAAC;IAClC,O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AE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,mEAAmE;AACnE,MAAM,WAAW,cAAe,SAAQ,SAAS;IAChD,GAAG,EAAE,MAAM,CAAC;CACZ"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edv4h/usketch-plugin-shape-image",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@edv4h/usketch-shared": "
|
|
15
|
+
"@edv4h/usketch-shared": "3.0.0"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": ">=19"
|