@orangecatai/element 0.0.1 → 0.0.3
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/README.md +1 -1
- package/dist/dev/index.js +42 -3
- package/dist/dev/index.js.map +2 -2
- package/dist/prod/index.js +1 -1
- package/dist/types/common/src/keys.d.ts +2 -0
- package/dist/types/element/src/arrows/focus.d.ts +1 -1
- package/dist/types/element/src/binding.d.ts +3 -3
- package/dist/types/element/src/bounds.d.ts +1 -1
- package/dist/types/element/src/collision.d.ts +1 -1
- package/dist/types/element/src/delta.d.ts +2 -2
- package/dist/types/element/src/dragElements.d.ts +1 -1
- package/dist/types/element/src/duplicate.d.ts +1 -1
- package/dist/types/element/src/embeddable.d.ts +1 -1
- package/dist/types/element/src/flowchart.d.ts +1 -1
- package/dist/types/element/src/frame.d.ts +4 -4
- package/dist/types/element/src/groups.d.ts +1 -1
- package/dist/types/element/src/renderElement.d.ts +1 -1
- package/dist/types/element/src/selection.d.ts +1 -1
- package/dist/types/element/src/shape.d.ts +2 -2
- package/dist/types/element/src/store.d.ts +2 -2
- package/dist/types/element/src/textElement.d.ts +1 -1
- package/dist/types/element/src/transform.d.ts +1 -1
- package/dist/types/element/src/utils.d.ts +1 -1
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +184 -7
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +7 -7
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionExport.d.ts +9 -9
- package/dist/types/excalidraw/actions/actionFrame.d.ts +178 -0
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +7 -7
- package/dist/types/excalidraw/actions/actionLink.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionMenu.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionProperties.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionStyles.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +4 -4
- package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
- package/dist/types/excalidraw/actions/index.d.ts +1 -1
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/appState.d.ts +4 -4
- package/dist/types/excalidraw/components/AIChatPanel.d.ts +114 -0
- package/dist/types/excalidraw/components/Actions.d.ts +4 -1
- package/dist/types/excalidraw/components/App.d.ts +13 -2
- 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/ColorPicker.d.ts +2 -2
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/colorConversions.d.ts +27 -0
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +1 -1
- package/dist/types/excalidraw/components/DarkModeToggle.d.ts +1 -1
- package/dist/types/excalidraw/components/DefaultSidebar.d.ts +2 -2
- package/dist/types/excalidraw/components/ElementCanvasButtons.d.ts +1 -1
- package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +2 -2
- package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +1 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +1 -1
- package/dist/types/excalidraw/components/FontPicker/keyboardNavHandlers.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 +16 -0
- package/dist/types/excalidraw/components/ImageExportDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/ImageGeneratorPanel.d.ts +43 -0
- package/dist/types/excalidraw/components/ImageQuickEditPanel.d.ts +16 -0
- package/dist/types/excalidraw/components/JSONExportDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/LayerUI.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/index.d.ts +1 -1
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +2 -2
- 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 +112 -0
- package/dist/types/excalidraw/components/ai-chat/audioUtils.d.ts +10 -0
- package/dist/types/excalidraw/components/ai-chat/canvasTools.d.ts +685 -0
- 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/ai-chat/reviewerAgent.d.ts +64 -0
- package/dist/types/excalidraw/components/auto-resize/AutoResizePanel.d.ts +17 -0
- package/dist/types/excalidraw/components/auto-resize/AutoResizePanelHost.d.ts +4 -0
- package/dist/types/excalidraw/components/auto-resize/AutoResizeShimmerLayer.d.ts +11 -0
- package/dist/types/excalidraw/components/auto-resize/autoResizeEngine.d.ts +144 -0
- package/dist/types/excalidraw/components/auto-resize/autoResizePanelStore.d.ts +15 -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/image-generation/pendingGenerations.d.ts +30 -0
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +1 -1
- package/dist/types/excalidraw/components/template-builder/TemplateBuilderPanelHost.d.ts +4 -0
- package/dist/types/excalidraw/components/template-builder/TemplateBuilderTray.d.ts +4 -0
- package/dist/types/excalidraw/components/template-builder/slotTypes.d.ts +43 -0
- package/dist/types/excalidraw/components/template-builder/templateBuilderStore.d.ts +19 -0
- package/dist/types/excalidraw/components/ui/avatar.d.ts +6 -0
- package/dist/types/excalidraw/components/ui/button.d.ts +11 -0
- package/dist/types/excalidraw/components/ui/chat-container.d.ts +17 -0
- package/dist/types/excalidraw/components/ui/code-block.d.ts +16 -0
- package/dist/types/excalidraw/components/ui/markdown.d.ts +10 -0
- package/dist/types/excalidraw/components/ui/message.d.ts +35 -0
- package/dist/types/excalidraw/components/ui/prompt-input.d.ts +28 -0
- package/dist/types/excalidraw/components/ui/scroll-button.d.ts +10 -0
- package/dist/types/excalidraw/components/ui/textarea.d.ts +3 -0
- package/dist/types/excalidraw/components/ui/tooltip.d.ts +7 -0
- package/dist/types/excalidraw/data/blob.d.ts +19 -17
- package/dist/types/excalidraw/data/json.d.ts +8 -8
- package/dist/types/excalidraw/data/library.d.ts +1 -1
- package/dist/types/excalidraw/fonts/Fonts.d.ts +19 -2
- package/dist/types/excalidraw/i18n.d.ts +1 -1
- package/dist/types/excalidraw/index.d.ts +9 -0
- package/dist/types/excalidraw/lib/utils.d.ts +2 -0
- package/dist/types/excalidraw/types.d.ts +229 -0
- package/dist/types/excalidraw/utils/geminiApiKey.d.ts +1 -0
- package/dist/types/excalidraw/utils/leonardoApiKey.d.ts +1 -0
- package/dist/types/excalidraw/utils/openRouterApiKey.d.ts +1 -0
- package/dist/types/excalidraw/utils/removeBgApiKey.d.ts +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export type ParsedRectangle = {
|
|
2
|
+
kind: "rectangle";
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
backgroundColor: string;
|
|
8
|
+
backgroundGradient?: string;
|
|
9
|
+
strokeColor: string;
|
|
10
|
+
strokeWidth: number;
|
|
11
|
+
opacity: number;
|
|
12
|
+
borderRadius: number;
|
|
13
|
+
};
|
|
14
|
+
export type ParsedEllipse = {
|
|
15
|
+
kind: "ellipse";
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
backgroundColor: string;
|
|
21
|
+
backgroundGradient?: string;
|
|
22
|
+
strokeColor: string;
|
|
23
|
+
strokeWidth: number;
|
|
24
|
+
opacity: number;
|
|
25
|
+
};
|
|
26
|
+
export type ParsedText = {
|
|
27
|
+
kind: "text";
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
text: string;
|
|
33
|
+
fontSize: number;
|
|
34
|
+
fontFamily: number;
|
|
35
|
+
color: string;
|
|
36
|
+
textAlign: "left" | "center" | "right";
|
|
37
|
+
opacity: number;
|
|
38
|
+
};
|
|
39
|
+
export type ParsedImage = {
|
|
40
|
+
kind: "image";
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
dataUrl: string;
|
|
46
|
+
};
|
|
47
|
+
export type ParsedElement = ParsedRectangle | ParsedEllipse | ParsedText | ParsedImage;
|
|
48
|
+
/**
|
|
49
|
+
* Render `html` in an off-screen iframe and walk the DOM to produce an
|
|
50
|
+
* array of ParsedElement objects, translated so the root .canvas div sits
|
|
51
|
+
* at (frameX, frameY) in Excalidraw canvas coordinates.
|
|
52
|
+
*/
|
|
53
|
+
export declare function htmlToExcalidrawElements(html: string, frameX: number, frameY: number, frameWidth: number, frameHeight: number, customFontMap?: Record<string, number>): Promise<ParsedElement[]>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ToolCall } from "./agentLoop";
|
|
2
|
+
export type OpenRouterDelta = {
|
|
3
|
+
content: string | null;
|
|
4
|
+
toolCalls: Array<{
|
|
5
|
+
index: number;
|
|
6
|
+
id?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
function?: {
|
|
9
|
+
name?: string;
|
|
10
|
+
arguments?: string;
|
|
11
|
+
};
|
|
12
|
+
}> | null;
|
|
13
|
+
finishReason: string | null;
|
|
14
|
+
};
|
|
15
|
+
export type ToolCallAccumulator = {
|
|
16
|
+
id: string;
|
|
17
|
+
type: "function";
|
|
18
|
+
function: {
|
|
19
|
+
name: string;
|
|
20
|
+
arguments: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Parse a single OpenAI-compatible SSE chunk JSON string into a typed delta.
|
|
25
|
+
* Returns null if the JSON is invalid or missing expected structure.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseOpenRouterChunk(jsonStr: string): OpenRouterDelta | null;
|
|
28
|
+
/**
|
|
29
|
+
* Async generator that yields parsed deltas from an OpenRouter streaming
|
|
30
|
+
* response. Reuses `parseSSEStream` for SSE line parsing.
|
|
31
|
+
*/
|
|
32
|
+
export declare function streamOpenRouter(response: Response): AsyncGenerator<OpenRouterDelta>;
|
|
33
|
+
/**
|
|
34
|
+
* Accumulate streaming tool call deltas into complete ToolCall objects.
|
|
35
|
+
* OpenRouter sends tool calls in chunks:
|
|
36
|
+
* - First chunk for a tool: has `id`, `type`, `function.name`, empty `function.arguments`
|
|
37
|
+
* - Subsequent chunks: has `function.arguments` fragment to append
|
|
38
|
+
*/
|
|
39
|
+
export declare function accumulateToolCalls(accumulated: ToolCallAccumulator[], delta: OpenRouterDelta): ToolCallAccumulator[];
|
|
40
|
+
/**
|
|
41
|
+
* Convert accumulators to the ToolCall type used by the agent loop.
|
|
42
|
+
*/
|
|
43
|
+
export declare function finalizeToolCalls(accumulated: ToolCallAccumulator[]): ToolCall[];
|
|
44
|
+
/**
|
|
45
|
+
* Check if a response is a streaming SSE response.
|
|
46
|
+
* Returns true only when the response has a body AND the content-type
|
|
47
|
+
* indicates an SSE stream (`text/event-stream`). Any other content-type
|
|
48
|
+
* (including `application/json` or `text/plain`) falls back to non-streaming.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isStreamingResponse(response: Response): boolean;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* reviewerAgent.ts
|
|
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.
|
|
9
|
+
*
|
|
10
|
+
* The reviewer is a separate LLM call from the main agent loop so it
|
|
11
|
+
* brings an independent eye to the generated banner.
|
|
12
|
+
*/
|
|
13
|
+
import type { BrandContext } from "../../types";
|
|
14
|
+
export type ReviewIssue = {
|
|
15
|
+
/** Which design element is affected */
|
|
16
|
+
element: "headline" | "subheadline" | "cta" | "image" | "layout" | "brand";
|
|
17
|
+
/** How bad it is */
|
|
18
|
+
severity: "critical" | "major" | "minor";
|
|
19
|
+
/** What is wrong — one sentence */
|
|
20
|
+
problem: string;
|
|
21
|
+
/** One-line direction for the fix */
|
|
22
|
+
fix: string;
|
|
23
|
+
/**
|
|
24
|
+
* Precise instruction with numeric coordinates or px values.
|
|
25
|
+
* Examples:
|
|
26
|
+
* "Reduce headline font-size from 72px to 48px"
|
|
27
|
+
* "Move CTA button to x=380,y=440 (bottom-right quadrant)"
|
|
28
|
+
* "Shift text container left boundary from x=0 to x=20 so it clears the image at x=260"
|
|
29
|
+
*/
|
|
30
|
+
preciseInstruction: string;
|
|
31
|
+
};
|
|
32
|
+
export type ReviewerFeedback = {
|
|
33
|
+
/** true = no actionable issues; main agent should finalize */
|
|
34
|
+
approved: boolean;
|
|
35
|
+
/** empty when approved */
|
|
36
|
+
issues: ReviewIssue[];
|
|
37
|
+
/** 1-2 sentence overall verdict */
|
|
38
|
+
summary: string;
|
|
39
|
+
/** which reviewer round produced this (1-based) */
|
|
40
|
+
iteration: number;
|
|
41
|
+
};
|
|
42
|
+
export declare function runReviewerAgent(opts: {
|
|
43
|
+
screenshotDataUrl: string;
|
|
44
|
+
htmlSource: string;
|
|
45
|
+
frame: {
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
id: string;
|
|
49
|
+
};
|
|
50
|
+
imagePlacement?: {
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
};
|
|
56
|
+
/** Original user request — first message only, not full conversation history */
|
|
57
|
+
userBrief: string;
|
|
58
|
+
brandContext?: BrandContext;
|
|
59
|
+
apiKey: string;
|
|
60
|
+
/** OpenRouter model tag. Must be vision-capable. Defaults to gemini-3.1-flash-lite-preview */
|
|
61
|
+
reviewerModel?: string;
|
|
62
|
+
signal?: AbortSignal;
|
|
63
|
+
iteration: number;
|
|
64
|
+
}): Promise<ReviewerFeedback>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "./AutoResizePanel.scss";
|
|
2
|
+
import type { ExcalidrawFrameLikeElement, NonDeletedExcalidrawElement } from "@orangecatai/element/types";
|
|
3
|
+
import type { AppClassProperties } from "../../types";
|
|
4
|
+
export declare const AutoResizePanel: ({ element, app, onClose, onBeforeAutoResize, onAfterAutoResize, onRunningChange, openRouterApiKey, chatModel, agentImageModel, }: {
|
|
5
|
+
element: NonDeletedExcalidrawElement & ExcalidrawFrameLikeElement;
|
|
6
|
+
app: AppClassProperties;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onBeforeAutoResize?: () => Promise<{
|
|
9
|
+
allowed: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
}>;
|
|
12
|
+
onAfterAutoResize?: () => void;
|
|
13
|
+
onRunningChange?: (running: boolean) => void;
|
|
14
|
+
openRouterApiKey: string;
|
|
15
|
+
chatModel: string;
|
|
16
|
+
agentImageModel?: string;
|
|
17
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders shimmer overlays on top of in-progress auto-resize frames.
|
|
3
|
+
* Rendered unconditionally from App.tsx — same React tree as FrameToolbar
|
|
4
|
+
* and ElementCanvasButtons. Uses useExcalidrawAppState() for reactive
|
|
5
|
+
* viewport state (scroll, zoom, offset) so it repositions on every change.
|
|
6
|
+
*
|
|
7
|
+
* IMPORTANT: Reads the CURRENT frame position from the scene elements,
|
|
8
|
+
* not from the stored LoadingFrameInfo. This ensures the shimmer moves
|
|
9
|
+
* with the frame if the user drags it during generation.
|
|
10
|
+
*/
|
|
11
|
+
export declare const AutoResizeShimmerLayer: () => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
elementId: string;
|
|
20
|
+
slotType?: string;
|
|
21
|
+
relX: number;
|
|
22
|
+
relY: number;
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
text: string;
|
|
26
|
+
fontSize: number;
|
|
27
|
+
color: string;
|
|
28
|
+
textAlign: string;
|
|
29
|
+
fontWeight: string;
|
|
30
|
+
opacity: number;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "image";
|
|
33
|
+
elementId: string;
|
|
34
|
+
slotType?: string;
|
|
35
|
+
relX: number;
|
|
36
|
+
relY: number;
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
dataUrl: string;
|
|
40
|
+
opacity: number;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "rect";
|
|
43
|
+
elementId: string;
|
|
44
|
+
slotType?: string;
|
|
45
|
+
relX: number;
|
|
46
|
+
relY: number;
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
backgroundColor: string;
|
|
50
|
+
borderRadius: number;
|
|
51
|
+
opacity: number;
|
|
52
|
+
};
|
|
53
|
+
type SourceFrameInfo = {
|
|
54
|
+
frame: ExcalidrawFrameLikeElement;
|
|
55
|
+
background: {
|
|
56
|
+
type: "solid";
|
|
57
|
+
color: string;
|
|
58
|
+
elementId?: string;
|
|
59
|
+
} | {
|
|
60
|
+
type: "image";
|
|
61
|
+
dataUrl: string;
|
|
62
|
+
elementId?: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: "none";
|
|
65
|
+
};
|
|
66
|
+
foreground: ForegroundEl[];
|
|
67
|
+
};
|
|
68
|
+
export declare function extractFrameInfo(elements: readonly ExcalidrawElement[], frame: ExcalidrawFrameLikeElement, files: BinaryFiles): SourceFrameInfo;
|
|
69
|
+
export declare function computeCropLoss(sourceAR: number, targetAR: number): number;
|
|
70
|
+
export declare function needsBackgroundRegeneration(srcW: number, srcH: number, tgtW: number, tgtH: number): boolean;
|
|
71
|
+
export declare function nearestGeminiAspectRatio(w: number, h: number): string;
|
|
72
|
+
/**
|
|
73
|
+
* Selects the optimal resolution for a given target dimension and aspect ratio.
|
|
74
|
+
* Chooses the resolution level that is closest to (but preferably >= ) the target size.
|
|
75
|
+
*/
|
|
76
|
+
export declare function selectOptimalResolution(targetW: number, targetH: number, aspectRatio: string): "0.5K" | "1K" | "2K" | "4K";
|
|
77
|
+
/**
|
|
78
|
+
* Returns the x, y, width, height (relative to frame top-left) to place an
|
|
79
|
+
* image such that:
|
|
80
|
+
* - it covers the entire frame (scale up if needed)
|
|
81
|
+
* - the centres of the image and frame coincide
|
|
82
|
+
*/
|
|
83
|
+
export declare function fitImageToFrame(imgW: number, imgH: number, frameW: number, frameH: number): {
|
|
84
|
+
relX: number;
|
|
85
|
+
relY: number;
|
|
86
|
+
width: number;
|
|
87
|
+
height: number;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Fit-contain: scale image to fit entirely within the bbox, preserving aspect
|
|
91
|
+
* ratio, centred. Use for foreground elements (logos, product images) where
|
|
92
|
+
* cropping or stretching is not acceptable.
|
|
93
|
+
*/
|
|
94
|
+
export declare function containImageInBbox(imgW: number, imgH: number, bboxW: number, bboxH: number): {
|
|
95
|
+
relX: number;
|
|
96
|
+
relY: number;
|
|
97
|
+
width: number;
|
|
98
|
+
height: number;
|
|
99
|
+
};
|
|
100
|
+
export declare function getProductMinBox(targetW: number, targetH: number): {
|
|
101
|
+
minWidth: number;
|
|
102
|
+
minHeight: number;
|
|
103
|
+
};
|
|
104
|
+
export declare function enforceMinProductBox({ x, y, width, height, targetW, targetH, }: {
|
|
105
|
+
x: number;
|
|
106
|
+
y: number;
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
targetW: number;
|
|
110
|
+
targetH: number;
|
|
111
|
+
}): {
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
width: number;
|
|
115
|
+
height: number;
|
|
116
|
+
};
|
|
117
|
+
export type PreCreatedFrameInfo = {
|
|
118
|
+
frameId: string;
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
width: number;
|
|
122
|
+
height: number;
|
|
123
|
+
};
|
|
124
|
+
export declare function preCreateAllFrames(targetDimensions: TargetDimension[], sourceFrame: ExcalidrawFrameLikeElement, app: AppClassProperties): PreCreatedFrameInfo[];
|
|
125
|
+
export declare function runAutoResize(opts: {
|
|
126
|
+
sourceFrameId: string;
|
|
127
|
+
targetDimensions: TargetDimension[];
|
|
128
|
+
app: AppClassProperties;
|
|
129
|
+
geminiApiKey: string;
|
|
130
|
+
openRouterApiKey: string;
|
|
131
|
+
chatModel?: string;
|
|
132
|
+
agentImageModel?: string;
|
|
133
|
+
customFontMap?: Record<string, number>;
|
|
134
|
+
onBeforeAutoResize?: () => Promise<{
|
|
135
|
+
allowed: boolean;
|
|
136
|
+
error?: string;
|
|
137
|
+
}>;
|
|
138
|
+
onAfterAutoResize?: () => void;
|
|
139
|
+
onProgress?: ProgressCallback;
|
|
140
|
+
signal?: AbortSignal;
|
|
141
|
+
/** Pass the result of preCreateAllFrames() to skip redundant frame creation */
|
|
142
|
+
preCreatedFrameInfos?: PreCreatedFrameInfo[];
|
|
143
|
+
}): Promise<DimensionResult[]>;
|
|
144
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExcalidrawFrameLikeElement, NonDeletedExcalidrawElement } from "@orangecatai/element/types";
|
|
2
|
+
export type AutoResizePanelState = {
|
|
3
|
+
element: (NonDeletedExcalidrawElement & ExcalidrawFrameLikeElement) | null;
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
isRunning: boolean;
|
|
6
|
+
};
|
|
7
|
+
type Listener = (state: AutoResizePanelState) => void;
|
|
8
|
+
export declare const autoResizePanelStore: {
|
|
9
|
+
open(element: NonDeletedExcalidrawElement & ExcalidrawFrameLikeElement): void;
|
|
10
|
+
close(): void;
|
|
11
|
+
setRunning(running: boolean): void;
|
|
12
|
+
getState(): AutoResizePanelState;
|
|
13
|
+
subscribe(fn: Listener): () => void;
|
|
14
|
+
};
|
|
15
|
+
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;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pending image generation state — shared across ImageGeneratorPanel and
|
|
3
|
+
* ImageQuickEditPanel so generation survives panel unmount/remount.
|
|
4
|
+
*
|
|
5
|
+
* Flow:
|
|
6
|
+
* 1. User clicks Generate → startPendingGeneration(id, prompt, settings, controller)
|
|
7
|
+
* Stores prompt, model/ratio/resolution, and AbortController. Request continues
|
|
8
|
+
* even if user clicks away (no unmount-abort).
|
|
9
|
+
* 2. Panel subscribes via subscribeGenerationDone(id, cb). If generation already
|
|
10
|
+
* finished while unmounted, cb is invoked immediately with finishedError.
|
|
11
|
+
* 3. On success/error → finishPendingGeneration(id, error) notifies subscribers.
|
|
12
|
+
* 4. On success only → clearGenerationState(id) removes the entry so reselecting
|
|
13
|
+
* the frame/image shows a clean prompt instead of the old one.
|
|
14
|
+
* 5. Stop button → abortPendingGeneration(id) aborts the controller.
|
|
15
|
+
*/
|
|
16
|
+
export type GenerationDoneCallback = (error: string | null) => void;
|
|
17
|
+
export interface GenerationSettings {
|
|
18
|
+
model: string;
|
|
19
|
+
ratio: string;
|
|
20
|
+
resolution: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function startPendingGeneration(elementId: string, prompt: string, settings: GenerationSettings, controller: AbortController): void;
|
|
23
|
+
export declare function finishPendingGeneration(elementId: string, error: string | null): void;
|
|
24
|
+
export declare function subscribeGenerationDone(elementId: string, fn: GenerationDoneCallback): boolean;
|
|
25
|
+
export declare function unsubscribeGenerationDone(elementId: string, fn: GenerationDoneCallback): void;
|
|
26
|
+
export declare function clearGenerationState(elementId: string): void;
|
|
27
|
+
export declare function abortPendingGeneration(elementId: string): void;
|
|
28
|
+
export declare function getPendingPrompt(elementId: string): string;
|
|
29
|
+
export declare function getPendingSettings(elementId: string): GenerationSettings | null;
|
|
30
|
+
export declare function hasPendingGeneration(elementId: string): boolean;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const SLOT_TYPES: readonly [{
|
|
2
|
+
readonly id: "background";
|
|
3
|
+
readonly label: "Background";
|
|
4
|
+
readonly color: "#94a3b8";
|
|
5
|
+
readonly kind: "rect";
|
|
6
|
+
}, {
|
|
7
|
+
readonly id: "logo";
|
|
8
|
+
readonly label: "Logo";
|
|
9
|
+
readonly color: "#f97316";
|
|
10
|
+
readonly kind: "image";
|
|
11
|
+
}, {
|
|
12
|
+
readonly id: "product_image";
|
|
13
|
+
readonly label: "Product Image";
|
|
14
|
+
readonly color: "#22c55e";
|
|
15
|
+
readonly kind: "image";
|
|
16
|
+
}, {
|
|
17
|
+
readonly id: "headline";
|
|
18
|
+
readonly label: "Headline";
|
|
19
|
+
readonly color: "#3b82f6";
|
|
20
|
+
readonly kind: "text";
|
|
21
|
+
}, {
|
|
22
|
+
readonly id: "subhead";
|
|
23
|
+
readonly label: "Subhead";
|
|
24
|
+
readonly color: "#8b5cf6";
|
|
25
|
+
readonly kind: "text";
|
|
26
|
+
}, {
|
|
27
|
+
readonly id: "cta";
|
|
28
|
+
readonly label: "CTA";
|
|
29
|
+
readonly color: "#ef4444";
|
|
30
|
+
readonly kind: "text";
|
|
31
|
+
}, {
|
|
32
|
+
readonly id: "signoff";
|
|
33
|
+
readonly label: "Signoff";
|
|
34
|
+
readonly color: "#64748b";
|
|
35
|
+
readonly kind: "text";
|
|
36
|
+
}, {
|
|
37
|
+
readonly id: "auxiliary_image";
|
|
38
|
+
readonly label: "Aux Image";
|
|
39
|
+
readonly color: "#14b8a6";
|
|
40
|
+
readonly kind: "image";
|
|
41
|
+
}];
|
|
42
|
+
export type SlotType = typeof SLOT_TYPES[number];
|
|
43
|
+
export type SlotTypeId = SlotType["id"];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type TemplateBuilderState = {
|
|
2
|
+
isOpen: boolean;
|
|
3
|
+
isBuilding: boolean;
|
|
4
|
+
templateName: string;
|
|
5
|
+
campaignTag: string;
|
|
6
|
+
/** The frame element ID that triggered the template builder (set by FrameToolbar). */
|
|
7
|
+
sourceFrameId: string | null;
|
|
8
|
+
};
|
|
9
|
+
type Listener = (state: TemplateBuilderState) => void;
|
|
10
|
+
export declare const templateBuilderStore: {
|
|
11
|
+
open(sourceFrameId?: string): void;
|
|
12
|
+
close(): void;
|
|
13
|
+
setBuilding(b: boolean): void;
|
|
14
|
+
setName(name: string): void;
|
|
15
|
+
setCampaignTag(tag: string): void;
|
|
16
|
+
getState(): TemplateBuilderState;
|
|
17
|
+
subscribe(fn: Listener): () => void;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
3
|
+
declare const Avatar: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
4
|
+
declare const AvatarImage: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarImageProps & React.RefAttributes<HTMLImageElement>, "ref"> & React.RefAttributes<HTMLImageElement>>;
|
|
5
|
+
declare const AvatarFallback: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarFallbackProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
6
|
+
export { Avatar, AvatarImage, AvatarFallback };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const buttonVariants: (props?: ({
|
|
4
|
+
variant?: "link" | "default" | "outline" | "secondary" | "destructive" | "ghost" | null | undefined;
|
|
5
|
+
size?: "icon" | "default" | "sm" | "lg" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type ChatContainerRootProps = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
6
|
+
export type ChatContainerContentProps = {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
10
|
+
export type ChatContainerScrollAnchorProps = {
|
|
11
|
+
className?: string;
|
|
12
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
13
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
14
|
+
declare function ChatContainerRoot({ children, className, ...props }: ChatContainerRootProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare function ChatContainerContent({ children, className, ...props }: ChatContainerContentProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare function ChatContainerScrollAnchor({ className, ...props }: ChatContainerScrollAnchorProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export { ChatContainerRoot, ChatContainerContent, ChatContainerScrollAnchor };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type CodeBlockProps = {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
} & React.HTMLProps<HTMLDivElement>;
|
|
6
|
+
declare function CodeBlock({ children, className, ...props }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export type CodeBlockCodeProps = {
|
|
8
|
+
code: string;
|
|
9
|
+
language?: string;
|
|
10
|
+
theme?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
} & React.HTMLProps<HTMLDivElement>;
|
|
13
|
+
declare function CodeBlockCode({ code, language, theme, className, ...props }: CodeBlockCodeProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export type CodeBlockGroupProps = React.HTMLAttributes<HTMLDivElement>;
|
|
15
|
+
declare function CodeBlockGroup({ children, className, ...props }: CodeBlockGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export { CodeBlockGroup, CodeBlockCode, CodeBlock };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Components } from "react-markdown";
|
|
2
|
+
export type MarkdownProps = {
|
|
3
|
+
children: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
components?: Partial<Components>;
|
|
7
|
+
};
|
|
8
|
+
declare function MarkdownComponent({ children, id, className, components, }: MarkdownProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
declare const Markdown: import("react").MemoExoticComponent<typeof MarkdownComponent>;
|
|
10
|
+
export { Markdown };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Markdown } from "./markdown";
|
|
3
|
+
import { Tooltip } from "@/components/ui/tooltip";
|
|
4
|
+
export type MessageProps = {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
} & React.HTMLProps<HTMLDivElement>;
|
|
8
|
+
declare const Message: ({ children, className, ...props }: MessageProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export type MessageAvatarProps = {
|
|
10
|
+
src: string;
|
|
11
|
+
alt: string;
|
|
12
|
+
fallback?: string;
|
|
13
|
+
delayMs?: number;
|
|
14
|
+
className?: string;
|
|
15
|
+
};
|
|
16
|
+
declare const MessageAvatar: ({ src, alt, fallback, delayMs, className, }: MessageAvatarProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export type MessageContentProps = {
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
markdown?: boolean;
|
|
20
|
+
className?: string;
|
|
21
|
+
} & React.ComponentProps<typeof Markdown> & React.HTMLProps<HTMLDivElement>;
|
|
22
|
+
declare const MessageContent: ({ children, markdown, className, ...props }: MessageContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export type MessageActionsProps = {
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
className?: string;
|
|
26
|
+
} & React.HTMLProps<HTMLDivElement>;
|
|
27
|
+
declare const MessageActions: ({ children, className, ...props }: MessageActionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export type MessageActionProps = {
|
|
29
|
+
className?: string;
|
|
30
|
+
tooltip: React.ReactNode;
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
33
|
+
} & React.ComponentProps<typeof Tooltip>;
|
|
34
|
+
declare const MessageAction: ({ tooltip, children, className, side, ...props }: MessageActionProps) => import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export { Message, MessageAvatar, MessageContent, MessageActions, MessageAction, };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Textarea } from "./textarea";
|
|
3
|
+
import { Tooltip } from "./tooltip";
|
|
4
|
+
export type PromptInputProps = {
|
|
5
|
+
isLoading?: boolean;
|
|
6
|
+
value?: string;
|
|
7
|
+
onValueChange?: (value: string) => void;
|
|
8
|
+
maxHeight?: number | string;
|
|
9
|
+
onSubmit?: () => void;
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
} & React.ComponentProps<"div">;
|
|
14
|
+
declare function PromptInput({ className, isLoading, maxHeight, value, onValueChange, onSubmit, children, disabled, onClick, ...props }: PromptInputProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export type PromptInputTextareaProps = {
|
|
16
|
+
disableAutosize?: boolean;
|
|
17
|
+
} & React.ComponentProps<typeof Textarea>;
|
|
18
|
+
declare function PromptInputTextarea({ className, onKeyDown, disableAutosize, ...props }: PromptInputTextareaProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export type PromptInputActionsProps = React.HTMLAttributes<HTMLDivElement>;
|
|
20
|
+
declare function PromptInputActions({ children, className, ...props }: PromptInputActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export type PromptInputActionProps = {
|
|
22
|
+
className?: string;
|
|
23
|
+
tooltip: React.ReactNode;
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
26
|
+
} & React.ComponentProps<typeof Tooltip>;
|
|
27
|
+
declare function PromptInputAction({ tooltip, children, className, side, ...props }: PromptInputActionProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export { PromptInput, PromptInputTextarea, PromptInputActions, PromptInputAction, };
|