@orangecatai/adgen-canvas 0.0.21 → 0.0.22

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.
Files changed (31) hide show
  1. package/dist/dev/{chunk-RD5LX7MN.js → chunk-DG4DHKBY.js} +2 -2
  2. package/dist/dev/{chunk-WFKR6OGI.js → chunk-OIMA545L.js} +3 -3
  3. package/dist/dev/data/{image-DSU2H6P5.js → image-AWVYCS2V.js} +3 -3
  4. package/dist/dev/index.css +73 -0
  5. package/dist/dev/index.css.map +2 -2
  6. package/dist/dev/index.js +2594 -2911
  7. package/dist/dev/index.js.map +4 -4
  8. package/dist/dev/subset-shared.chunk.js +1 -1
  9. package/dist/dev/subset-worker.chunk.js +1 -1
  10. package/dist/prod/{chunk-OWNL6YOR.js → chunk-PJYEU4Z2.js} +1 -1
  11. package/dist/prod/{chunk-RXJEXEKA.js → chunk-X4HZUT4M.js} +2 -2
  12. package/dist/prod/data/image-YCVSAMH5.js +1 -0
  13. package/dist/prod/index.css +1 -1
  14. package/dist/prod/index.js +183 -426
  15. package/dist/prod/subset-shared.chunk.js +1 -1
  16. package/dist/prod/subset-worker.chunk.js +1 -1
  17. package/dist/types/excalidraw/components/ImageGeneratorPanel.d.ts +16 -2
  18. package/dist/types/excalidraw/components/ai-chat/AdGenShimmerLayer.d.ts +10 -0
  19. package/dist/types/excalidraw/components/ai-chat/adGenShimmerStore.d.ts +12 -0
  20. package/dist/types/excalidraw/components/ai-chat/agentLoop.d.ts +0 -4
  21. package/dist/types/excalidraw/components/ai-chat/canvasTools.d.ts +15 -40
  22. package/dist/types/excalidraw/components/ai-chat/reviewerAgent.d.ts +18 -9
  23. package/dist/types/excalidraw/components/auto-resize/autoResizeEngine.d.ts +41 -0
  24. package/dist/types/excalidraw/types.d.ts +22 -0
  25. package/dist/types/excalidraw/utils/brandContextUtils.d.ts +20 -0
  26. package/dist/types/excalidraw/utils/imageApi.d.ts +19 -1
  27. package/package.json +1 -1
  28. package/dist/prod/data/image-I7MZ4QNS.js +0 -1
  29. /package/dist/dev/{chunk-RD5LX7MN.js.map → chunk-DG4DHKBY.js.map} +0 -0
  30. /package/dist/dev/{chunk-WFKR6OGI.js.map → chunk-OIMA545L.js.map} +0 -0
  31. /package/dist/dev/data/{image-DSU2H6P5.js.map → image-AWVYCS2V.js.map} +0 -0
