@orangecatai/adgen-canvas 0.0.5 → 0.0.7
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-3FGOYDLK.js → chunk-2Q3FNCU4.js} +44 -3
- package/dist/dev/chunk-2Q3FNCU4.js.map +7 -0
- package/dist/dev/{chunk-IRIUFXMO.js → chunk-MW637LK5.js} +2 -2
- package/dist/dev/data/{image-HH4XNQRO.js → image-L2UC5LX5.js} +3 -3
- package/dist/dev/index.css +909 -27
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +6595 -2561
- 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-SG4RCQVC.js → chunk-7AVPHWG7.js} +1 -1
- package/dist/prod/{chunk-LUZI7MFZ.js → chunk-XPV36KCI.js} +3 -3
- package/dist/prod/data/image-6DWEFZH4.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +342 -85
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/excalidraw/components/AIChatPanel.d.ts +26 -0
- package/dist/types/excalidraw/components/CanvasBackgroundSwatch.d.ts +7 -0
- package/dist/types/excalidraw/components/ColorPicker/AdvancedColorPicker.d.ts +8 -0
- package/dist/types/excalidraw/components/ColorPicker/colorConversions.d.ts +27 -0
- package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
- package/dist/types/excalidraw/components/ElementCanvasButtons.d.ts +1 -1
- package/dist/types/excalidraw/components/FrameToolbar.d.ts +1 -1
- package/dist/types/excalidraw/components/HintViewer.d.ts +1 -1
- package/dist/types/excalidraw/components/ImageEditToolbar.d.ts +15 -0
- package/dist/types/excalidraw/components/ImageQuickEditPanel.d.ts +5 -1
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/index.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +1 -0
- package/dist/types/excalidraw/components/ToolButton.d.ts +1 -1
- package/dist/types/excalidraw/components/ai-chat/agentLoop.d.ts +16 -1
- package/dist/types/excalidraw/components/ai-chat/audioUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/ai-chat/canvasTools.d.ts +236 -1
- package/dist/types/excalidraw/components/ai-chat/htmlToExcalidraw.d.ts +53 -0
- package/dist/types/excalidraw/components/ai-chat/openRouterStream.d.ts +50 -0
- package/dist/types/excalidraw/components/auto-resize/AutoResizePanel.d.ts +16 -0
- package/dist/types/excalidraw/components/auto-resize/AutoResizeShimmerLayer.d.ts +7 -0
- package/dist/types/excalidraw/components/auto-resize/autoResizeEngine.d.ts +89 -0
- package/dist/types/excalidraw/components/auto-resize/autoResizeStore.d.ts +16 -0
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +1 -1
- package/dist/types/excalidraw/components/icons.d.ts +1 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +1 -1
- package/dist/types/excalidraw/components/ui/button.d.ts +1 -1
- package/dist/types/excalidraw/fonts/Fonts.d.ts +11 -0
- package/dist/types/excalidraw/index.d.ts +2 -0
- package/dist/types/excalidraw/types.d.ts +138 -0
- package/dist/types/excalidraw/utils/leonardoApiKey.d.ts +1 -0
- package/dist/types/excalidraw/utils/removeBgApiKey.d.ts +1 -0
- package/package.json +1 -1
- package/dist/dev/chunk-3FGOYDLK.js.map +0 -7
- package/dist/prod/data/image-J2ZJZU4A.js +0 -1
- /package/dist/dev/{chunk-IRIUFXMO.js.map → chunk-MW637LK5.js.map} +0 -0
- /package/dist/dev/data/{image-HH4XNQRO.js.map → image-L2UC5LX5.js.map} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ExcalidrawElement, ExcalidrawFrameLikeElement } from "@orangecatai/element/types";
|
|
2
|
+
import type { AppClassProperties } from "../../types";
|
|
3
|
+
import type { BinaryFiles } from "../../types";
|
|
4
|
+
export type TargetDimension = {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
label?: string;
|
|
8
|
+
};
|
|
9
|
+
export type DimensionResult = {
|
|
10
|
+
status: "ok";
|
|
11
|
+
frameId: string;
|
|
12
|
+
} | {
|
|
13
|
+
status: "error";
|
|
14
|
+
error: string;
|
|
15
|
+
};
|
|
16
|
+
export type ProgressCallback = (dimensionIndex: number, total: number, phase: "bg-regen" | "layout" | "inserting" | "done" | "error", label: string) => void;
|
|
17
|
+
type ForegroundEl = {
|
|
18
|
+
kind: "text";
|
|
19
|
+
relX: number;
|
|
20
|
+
relY: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
text: string;
|
|
24
|
+
fontSize: number;
|
|
25
|
+
color: string;
|
|
26
|
+
textAlign: string;
|
|
27
|
+
fontWeight: string;
|
|
28
|
+
opacity: number;
|
|
29
|
+
} | {
|
|
30
|
+
kind: "image";
|
|
31
|
+
relX: number;
|
|
32
|
+
relY: number;
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
dataUrl: string;
|
|
36
|
+
opacity: number;
|
|
37
|
+
} | {
|
|
38
|
+
kind: "rect";
|
|
39
|
+
relX: number;
|
|
40
|
+
relY: number;
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
backgroundColor: string;
|
|
44
|
+
borderRadius: number;
|
|
45
|
+
opacity: number;
|
|
46
|
+
};
|
|
47
|
+
type SourceFrameInfo = {
|
|
48
|
+
frame: ExcalidrawFrameLikeElement;
|
|
49
|
+
background: {
|
|
50
|
+
type: "solid";
|
|
51
|
+
color: string;
|
|
52
|
+
} | {
|
|
53
|
+
type: "image";
|
|
54
|
+
dataUrl: string;
|
|
55
|
+
} | {
|
|
56
|
+
type: "none";
|
|
57
|
+
};
|
|
58
|
+
foreground: ForegroundEl[];
|
|
59
|
+
};
|
|
60
|
+
export declare function extractFrameInfo(elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, files: BinaryFiles): SourceFrameInfo;
|
|
61
|
+
export declare function needsBackgroundRegeneration(srcW: number, srcH: number, tgtW: number, tgtH: number): boolean;
|
|
62
|
+
export type PreCreatedFrameInfo = {
|
|
63
|
+
frameId: string;
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
};
|
|
69
|
+
export declare function preCreateAllFrames(targetDimensions: TargetDimension[], sourceFrame: ExcalidrawFrameLikeElement, app: AppClassProperties): PreCreatedFrameInfo[];
|
|
70
|
+
export declare function runAutoResize(opts: {
|
|
71
|
+
sourceFrameId: string;
|
|
72
|
+
targetDimensions: TargetDimension[];
|
|
73
|
+
app: AppClassProperties;
|
|
74
|
+
geminiApiKey: string;
|
|
75
|
+
openRouterApiKey: string;
|
|
76
|
+
chatModel?: string;
|
|
77
|
+
agentImageModel?: string;
|
|
78
|
+
customFontMap?: Record<string, number>;
|
|
79
|
+
onBeforeAutoResize?: () => Promise<{
|
|
80
|
+
allowed: boolean;
|
|
81
|
+
error?: string;
|
|
82
|
+
}>;
|
|
83
|
+
onAfterAutoResize?: () => void;
|
|
84
|
+
onProgress?: ProgressCallback;
|
|
85
|
+
signal?: AbortSignal;
|
|
86
|
+
/** Pass the result of preCreateAllFrames() to skip redundant frame creation */
|
|
87
|
+
preCreatedFrameInfos?: PreCreatedFrameInfo[];
|
|
88
|
+
}): Promise<DimensionResult[]>;
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type LoadingFrameInfo = {
|
|
2
|
+
frameId: string;
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
8
|
+
type Listener = () => void;
|
|
9
|
+
export declare const autoResizeStore: {
|
|
10
|
+
setLoadingFrames(frames: LoadingFrameInfo[]): void;
|
|
11
|
+
markComplete(frameId: string): void;
|
|
12
|
+
clear(): void;
|
|
13
|
+
getLoadingFrames(): LoadingFrameInfo[];
|
|
14
|
+
subscribe(fn: Listener): () => void;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import "./Hyperlink.scss";
|
|
1
2
|
import type { Scene } from "@orangecatai/element";
|
|
2
3
|
import type { ElementsMap, ExcalidrawEmbeddableElement, NonDeletedExcalidrawElement } from "@orangecatai/element/types";
|
|
3
|
-
import "./Hyperlink.scss";
|
|
4
4
|
import type { AppState, ExcalidrawProps, UIAppState } from "../../types";
|
|
5
5
|
export declare const Hyperlink: ({ element, scene, setAppState, onLinkOpen, setToast, updateEmbedValidationStatus, }: {
|
|
6
6
|
element: NonDeletedExcalidrawElement;
|
|
@@ -188,6 +188,7 @@ export declare const alertTriangleIcon: import("react/jsx-runtime").JSX.Element;
|
|
|
188
188
|
export declare const eyeDropperIcon: import("react/jsx-runtime").JSX.Element;
|
|
189
189
|
export declare const extraToolsIcon: import("react/jsx-runtime").JSX.Element;
|
|
190
190
|
export declare const frameToolIcon: import("react/jsx-runtime").JSX.Element;
|
|
191
|
+
export declare const imageGeneratorToolIcon: import("react/jsx-runtime").JSX.Element;
|
|
191
192
|
export declare const mermaidLogoIcon: import("react/jsx-runtime").JSX.Element;
|
|
192
193
|
export declare const RetryIcon: import("react/jsx-runtime").JSX.Element;
|
|
193
194
|
export declare const stackPushIcon: import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "link" | "default" | "outline" | "
|
|
4
|
+
variant?: "link" | "default" | "outline" | "secondary" | "destructive" | "ghost" | null | undefined;
|
|
5
5
|
size?: "icon" | "default" | "sm" | "lg" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
7
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
@@ -14,6 +14,17 @@ export declare class Fonts {
|
|
|
14
14
|
metadata: FontMetadata;
|
|
15
15
|
fontFaces: ExcalidrawFontFace[];
|
|
16
16
|
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Register a custom font from a URL into the canvas font system.
|
|
19
|
+
*
|
|
20
|
+
* Use family IDs >= 1000 to avoid collisions with built-in fonts.
|
|
21
|
+
*
|
|
22
|
+
* Note: custom fonts are registered without a weight/style descriptor
|
|
23
|
+
* because getFontString generates "${size}px ${familyName}" (no weight),
|
|
24
|
+
* so the browser always requests the normal-weight variant. Pass the font
|
|
25
|
+
* file that should render by default for this family ID.
|
|
26
|
+
*/
|
|
27
|
+
static registerCustomFont(spec: import("../types").CustomFontSpec): void;
|
|
17
28
|
private readonly scene;
|
|
18
29
|
constructor(scene: Scene);
|
|
19
30
|
/**
|
|
@@ -51,3 +51,5 @@ export type { AIChatPanelProps, AIChatPanelRef, ChatMessage, ChatSession, } from
|
|
|
51
51
|
export type { ExcalidrawImperativeAPI } from "./types";
|
|
52
52
|
export type { AppState, BinaryFiles, BinaryFileData, ExcalidrawProps, ExcalidrawInitialDataState, LibraryItem, LibraryItems, SceneData, UnsubscribeCallback, } from "./types";
|
|
53
53
|
export type { ExcalidrawElement, NonDeletedExcalidrawElement, NonDeleted, OrderedExcalidrawElement, ExcalidrawElementType, } from "@orangecatai/element/types";
|
|
54
|
+
export type { ImageEditToolbarCallbacks } from "./components/ImageEditToolbar";
|
|
55
|
+
export type { CustomFontSpec, BrandContext } from "./types";
|
|
@@ -430,6 +430,75 @@ export type OnUserFollowedPayload = {
|
|
|
430
430
|
userToFollow: UserToFollow;
|
|
431
431
|
action: "FOLLOW" | "UNFOLLOW";
|
|
432
432
|
};
|
|
433
|
+
/**
|
|
434
|
+
* Describes a custom font to register in the canvas font system.
|
|
435
|
+
* Use family IDs >= 1000 to avoid collision with built-in fonts.
|
|
436
|
+
*/
|
|
437
|
+
export type CustomFontSpec = {
|
|
438
|
+
/** Unique numeric family ID. Use 1000+ to avoid collisions with built-ins. */
|
|
439
|
+
familyId: number;
|
|
440
|
+
/** CSS font-family name used in @font-face and canvas rendering. */
|
|
441
|
+
name: string;
|
|
442
|
+
/** Absolute URL or data: URL pointing to the font file. */
|
|
443
|
+
url: string;
|
|
444
|
+
/**
|
|
445
|
+
* Informational font-weight (e.g. "400", "700"). Not applied as a CSS
|
|
446
|
+
* descriptor — getFontString never includes weight, so all custom fonts
|
|
447
|
+
* load as the normal-weight variant for their family ID.
|
|
448
|
+
*/
|
|
449
|
+
weight?: string;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Optional brand identity context passed to AIChatPanel.
|
|
453
|
+
* When provided, the AI agent uses these guidelines when creating ads.
|
|
454
|
+
*/
|
|
455
|
+
export type BrandContext = {
|
|
456
|
+
colors?: {
|
|
457
|
+
primary?: string;
|
|
458
|
+
secondary?: string;
|
|
459
|
+
accent?: string;
|
|
460
|
+
background?: string;
|
|
461
|
+
};
|
|
462
|
+
typography?: {
|
|
463
|
+
headline?: {
|
|
464
|
+
family: string;
|
|
465
|
+
weight?: string;
|
|
466
|
+
/** size_scale from brand kit (e.g. "display", "large", "medium", "small") */
|
|
467
|
+
sizeScale?: string;
|
|
468
|
+
/**
|
|
469
|
+
* Font family ID if a matching custom font was registered via
|
|
470
|
+
* the `customFonts` prop on <Excalidraw>. The agent will pass
|
|
471
|
+
* this number to add_text fontFamily calls.
|
|
472
|
+
*/
|
|
473
|
+
fontFamilyId?: number;
|
|
474
|
+
};
|
|
475
|
+
body?: {
|
|
476
|
+
family: string;
|
|
477
|
+
weight?: string;
|
|
478
|
+
sizeScale?: string;
|
|
479
|
+
fontFamilyId?: number;
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
visualStyle?: string;
|
|
483
|
+
layoutPattern?: string;
|
|
484
|
+
toneOfVoice?: {
|
|
485
|
+
register?: string;
|
|
486
|
+
vocabulary?: string;
|
|
487
|
+
ctaStyle?: string;
|
|
488
|
+
sentenceLength?: string;
|
|
489
|
+
person?: string;
|
|
490
|
+
};
|
|
491
|
+
imagery?: {
|
|
492
|
+
type?: string;
|
|
493
|
+
lighting?: string;
|
|
494
|
+
composition?: string;
|
|
495
|
+
subjects?: string;
|
|
496
|
+
grading?: string;
|
|
497
|
+
depthOfField?: string;
|
|
498
|
+
environment?: string;
|
|
499
|
+
negativeSpace?: string;
|
|
500
|
+
};
|
|
501
|
+
};
|
|
433
502
|
export interface ExcalidrawProps {
|
|
434
503
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
435
504
|
onIncrement?: (event: DurableIncrement | EphemeralIncrement) => void;
|
|
@@ -497,6 +566,16 @@ export interface ExcalidrawProps {
|
|
|
497
566
|
* Required for image generation when using this package as an npm dependency.
|
|
498
567
|
*/
|
|
499
568
|
geminiApiKey?: string;
|
|
569
|
+
/**
|
|
570
|
+
* Leonardo API key for image toolbar upscale action.
|
|
571
|
+
* When provided, takes precedence over the VITE_APP_LEONARDO_API_KEY env variable.
|
|
572
|
+
*/
|
|
573
|
+
leonardoApiKey?: string;
|
|
574
|
+
/**
|
|
575
|
+
* remove.bg API key for the remove background toolbar action.
|
|
576
|
+
* When provided, takes precedence over the VITE_APP_REMOVE_BG_API_KEY env variable.
|
|
577
|
+
*/
|
|
578
|
+
removeBgApiKey?: string;
|
|
500
579
|
/**
|
|
501
580
|
* Called before any image generation (ImageGeneratorPanel, ImageQuickEditPanel,
|
|
502
581
|
* or agent loop generate_image tool). Return `{ allowed: false }` to block.
|
|
@@ -510,6 +589,63 @@ export interface ExcalidrawProps {
|
|
|
510
589
|
* Called after a successful image generation from any panel or agent tool.
|
|
511
590
|
*/
|
|
512
591
|
onAfterImageGen?: () => void;
|
|
592
|
+
/**
|
|
593
|
+
* Called before an upscale is run (deduct credits, check quota).
|
|
594
|
+
* Return `{ allowed: false, error: "..." }` to block the operation.
|
|
595
|
+
*/
|
|
596
|
+
onBeforeUpscale?: () => Promise<{
|
|
597
|
+
allowed: boolean;
|
|
598
|
+
error?: string;
|
|
599
|
+
}>;
|
|
600
|
+
/** Called after a successful upscale. */
|
|
601
|
+
onAfterUpscale?: () => void;
|
|
602
|
+
/**
|
|
603
|
+
* Called before a background removal is run (deduct credits, check quota).
|
|
604
|
+
* Return `{ allowed: false, error: "..." }` to block the operation.
|
|
605
|
+
*/
|
|
606
|
+
onBeforeRemoveBg?: () => Promise<{
|
|
607
|
+
allowed: boolean;
|
|
608
|
+
error?: string;
|
|
609
|
+
}>;
|
|
610
|
+
/** Called after a successful background removal. */
|
|
611
|
+
onAfterRemoveBg?: () => void;
|
|
612
|
+
/**
|
|
613
|
+
* Called before each auto-resize dimension is generated (deduct credits, check quota).
|
|
614
|
+
* Return `{ allowed: false, error: "..." }` to skip that dimension.
|
|
615
|
+
*/
|
|
616
|
+
onBeforeAutoResize?: () => Promise<{
|
|
617
|
+
allowed: boolean;
|
|
618
|
+
error?: string;
|
|
619
|
+
}>;
|
|
620
|
+
/** Called after each successfully generated auto-resize dimension. */
|
|
621
|
+
onAfterAutoResize?: () => void;
|
|
622
|
+
/**
|
|
623
|
+
* Gemini model ID used for AI image generation — covers both the auto-resize
|
|
624
|
+
* background regeneration and the agent chat `generate_image` tool.
|
|
625
|
+
* Pass the same value here and to `AIChatPanel.agentImageModel` to keep
|
|
626
|
+
* both surfaces on the same model with a single configuration.
|
|
627
|
+
* @default "gemini-3.1-flash-image-preview"
|
|
628
|
+
* @example "gemini-3.1-flash-image-preview"
|
|
629
|
+
*/
|
|
630
|
+
agentImageModel?: string;
|
|
631
|
+
/**
|
|
632
|
+
* Show the Library sidebar trigger button. Defaults to `false`.
|
|
633
|
+
* Set to `true` to show the library icon in the top-right area.
|
|
634
|
+
*/
|
|
635
|
+
showLibraryButton?: boolean;
|
|
636
|
+
/**
|
|
637
|
+
* Callbacks for each action in the image edit toolbar
|
|
638
|
+
* (shown when an image element is selected on canvas).
|
|
639
|
+
* When callbacks are omitted, built-in toolbar actions are used.
|
|
640
|
+
*/
|
|
641
|
+
imageEditToolbarCallbacks?: import("./components/ImageEditToolbar").ImageEditToolbarCallbacks;
|
|
642
|
+
/**
|
|
643
|
+
* Custom fonts to register in the canvas font system.
|
|
644
|
+
* Each entry maps a numeric family ID (use 1000+) to a font file URL.
|
|
645
|
+
* Registered fonts become available for text elements whose fontFamily
|
|
646
|
+
* matches the given familyId.
|
|
647
|
+
*/
|
|
648
|
+
customFonts?: CustomFontSpec[];
|
|
513
649
|
}
|
|
514
650
|
export type SceneData = {
|
|
515
651
|
elements?: ImportedDataState["elements"];
|
|
@@ -563,6 +699,7 @@ export type AppProps = Merge<ExcalidrawProps, {
|
|
|
563
699
|
export type AppClassProperties = {
|
|
564
700
|
props: AppProps;
|
|
565
701
|
state: AppState;
|
|
702
|
+
actionManager: App["actionManager"];
|
|
566
703
|
interactiveCanvas: HTMLCanvasElement | null;
|
|
567
704
|
/** static canvas */
|
|
568
705
|
canvas: HTMLCanvasElement;
|
|
@@ -604,6 +741,7 @@ export type AppClassProperties = {
|
|
|
604
741
|
visibleElements: App["visibleElements"];
|
|
605
742
|
excalidrawContainerValue: App["excalidrawContainerValue"];
|
|
606
743
|
getSceneElements: App["getSceneElements"];
|
|
744
|
+
updateScene: App["updateScene"];
|
|
607
745
|
onPointerUpEmitter: App["onPointerUpEmitter"];
|
|
608
746
|
updateEditorAtom: App["updateEditorAtom"];
|
|
609
747
|
onPointerDownEmitter: App["onPointerDownEmitter"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveLeonardoApiKey(propKey?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveRemoveBgApiKey(propKey?: string): string;
|