@orangecatai/element 0.0.3 → 0.0.4
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/index.js +28 -2
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +9 -9
- package/dist/types/common/src/constants.d.ts +4 -0
- package/dist/types/element/src/Scene.d.ts +1 -1
- package/dist/types/element/src/frame.d.ts +2 -2
- package/dist/types/element/src/newElement.d.ts +10 -1
- package/dist/types/element/src/typeChecks.d.ts +2 -1
- package/dist/types/element/src/types.d.ts +17 -2
- package/dist/types/excalidraw/actions/actionFrame.d.ts +41 -0
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +41 -0
- package/dist/types/excalidraw/components/AIChatPanel.d.ts +70 -8
- package/dist/types/excalidraw/components/App.d.ts +10 -0
- package/dist/types/excalidraw/components/ImageEditToolbar.d.ts +0 -1
- package/dist/types/excalidraw/components/ImageGeneratorPanel.d.ts +53 -12
- package/dist/types/excalidraw/components/StockImagePanel.d.ts +49 -0
- package/dist/types/excalidraw/components/VideoElement.d.ts +9 -0
- package/dist/types/excalidraw/components/VideoGeneratorPanel.d.ts +149 -0
- package/dist/types/excalidraw/components/ai-chat/AdGenShimmerLayer.d.ts +10 -0
- package/dist/types/excalidraw/components/ai-chat/adGenShimmerStore.d.ts +12 -0
- package/dist/types/excalidraw/components/ai-chat/agentLoop.d.ts +8 -6
- package/dist/types/excalidraw/components/ai-chat/audioUtils.d.ts +0 -5
- package/dist/types/excalidraw/components/ai-chat/canvasTools.d.ts +96 -29
- package/dist/types/excalidraw/components/ai-chat/reviewerAgent.d.ts +21 -11
- package/dist/types/excalidraw/components/auto-resize/AutoResizePanel.d.ts +2 -2
- package/dist/types/excalidraw/components/auto-resize/autoResizeEngine.d.ts +43 -2
- package/dist/types/excalidraw/components/icons.d.ts +2 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +4 -0
- package/dist/types/excalidraw/data/blob.d.ts +4 -1
- package/dist/types/excalidraw/index.d.ts +6 -2
- package/dist/types/excalidraw/scene/types.d.ts +1 -0
- package/dist/types/excalidraw/types.d.ts +83 -21
- package/dist/types/excalidraw/utils/brandContextUtils.d.ts +23 -0
- package/dist/types/excalidraw/utils/imageApi.d.ts +19 -0
- package/dist/types/excalidraw/utils/videoApi.d.ts +30 -0
- package/dist/types/utils/src/shape.d.ts +2 -2
- package/package.json +2 -2
- package/dist/types/excalidraw/utils/geminiApiKey.d.ts +0 -1
- package/dist/types/excalidraw/utils/leonardoApiKey.d.ts +0 -1
- package/dist/types/excalidraw/utils/openRouterApiKey.d.ts +0 -1
- package/dist/types/excalidraw/utils/removeBgApiKey.d.ts +0 -1
|
@@ -454,6 +454,8 @@ export type CustomFontSpec = {
|
|
|
454
454
|
* When provided, the AI agent uses these guidelines when creating ads.
|
|
455
455
|
*/
|
|
456
456
|
export type BrandContext = {
|
|
457
|
+
/** Brand name — injected as a system-level constraint so the model stays on-brand. */
|
|
458
|
+
name?: string;
|
|
457
459
|
colors?: {
|
|
458
460
|
primary?: string;
|
|
459
461
|
secondary?: string;
|
|
@@ -503,6 +505,21 @@ export type BrandContext = {
|
|
|
503
505
|
environment?: string;
|
|
504
506
|
negativeSpace?: string;
|
|
505
507
|
};
|
|
508
|
+
/** Data URL of the master brand logo — passed as a visual reference to the image generation model. */
|
|
509
|
+
logoDataUrl?: string;
|
|
510
|
+
/** Data URL of text rendered in the brand headline font — passed as a visual reference to the image generation model. */
|
|
511
|
+
headlineFontPreviewDataUrl?: string;
|
|
512
|
+
/** Data URL of text rendered in the brand body font — passed as a second visual reference alongside the headline preview. */
|
|
513
|
+
bodyFontPreviewDataUrl?: string;
|
|
514
|
+
/**
|
|
515
|
+
* Fetchable URL (e.g. a short-lived presigned S3 URL) of the actual headline
|
|
516
|
+
* font file (.ttf/.otf). Passed to image models that accept a font file as
|
|
517
|
+
* input (Sourceful Riverflow v2+ via OpenRouter `image_config.font_inputs`).
|
|
518
|
+
* Unlike `headlineFontPreviewDataUrl` (a rendered preview image), this is the
|
|
519
|
+
* real font file the provider's servers fetch directly, so it must be a URL
|
|
520
|
+
* reachable without auth cookies — not the private `/api/brand/font` proxy.
|
|
521
|
+
*/
|
|
522
|
+
headlineFontUrl?: string;
|
|
506
523
|
};
|
|
507
524
|
export interface ExcalidrawProps {
|
|
508
525
|
onChange?: (elements: readonly OrderedExcalidrawElement[], appState: AppState, files: BinaryFiles) => void;
|
|
@@ -566,26 +583,29 @@ export interface ExcalidrawProps {
|
|
|
566
583
|
showDeprecatedFonts?: boolean;
|
|
567
584
|
renderScrollbars?: boolean;
|
|
568
585
|
/**
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
586
|
+
* Host proxy URL for OpenRouter image generation (ImageGeneratorPanel,
|
|
587
|
+
* ImageQuickEditPanel). The SDK POSTs the OpenRouter request body here; the
|
|
588
|
+
* host injects the API key and forwards. Keeps the provider key out of the
|
|
589
|
+
* browser.
|
|
572
590
|
*/
|
|
573
|
-
|
|
591
|
+
imageGenUrl?: string;
|
|
574
592
|
/**
|
|
575
|
-
*
|
|
576
|
-
*
|
|
593
|
+
* Brand context (colors, typography, logo, font preview) passed to every
|
|
594
|
+
* image generation surface (ImageGeneratorPanel, ImageQuickEditPanel, and the
|
|
595
|
+
* AI chat agent). When present, the logo and font preview are sent as visual
|
|
596
|
+
* references to the image model.
|
|
577
597
|
*/
|
|
578
|
-
|
|
598
|
+
brandContext?: BrandContext;
|
|
579
599
|
/**
|
|
580
|
-
*
|
|
581
|
-
*
|
|
600
|
+
* Host proxy URL for the auto-resize engine's OpenRouter calls (layout
|
|
601
|
+
* planning, vision tagging, HTML generation, reviewer). Key stays server-side.
|
|
582
602
|
*/
|
|
583
|
-
|
|
603
|
+
autoResizeUrl?: string;
|
|
584
604
|
/**
|
|
585
|
-
*
|
|
586
|
-
*
|
|
605
|
+
* Host proxy URL for the remove.bg toolbar action. The SDK POSTs
|
|
606
|
+
* `{ imageDataUrl }` and receives `{ imageDataUrl }`. Key stays server-side.
|
|
587
607
|
*/
|
|
588
|
-
|
|
608
|
+
removeBgUrl?: string;
|
|
589
609
|
/**
|
|
590
610
|
* Called before any image generation (ImageGeneratorPanel, ImageQuickEditPanel,
|
|
591
611
|
* or agent loop generate_image tool). Return `{ allowed: false }` to block.
|
|
@@ -600,15 +620,34 @@ export interface ExcalidrawProps {
|
|
|
600
620
|
*/
|
|
601
621
|
onAfterImageGen?: () => void;
|
|
602
622
|
/**
|
|
603
|
-
*
|
|
604
|
-
*
|
|
623
|
+
* Host proxy URL for video uploads. The SDK POSTs multipart/form-data with
|
|
624
|
+
* a `file` field; the host stores the video and returns `{ url: string }`.
|
|
625
|
+
* Without this prop, video upload via drag-and-drop is silently ignored.
|
|
605
626
|
*/
|
|
606
|
-
|
|
627
|
+
videoUploadUrl?: string;
|
|
628
|
+
/**
|
|
629
|
+
* Called before a video upload begins. Return `{ allowed: false }` to block
|
|
630
|
+
* (e.g. quota exceeded). Host uses this for credit gating.
|
|
631
|
+
*/
|
|
632
|
+
onBeforeVideoUpload?: () => Promise<{
|
|
607
633
|
allowed: boolean;
|
|
608
634
|
error?: string;
|
|
609
635
|
}>;
|
|
610
|
-
/** Called after a
|
|
611
|
-
|
|
636
|
+
/** Called after a video is successfully uploaded and placed on the canvas. */
|
|
637
|
+
onAfterVideoUpload?: () => void;
|
|
638
|
+
/** Host proxy URL for video generation jobs (POST). */
|
|
639
|
+
videoGenUrl?: string;
|
|
640
|
+
/** Host proxy URL for polling video generation job status (GET {url}/{jobId}). */
|
|
641
|
+
videoGenStatusUrl?: string;
|
|
642
|
+
/** Called before a video generation job is submitted (credit gate). */
|
|
643
|
+
onBeforeVideoGen?: () => Promise<{
|
|
644
|
+
allowed: boolean;
|
|
645
|
+
error?: string;
|
|
646
|
+
}>;
|
|
647
|
+
/** Called after a video is successfully generated and inserted into the canvas. */
|
|
648
|
+
onAfterVideoGen?: () => void;
|
|
649
|
+
/** Host proxy URL for video downloads — works around S3 CORS / presigned-URL expiry. */
|
|
650
|
+
videoDownloadProxyUrl?: string;
|
|
612
651
|
/**
|
|
613
652
|
* Called before a background removal is run (deduct credits, check quota).
|
|
614
653
|
* Return `{ allowed: false, error: "..." }` to block the operation.
|
|
@@ -630,12 +669,12 @@ export interface ExcalidrawProps {
|
|
|
630
669
|
/** Called after each successfully generated auto-resize dimension. */
|
|
631
670
|
onAfterAutoResize?: () => void;
|
|
632
671
|
/**
|
|
633
|
-
*
|
|
672
|
+
* OpenRouter model ID used for AI image generation — covers both the auto-resize
|
|
634
673
|
* background regeneration and the agent chat `generate_image` tool.
|
|
635
674
|
* Pass the same value here and to `AIChatPanel.agentImageModel` to keep
|
|
636
675
|
* both surfaces on the same model with a single configuration.
|
|
637
|
-
* @default "gemini-3.1-flash-image-preview"
|
|
638
|
-
* @example "gemini-
|
|
676
|
+
* @default "google/gemini-3.1-flash-image-preview"
|
|
677
|
+
* @example "google/gemini-2.5-flash-image"
|
|
639
678
|
*/
|
|
640
679
|
agentImageModel?: string;
|
|
641
680
|
/**
|
|
@@ -714,6 +753,21 @@ export interface ExcalidrawProps {
|
|
|
714
753
|
onGetTemplateVariant?: (templateId: string) => Promise<{
|
|
715
754
|
canvasJson: string;
|
|
716
755
|
}>;
|
|
756
|
+
/**
|
|
757
|
+
* Search brand image assets, ad creatives, or templates by keywords and
|
|
758
|
+
* return top 3 matches with base64 preview images. Used by the agent's
|
|
759
|
+
* `find_brand_asset` tool.
|
|
760
|
+
*/
|
|
761
|
+
onFindBrandAssets?: (type: "image-asset" | "ad-creative" | "template", keywords: string[]) => Promise<{
|
|
762
|
+
results: Array<{
|
|
763
|
+
id: string;
|
|
764
|
+
name: string;
|
|
765
|
+
tags?: string[];
|
|
766
|
+
width?: number | null;
|
|
767
|
+
height?: number | null;
|
|
768
|
+
previewDataUrl: string;
|
|
769
|
+
}>;
|
|
770
|
+
}>;
|
|
717
771
|
}
|
|
718
772
|
export type SceneData = {
|
|
719
773
|
elements?: ImportedDataState["elements"];
|
|
@@ -797,8 +851,10 @@ export type AppClassProperties = {
|
|
|
797
851
|
insertEmbeddableElement: App["insertEmbeddableElement"];
|
|
798
852
|
onMagicframeToolSelect: App["onMagicframeToolSelect"];
|
|
799
853
|
onImageGeneratorSelect: App["onImageGeneratorSelect"];
|
|
854
|
+
onVideoGeneratorSelect: App["onVideoGeneratorSelect"];
|
|
800
855
|
insertGeneratedImageIntoFrame: App["insertGeneratedImageIntoFrame"];
|
|
801
856
|
insertGeneratedImageNearElement: App["insertGeneratedImageNearElement"];
|
|
857
|
+
insertGeneratedVideoIntoFrame: App["insertGeneratedVideoIntoFrame"];
|
|
802
858
|
getName: App["getName"];
|
|
803
859
|
dismissLinearEditor: App["dismissLinearEditor"];
|
|
804
860
|
flowChartCreator: App["flowChartCreator"];
|
|
@@ -815,6 +871,12 @@ export type AppClassProperties = {
|
|
|
815
871
|
onPointerDownEmitter: App["onPointerDownEmitter"];
|
|
816
872
|
lastPointerMoveCoords: App["lastPointerMoveCoords"];
|
|
817
873
|
bindModeHandler: App["bindModeHandler"];
|
|
874
|
+
refresh: App["refresh"];
|
|
875
|
+
refreshEditorInterface: App["refreshEditorInterface"];
|
|
876
|
+
lassoTrail: App["lassoTrail"];
|
|
877
|
+
toggleSidebar: App["toggleSidebar"];
|
|
878
|
+
insertVideos: App["insertVideos"];
|
|
879
|
+
onVideoToolbarButtonClick: App["onVideoToolbarButtonClick"];
|
|
818
880
|
};
|
|
819
881
|
export type PointerDownState = Readonly<{
|
|
820
882
|
origin: Readonly<{
|
|
@@ -0,0 +1,23 @@
|
|
|
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, dimensions?: {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
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>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface VideoJobParams {
|
|
2
|
+
model: string;
|
|
3
|
+
prompt: string;
|
|
4
|
+
aspectRatio: string;
|
|
5
|
+
duration?: number;
|
|
6
|
+
resolution?: string;
|
|
7
|
+
firstFrameDataUrl?: string;
|
|
8
|
+
lastFrameDataUrl?: string;
|
|
9
|
+
audio?: boolean;
|
|
10
|
+
negativePrompt?: string;
|
|
11
|
+
inputReferences?: string[];
|
|
12
|
+
seed?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface VideoJobResult {
|
|
15
|
+
videoPresignedUrl: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Submit a video generation job to the host proxy.
|
|
19
|
+
* Returns { jobId } immediately — the job runs async on OpenRouter.
|
|
20
|
+
*/
|
|
21
|
+
export declare function submitVideoJob(params: VideoJobParams, videoGenUrl: string): Promise<{
|
|
22
|
+
jobId: string;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Poll the host status endpoint until the job is done or failed.
|
|
26
|
+
* onProgress is called with values 0–1 as they arrive.
|
|
27
|
+
* Resolves with { videoPresignedUrl } on success.
|
|
28
|
+
* Rejects with an Error on failure or abort.
|
|
29
|
+
*/
|
|
30
|
+
export declare function pollVideoJob(jobId: string, videoGenStatusUrl: string, onProgress: (progress: number) => void, signal?: AbortSignal): Promise<VideoJobResult>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type GlobalPoint, type LocalPoint } from "@orangecatai/math";
|
|
2
|
-
import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawFreeDrawElement, ExcalidrawIframeElement, ExcalidrawImageElement, ExcalidrawLinearElement, ExcalidrawRectangleElement, ExcalidrawSelectionElement, ExcalidrawTextElement } from "@orangecatai/element/types";
|
|
2
|
+
import type { ElementsMap, ExcalidrawBindableElement, ExcalidrawDiamondElement, ExcalidrawElement, ExcalidrawEllipseElement, ExcalidrawEmbeddableElement, ExcalidrawFrameLikeElement, ExcalidrawFreeDrawElement, ExcalidrawIframeElement, ExcalidrawImageElement, ExcalidrawVideoElement, ExcalidrawLinearElement, ExcalidrawRectangleElement, ExcalidrawSelectionElement, ExcalidrawTextElement } from "@orangecatai/element/types";
|
|
3
3
|
import type { Curve, LineSegment, Polygon, Radians } from "@orangecatai/math";
|
|
4
4
|
import type { Drawable, Op } from "roughjs/bin/core";
|
|
5
5
|
export type Polyline<Point extends GlobalPoint | LocalPoint> = LineSegment<Point>[];
|
|
@@ -29,7 +29,7 @@ export type GeometricShape<Point extends GlobalPoint | LocalPoint> = {
|
|
|
29
29
|
type: "polycurve";
|
|
30
30
|
data: Polycurve<Point>;
|
|
31
31
|
};
|
|
32
|
-
type RectangularElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawImageElement | ExcalidrawIframeElement | ExcalidrawTextElement | ExcalidrawSelectionElement;
|
|
32
|
+
type RectangularElement = ExcalidrawRectangleElement | ExcalidrawDiamondElement | ExcalidrawFrameLikeElement | ExcalidrawEmbeddableElement | ExcalidrawImageElement | ExcalidrawVideoElement | ExcalidrawIframeElement | ExcalidrawTextElement | ExcalidrawSelectionElement;
|
|
33
33
|
export declare const getPolygonShape: <Point extends GlobalPoint | LocalPoint>(element: RectangularElement) => GeometricShape<Point>;
|
|
34
34
|
export declare const getSelectionBoxShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawElement, elementsMap: ElementsMap, padding?: number) => GeometricShape<Point>;
|
|
35
35
|
export declare const getEllipseShape: <Point extends GlobalPoint | LocalPoint>(element: ExcalidrawEllipseElement) => GeometricShape<Point>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orangecatai/element",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/types/element/src/index.d.ts",
|
|
6
6
|
"main": "./dist/prod/index.js",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@orangecatai/common": "0.0.
|
|
66
|
+
"@orangecatai/common": "0.0.4",
|
|
67
67
|
"@orangecatai/math": "0.0.2"
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function resolveGeminiApiKey(propKey?: string): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function resolveLeonardoApiKey(propKey?: string): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function resolveOpenRouterApiKey(propKey?: string): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function resolveRemoveBgApiKey(propKey?: string): string;
|