@@ -1 +1 @@
1
- import{a,b,c,d}from"./chunk-Z5NKEFVG.js";import"./chunk-OWNL6YOR.js";import"./chunk-SRAX5OIU.js";export{a as Commands,b as subsetToBase64,c as subsetToBinary,d as toBase64};
1
+ import{a,b,c,d}from"./chunk-Z5NKEFVG.js";import"./chunk-PJYEU4Z2.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-OWNL6YOR.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};
1
+ import{a as r,c as t}from"./chunk-Z5NKEFVG.js";import"./chunk-PJYEU4Z2.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};
@@ -12,14 +12,14 @@ export declare const MODEL_CONFIG: {
12
12
  readonly "nano banana 2": {
13
13
  readonly modelId: "google/gemini-3.1-flash-image-preview";
14
14
  readonly textOutput: true;
15
- readonly supportsImageSize: true;
15
+ readonly supportsImageSize: false;
16
16
  readonly supportedResolutions: readonly ["0.5K", "1K", "2K", "4K"];
17
17
  readonly supportedRatios: readonly ["21:9", "16:9", "4:3", "3:2", "1:1", "9:16", "3:4", "2:3", "5:4", "4:5", "4:1", "1:4", "8:1", "1:8"];
18
18
  };
19
19
  readonly "nano banana pro": {
20
20
  readonly modelId: "google/gemini-3-pro-image-preview";
21
21
  readonly textOutput: true;
22
- readonly supportsImageSize: true;
22
+ readonly supportsImageSize: false;
23
23
  readonly supportedResolutions: readonly ["1K", "2K", "4K"];
24
24
  readonly supportedRatios: readonly ["21:9", "16:9", "4:3", "3:2", "1:1", "9:16", "3:4", "2:3", "5:4", "4:5"];
25
25
  };
@@ -37,6 +37,20 @@ export declare const MODEL_CONFIG: {
37
37
  readonly supportedResolutions: readonly ["1K", "2K"];
38
38
  readonly supportedRatios: readonly ["16:9", "4:3", "3:2", "1:1", "9:16", "3:4", "2:3", "5:4", "4:5"];
39
39
  };
40
+ readonly "riverflow 2.5 fast": {
41
+ readonly modelId: "sourceful/riverflow-v2.5-fast";
42
+ readonly textOutput: false;
43
+ readonly supportsImageSize: true;
44
+ readonly supportedResolutions: readonly ["1K", "2K"];
45
+ readonly supportedRatios: readonly ["1:1", "21:9", "16:9", "3:2", "4:3", "5:4", "4:5", "3:4", "2:3", "9:16"];
46
+ };
47
+ readonly "riverflow 2.5 pro": {
48
+ readonly modelId: "sourceful/riverflow-v2.5-pro";
49
+ readonly textOutput: false;
50
+ readonly supportsImageSize: true;
51
+ readonly supportedResolutions: readonly ["1K", "2K", "4K"];
52
+ readonly supportedRatios: readonly ["1:1", "21:9", "16:9", "3:2", "4:3", "5:4", "4:5", "3:4", "2:3", "9:16"];
53
+ };
40
54
  };
41
55
  export type ModelName = keyof typeof MODEL_CONFIG;
42
56
  export declare const MODEL_NAMES: ModelName[];
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Renders a shimmer overlay on top of frames that are currently being
3
+ * generated by the AI chat agent (create_frame → generate_image → review).
4
+ *
5
+ * Rendered unconditionally from App.tsx alongside AutoResizeShimmerLayer.
6
+ * Uses useExcalidrawAppState() so it repositions correctly on scroll/zoom.
7
+ * Reads current frame position from scene elements so it follows the frame
8
+ * if the user drags it during generation.
9
+ */
10
+ export declare const AdGenShimmerLayer: () => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,12 @@
1
+ export type AdGenFrameInfo = {
2
+ frameId: string;
3
+ };
4
+ type Listener = () => void;
5
+ export declare const adGenShimmerStore: {
6
+ startGenerating(frameId: string): void;
7
+ stopGenerating(frameId: string): void;
8
+ clear(): void;
9
+ getLoadingFrames(): AdGenFrameInfo[];
10
+ subscribe(fn: Listener): () => void;
11
+ };
12
+ export {};
@@ -60,10 +60,6 @@ export type AgentResult = {
60
60
  reply: string;
61
61
  toolActions: ToolAction[];
62
62
  };
