@orangecatai/adgen-canvas 0.0.32 → 0.0.33
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/dev/{chunk-VL47Q2RH.js → chunk-BSCN3CPW.js} +2 -2
- package/dist/dev/{chunk-OWDDSUUQ.js → chunk-O66HSY73.js} +3 -3
- package/dist/dev/data/{image-5Y3GORNT.js → image-ADAEIYVZ.js} +3 -3
- package/dist/dev/index.css +3 -0
- package/dist/dev/index.css.map +2 -2
- package/dist/dev/index.js +206 -95
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/{chunk-452N23ZE.js → chunk-DB27YYNM.js} +1 -1
- package/dist/prod/{chunk-AQSA3HNR.js → chunk-MBLHWEZ7.js} +2 -2
- package/dist/prod/data/image-ALVZ6E6S.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +57 -57
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/excalidraw/components/ai-chat/imagePayload.d.ts +70 -0
- package/package.json +1 -1
- package/dist/prod/data/image-5D6ZUEOG.js +0 -1
- /package/dist/dev/{chunk-VL47Q2RH.js.map → chunk-BSCN3CPW.js.map} +0 -0
- /package/dist/dev/{chunk-OWDDSUUQ.js.map → chunk-O66HSY73.js.map} +0 -0
- /package/dist/dev/data/{image-5Y3GORNT.js.map → image-ADAEIYVZ.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"./chunk-Z5NKEFVG.js";import"./chunk-
|
|
1
|
+
import{a,b,c,d}from"./chunk-Z5NKEFVG.js";import"./chunk-DB27YYNM.js";import"./chunk-SRAX5OIU.js";export{a as Commands,b as subsetToBase64,c as subsetToBinary,d as toBase64};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r,c as t}from"./chunk-Z5NKEFVG.js";import"./chunk-
|
|
1
|
+
import{a as r,c as t}from"./chunk-Z5NKEFVG.js";import"./chunk-DB27YYNM.js";import"./chunk-SRAX5OIU.js";var s=import.meta.url?new URL(import.meta.url):void 0;typeof window>"u"&&typeof self<"u"&&(self.onmessage=async e=>{switch(e.data.command){case r.Subset:let a=await t(e.data.arrayBuffer,e.data.codePoints);self.postMessage(a,{transfer:[a]});break}});export{s as WorkerUrl};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload-size normalisation for images sent to the chat API.
|
|
3
|
+
*
|
|
4
|
+
* Every `image_url` content block in a chat request travels as a base64 data
|
|
5
|
+
* URL embedded in JSON. Base64 inflates bytes by 4/3, and the host proxy runs
|
|
6
|
+
* on Vercel, whose platform-level request cap is 4.5 MB — enforced at the edge
|
|
7
|
+
* *before* the route handler runs, so it surfaces as an opaque 413 that never
|
|
8
|
+
* reaches any of our error handling.
|
|
9
|
+
*
|
|
10
|
+
* Rather than budget-and-drop (which loses the user's images, the one thing
|
|
11
|
+
* they actually asked the model to look at), every image is downscaled to a
|
|
12
|
+
* size where the whole request comfortably fits. A 1280px-long-edge JPEG at
|
|
13
|
+
* q0.78 lands around 100-150KB, so a request carrying the full complement of
|
|
14
|
+
* user uploads + brand references + frame screenshot sits near 1MB — roughly
|
|
15
|
+
* a quarter of the cap, with room for prompt text and tool schemas.
|
|
16
|
+
*
|
|
17
|
+
* This runs at payload-assembly time, not upload time, which is deliberate:
|
|
18
|
+
* conversation history persisted before this existed still holds raw
|
|
19
|
+
* multi-megabyte data URLs, and those are re-sent on every subsequent turn.
|
|
20
|
+
* Normalising here fixes existing conversations, not just new uploads.
|
|
21
|
+
*/
|
|
22
|
+
/** Estimated wire size of a data URL: the base64 payload is what gets sent. */
|
|
23
|
+
export declare function dataUrlWireBytes(dataUrl: string): number;
|
|
24
|
+
/**
|
|
25
|
+
* Whether a data URL is a raster format safe to send as an `image_url` block.
|
|
26
|
+
* SVG is commonly rejected outright by vision models, and canvas re-encoding
|
|
27
|
+
* of an SVG is unreliable across browsers, so it is neither shrunk nor sent.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isRasterImageDataUrl(dataUrl: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Downscale + re-encode a raster data URL so it is safe to embed in a request.
|
|
32
|
+
*
|
|
33
|
+
* Never throws: on any failure (decode error, no canvas context, non-raster
|
|
34
|
+
* input) the original data URL is returned unchanged. Callers treat this as
|
|
35
|
+
* best-effort normalisation, with `enforceImagePayloadBudget` as the backstop
|
|
36
|
+
* for anything that could not be shrunk.
|
|
37
|
+
*/
|
|
38
|
+
export declare function shrinkImageDataUrl(dataUrl: string): Promise<string>;
|
|
39
|
+
/** Shrink a batch in parallel, preserving order. */
|
|
40
|
+
export declare function shrinkImageDataUrls(dataUrls: string[]): Promise<string[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Normalise every image in an outgoing request so the body cannot exceed the
|
|
43
|
+
* platform request cap.
|
|
44
|
+
*
|
|
45
|
+
* Three escalating passes, so the common case costs nothing and the worst case
|
|
46
|
+
* still succeeds rather than 413ing:
|
|
47
|
+
*
|
|
48
|
+
* 1. Downscale every image to {@link MAX_EDGE_PX}. Almost always sufficient —
|
|
49
|
+
* a full request of 9 images lands near 1MB.
|
|
50
|
+
* 2. If still over (many images, or images that resisted re-encoding),
|
|
51
|
+
* re-encode at successively lower quality.
|
|
52
|
+
* 3. Only if *still* over, drop the oldest images — newest are the ones the
|
|
53
|
+
* user is actually asking about. Images on the final message are never
|
|
54
|
+
* dropped.
|
|
55
|
+
*
|
|
56
|
+
* Mutates the parts in place and returns the message array for convenience.
|
|
57
|
+
*/
|
|
58
|
+
export declare function normalizeRequestImages<T extends {
|
|
59
|
+
role: string;
|
|
60
|
+
}>(messages: T[]): Promise<T[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Build a user-facing message from a failed chat-proxy response.
|
|
63
|
+
*
|
|
64
|
+
* The previous handling assumed every non-OK status came from OpenRouter and
|
|
65
|
+
* carried an OpenRouter-shaped JSON error. Platform-level rejections (notably
|
|
66
|
+
* Vercel's 413 at the edge) return plain text, so `response.json()` threw and
|
|
67
|
+
* the raw fallback `OpenRouter error 413` reached the user — naming the wrong
|
|
68
|
+
* system and offering no action.
|
|
69
|
+
*/
|
|
70
|
+
export declare function describeChatError(response: Response): Promise<string>;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as a,T as b,U as c}from"../chunk-AQSA3HNR.js";import"../chunk-452N23ZE.js";import"../chunk-SRAX5OIU.js";export{c as decodePngMetadata,b as encodePngMetadata,a as getTEXtChunk};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|