63
- /**
64
- * Converts a BrandContext object to a concise system message string.
65
- */
66
- export declare function buildBrandContextMessage(ctx: BrandContext): string;
67
63
  export type FileAttachment = {
68
64
  name: string;
69
65
  type: "image" | "text" | "pdf" | "docx";
@@ -297,7 +297,7 @@ export declare const BANNER_TOOLS: readonly [{
297
297
  readonly type: "function";
298
298
  readonly function: {
299
299
  readonly name: "generate_image";
300
- readonly description: "Generate an image using AI (Gemini) and place it onto the canvas. Always call this for any photo or image content even when the user has attached a reference image. The attached image is passed to Gemini as visual reference; Gemini generates the final output. Use referenceImageIndex to tell Gemini which user attachment to reference. IMPORTANT: your prompt must describe a purely visual scene NO text, NO typography, NO words, NO captions, NO watermarks. All copy is handled by the HTML layer. A 'no text' safety suffix will be auto-appended, but you must also describe composition clearly (e.g. which side should be left open/empty for the HTML text).";
300
+ readonly description: "Generate the COMPLETE advertisement as a single AI image and place it into the frame. The image must contain BOTH the visuals AND all copy (headline, subheadline, CTA button, sign-off/brand name) rendered as legible text inside the image this is the entire ad, not a text-free background. Fill the whole frame (x:0, y:0, width:frameW, height:frameH). Use referenceImageIndex when the user attached an image to use as a subject/style reference. Your prompt must spell on-image text exactly and specify brand colors, typographic style, composition, and dimensions. Do NOT call generate_html_banner afterwards there is no separate text layer.";
301
301
  readonly parameters: {
302
302
  readonly type: "object";
303
303
  readonly properties: {
@@ -307,7 +307,7 @@ export declare const BANNER_TOOLS: readonly [{
307
307
  };
308
308
  readonly prompt: {
309
309
  readonly type: "string";
310
- readonly description: "Detailed generation prompt. When using a reference image, describe what you want Gemini to produce e.g. 'use this building as the subject, wide cinematic crop with open sky on the left for text overlay'.";
310
+ readonly description: "Detailed prompt for the COMPLETE ad: the visual scene PLUS the exact on-image copy (quote headline/subheadline/CTA/sign-off verbatim), brand colors per element, typographic style described in words, composition/layout, and the target dimensions/aspect.";
311
311
  };
312
312
  readonly x: {
313
313
  readonly type: "number";
@@ -334,27 +334,6 @@ export declare const BANNER_TOOLS: readonly [{
334
334
  readonly additionalProperties: false;
335
335
  };
336
336
  };
337
- }, {
338
- readonly type: "function";
339
- readonly function: {
340
- readonly name: "generate_html_banner";
341
- readonly description: "Place HTML/CSS text and shape elements into an EXISTING frame on the canvas. Always call create_frame first to get a frameId, then generate_image, then call this with that frameId. frameId is required — this tool does NOT create frames.";
342
- readonly parameters: {
343
- readonly type: "object";
344
- readonly properties: {
345
- readonly html: {
346
- readonly type: "string";
347
- readonly description: "Complete self-contained HTML with inline <style>. All layer elements must use position:absolute with explicit left/top/width/height in px. Root div must have class='canvas'.";
348
- };
349
- readonly frameId: {
350
- readonly type: "string";
351
- readonly description: "Required. The ID of the frame created by create_frame. Adds HTML elements into this existing frame, preserving existing children like images.";
352
- };
353
- };
354
- readonly required: readonly ["html", "frameId"];
355
- readonly additionalProperties: false;
356
- };
357
- };
358
337
  }, {
359
338
  readonly type: "function";
360
339
  readonly function: {
@@ -589,23 +568,6 @@ export declare const BANNER_TOOLS: readonly [{
589
568
  readonly additionalProperties: false;
590
569
  };
591
570
  };
592
- }, {
593
- readonly type: "function";
594
- readonly function: {
595
- readonly name: "finalize_ad";
596
- readonly description: "Call this when ALL elements are placed on the canvas — brand assets, generated images, and the HTML text overlay. Captures a screenshot of the complete frame for review. Do NOT call this before all assets are in place.";
597
- readonly parameters: {
598
- readonly type: "object";
599
- readonly properties: {
600
- readonly frameId: {
601
- readonly type: "string";
602
- readonly description: "ID of the frame to capture for review";
603
- };
604
- };
605
- readonly required: readonly ["frameId"];
606
- readonly additionalProperties: false;
607
- };
608
- };
609
571
  }];
610
572
  export declare function serializeElements(elements: readonly ExcalidrawElement[]): Record<string, unknown>[];
611
573
  export type FrameInfo = {
@@ -641,6 +603,19 @@ export type ToolExecutionContext = {
641
603
  brandHeadlineFontName?: string;
642
604
  /** Brand body font file name. Sourced from brand DNA. */
643
605
  brandBodyFontName?: string;
606
+ /** Data URL of the master brand logo — passed as a visual reference image to the image generation model. */
607
+ brandLogoDataUrl?: string;
608
+ /** Data URL of text rendered in the brand headline font — passed as a visual reference to the image generation model. */
609
+ brandFontPreviewDataUrl?: string;
610
+ /** Data URL of text rendered in the brand body font — passed as a second visual reference to the image generation model. */
611
+ brandBodyFontPreviewDataUrl?: string;
612
+ /**
613
+ * Fetchable URL of the actual headline font file (.ttf/.otf), e.g. a presigned
614
+ * S3 URL. Only consumed by image models that accept a font file as input
615
+ * (Sourceful Riverflow v2+ -> OpenRouter `image_config.font_inputs`). Other
616
+ * models ignore it.
617
+ */
618
+ brandFontUrl?: string;
644
619
  /**
645
620
  * Excalidraw fontFamilyId for the brand headline font.
646
621
  * When set, ALL text elements (add_text, fill_template_slots headline slots)
@@ -1,19 +1,28 @@
1
1
  /**
2
2
  * reviewerAgent.ts
3
3
  *
4
- * Stateless reviewer module. After generate_html_banner succeeds, this
5
- * agent receives a partial, focused context (rendered screenshot, HTML
6
- * source, frame dimensions, brand guidelines, original user brief) and
7
- * returns precise layout/readability critique NOT the full agent
8
- * conversation history.
4
+ * Brand Governance Agent — stateless reviewer that runs after the main agent
5
+ * generates a complete ad image (visuals + all copy baked in) and calls
6
+ * finalize_ad. It receives a focused context (the rendered screenshot, frame
7
+ * dimensions, brand guidelines, original user brief) and returns a precise
8
+ * critique covering creative quality AND brand-governance compliance:
9
+ * copy correctness, brand tone, logo usage, claim accuracy, legal mandatories,
10
+ * offer disclaimers, regulatory sensitivity, prohibited language, competitive
11
+ * claims, and data/privacy concerns.
9
12
  *
10
- * The reviewer is a separate LLM call from the main agent loop so it
11
- * brings an independent eye to the generated banner.
13
+ * The reviewer is a separate LLM call from the main agent loop so it brings an
14
+ * independent eye to the generated ad. Because the ad is a single image, every
15
+ * fix is applied by regenerating the image with a revised prompt — there is no
16
+ * HTML/CSS layer to patch.
17
+ *
18
+ * @deprecated note (2026-06-17): this reviewer previously audited an HTML text
19
+ * layer composited over a text-free image and emitted CSS-only fixes. That
20
+ * flow is gone — see the image-first agent loop in agentLoop.ts.
12
21
  */
13
22
  import type { BrandContext } from "../../types";
14
23
  export type ReviewIssue = {
15
- /** Which design element is affected */
16
- element: "headline" | "subheadline" | "cta" | "image" | "layout" | "brand";
24
+ /** Which design element or governance dimension is affected */
25
+ element: "headline" | "subheadline" | "cta" | "image" | "layout" | "brand" | "brand_tone" | "logo" | "claim" | "legal" | "disclaimer" | "regulatory" | "prohibited_language" | "competitive_claim" | "privacy";
17
26
  /** How bad it is */
18
27
  severity: "critical" | "major" | "minor";
19
28
  /** What is wrong — one sentence */
@@ -69,6 +69,37 @@ export declare function extractFrameInfo(elements: readonly ExcalidrawElement[],
69
69
  export declare function computeCropLoss(sourceAR: number, targetAR: number): number;
70
70
  export declare function needsBackgroundRegeneration(srcW: number, srcH: number, tgtW: number, tgtH: number): boolean;
71
71
  export declare function nearestGeminiAspectRatio(w: number, h: number): string;
72
+ /**
73
+ * Resolution dimensions available for each aspect ratio in Gemini 3.1 Flash
74
+ * Image (Nano Banana 2). Maps aspect ratio → resolution level → [width, height].
75
+ * Exported so the Auto Resize panel can build its dimension presets from the
76
+ * exact model-supported sizes instead of duplicating the numbers.
77
+ */
78
+ export declare const GEMINI_RESOLUTION_TABLE: Record<string, Record<string, [number, number]>>;
79
+ /**
80
+ * Resolution levels offered by the Auto Resize panel.
81
+ * Nano Banana (gemini-2.5-flash-image) and Nano Banana 2 (gemini-3.1-flash-image-preview)
82
+ * both support 0.5K–4K. 0.5K is the fastest/cheapest tier.
83
+ */
84
+ export declare const AUTO_RESIZE_RESOLUTIONS: readonly ["0.5K", "1K", "2K", "4K"];
85
+ export type AutoResizeResolution = typeof AUTO_RESIZE_RESOLUTIONS[number];
86
+ /**
87
+ * Aspect ratios the Nano Banana 2 / Gemini 3.1 Flash Image model supports,
88
+ * ordered for display (common first, then the ultrawide / extreme-narrow ones).
89
+ * Each carries a human label for the panel.
90
+ */
91
+ export declare const AUTO_RESIZE_ASPECT_RATIOS: {
92
+ ratio: string;
93
+ desc: string;
94
+ }[];
95
+ /**
96
+ * Concrete pixel dimensions for a given aspect ratio + resolution, straight from
97
+ * the Nano Banana 2 resolution table. Falls back to 1:1 / 1K if unknown.
98
+ */
99
+ export declare function geminiDimsFor(ratio: string, resolution: string): {
100
+ width: number;
101
+ height: number;
102
+ };
72
103
  /**
73
104
  * Selects the optimal resolution for a given target dimension and aspect ratio.
74
105
  * Chooses the resolution level that is closest to (but preferably >= ) the target size.
@@ -139,5 +170,15 @@ export declare function runAutoResize(opts: {
139
170
  signal?: AbortSignal;
140
171
  /** Pass the result of preCreateAllFrames() to skip redundant frame creation */
141
172
  preCreatedFrameInfos?: PreCreatedFrameInfo[];
173
+ /**
174
+ * Brand assets handed to the image model so the recomposed ad keeps the brand
175
+ * logo, typeface, and (for font-aware models) the real font file. Sourced from
176
+ * `app.state.brandContext` by the panel.
177
+ */
178
+ brandImages?: {
179
+ logo?: string;
180
+ fontPreview?: string;
181
+ fontUrl?: string;
182
+ };
142
183
  }): Promise<DimensionResult[]>;
143
184
  export {};
@@ -503,6 +503,21 @@ export type BrandContext = {
503
503
  environment?: string;
504
504
  negativeSpace?: string;
505
505
  };
506
+ /** Data URL of the master brand logo — passed as a visual reference to the image generation model. */
507
+ logoDataUrl?: string;
508
+ /** Data URL of text rendered in the brand headline font — passed as a visual reference to the image generation model. */
509
+ headlineFontPreviewDataUrl?: string;
510
+ /** Data URL of text rendered in the brand body font — passed as a second visual reference alongside the headline preview. */
511
+ bodyFontPreviewDataUrl?: string;
512
+ /**
513
+ * Fetchable URL (e.g. a short-lived presigned S3 URL) of the actual headline
514
+ * font file (.ttf/.otf). Passed to image models that accept a font file as
515
+ * input (Sourceful Riverflow v2+ via OpenRouter `image_config.font_inputs`).
516
+ * Unlike `headlineFontPreviewDataUrl` (a rendered preview image), this is the
517
+ * real font file the provider's servers fetch directly, so it must be a URL
518
+ * reachable without auth cookies — not the private `/api/brand/font` proxy.
519
+ */
520
+ headlineFontUrl?: string;
506
521
  };
507
522
  export interface ExcalidrawProps {
508
523
  onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
@@ -572,6 +587,13 @@ export interface ExcalidrawProps {
572
587
  * browser.
573
588
  */
574
589
  imageGenUrl?: string;
590
+ /**
591
+ * Brand context (colors, typography, logo, font preview) passed to every
592
+ * image generation surface (ImageGeneratorPanel, ImageQuickEditPanel, and the
593
+ * AI chat agent). When present, the logo and font preview are sent as visual
594
+ * references to the image model.
595
+ */
596
+ brandContext?: BrandContext;
575
597
  /**
576
598
  * Host proxy URL for the auto-resize engine's OpenRouter calls (layout
577
599
  * planning, vision tagging, HTML generation, reviewer). Key stays server-side.
@@ -0,0 +1,20 @@
1
+ import type { BrandContext } from "../types";
2
+ /**
3
+ * Converts a BrandContext object to a concise text block describing brand
4
+ * identity guidelines. Used as a system/prompt prefix for both the agent loop
5
+ * and direct image generation panels.
6
+ */
7
+ export declare function buildBrandContextMessage(ctx: BrandContext): string;
8
+ /**
9
+ * Augments a raw user prompt with strong brand asset instructions — identical to
10
+ * the approach used by execGenerateImage in the AI chat agent. Call this in
11
+ * ImageGeneratorPanel and ImageQuickEditPanel before invoking callOpenRouterImageAPI
12
+ * so that direct-generation panels produce the same brand-faithful output as the
13
+ * agent loop.
14
+ *
15
+ * Brand DNA text (colors, visual style, etc.) should be passed separately as
16
+ * `brandImages.brandContextText` in callOpenRouterImageAPI so it's prepended as a
17
+ * block before the prompt. This function only appends the per-asset mandatory
18
+ * instructions that reference the visual attachments by position.
19
+ */
20
+ export declare function buildImageGenSafePrompt(prompt: string, brandContext: BrandContext): string;
@@ -1 +1,19 @@
1
- export declare function callOpenRouterImageAPI(prompt: string, modelId: string, aspectRatio: string, imageSize: string | null, textOutput: boolean, imageGenUrl: string, referenceImageDataUrl?: string, signal?: AbortSignal): Promise<string>;
1
+ export declare function callOpenRouterImageAPI(prompt: string, modelId: string, aspectRatio: string, imageSize: string | null, textOutput: boolean, imageGenUrl: string, referenceImageDataUrl?: string, signal?: AbortSignal, brandImages?: {
2
+ logo?: string;
3
+ fontPreview?: string;
4
+ /** Optional second font preview (brand body typeface) shown as a reference. */
5
+ fontPreviewBody?: string;
6
+ /**
7
+ * Fetchable URL of the real headline font file (.ttf/.otf). Only Sourceful
8
+ * Riverflow v2+ consumes this — sent via `image_config.font_inputs` so the
9
+ * model renders text in the actual brand typeface (not just a preview img).
10
+ */
11
+ fontUrl?: string;
12
+ /** Text to render with `fontUrl` for the font_inputs entry. */
13
+ fontText?: string;
14
+ /**
15
+ * Full brand identity context text (colors, typography, visual style, etc.)
16
+ * prepended to the prompt so the model applies brand guidelines to the image.
17
+ */
18
+ brandContextText?: string;
19
+ }): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orangecatai/adgen-canvas",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "type": "module",
5
5
  "types": "./dist/types/excalidraw/index.d.ts",
6
6
  "main": "./dist/prod/index.js",
@@ -1 +0,0 @@
1
- import{T as a,U as b,V as c}from"../chunk-RXJEXEKA.js";import"../chunk-OWNL6YOR.js";import"../chunk-SRAX5OIU.js";export{c as decodePngMetadata,b as encodePngMetadata,a as getTEXtChunk};