Repository navigation
Expand file tree
/
Copy pathtypes.ts
More file actions
232 lines (196 loc) · 5.55 KB
/
Copy pathtypes.ts
File metadata and controls
232 lines (196 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
import React from 'react';
export type Section = {
id: string;
title: string;
icon: React.ReactNode;
content: React.ReactNode;
};
export type ElementType = 'text' | 'image' | 'shape' | 'path' | 'table' | 'mindmap' | 'geogebra' | 'figure' | 'container' | 'math' | 'p5';
export type LayoutRole = 'text' | 'image' | 'table' | 'math' | 'diagram';
export type LayoutOrientation = 'portrait' | 'landscape' | 'square';
export type LayoutSlotMetadata = {
templateId: string;
templateSlotId: string;
role: LayoutRole | null;
};
export type LayoutTemplateSlot = {
id: string;
name: string;
x: number;
y: number;
w: number;
h: number;
};
export type LayoutTemplate = {
schemaVersion: 1;
id: string;
name: string;
description: string;
orientation: LayoutOrientation;
source: 'built-in' | 'user';
slots: LayoutTemplateSlot[];
};
export type ShapeType =
| 'rectangle' | 'square' | 'circle' | 'triangle' | 'star' | 'polygon'
// Standard Geometric
| 'parallelogram' | 'trapezium' | 'rhombus' | 'kite'
// Polygons
| 'pentagon' | 'hexagon' | 'heptagon' | 'octagon' | 'nonagon' | 'decagon'
// Specialized
| 'arrow' | 'ring' | 'crescent' | 'heart' | 'semicircle' | 'minus' | 'plus' | 'pic'
| 'cloud' | 'lightning' | 'shield' | 'badge' | 'speech_bubble' | 'capsule' | 'cross_sign' | 'chevron' | 'flower' | 'wave'
| 'right_triangle' | 'custom_polygon';
export type TextStyle = {
fontSize?: number;
fontWeight?: string;
fontFamily?: string;
fontStyle?: 'normal' | 'italic';
textAlign?: 'left' | 'center' | 'right' | 'justify';
color?: string;
lineHeight?: number;
};
export type BoardConfig = {
backgroundColor?: string;
borderRadius?: number;
showGrid?: boolean;
gridRows?: number;
gridCols?: number;
showGuides?: boolean;
bleed?: number;
};
export type TableData = {
rows: number;
cols: number;
headers: string[];
data: string[][];
textColor?: string;
};
export type MindMapNode = {
label: string;
children?: MindMapNode[];
};
export type MindMapData = {
root: string;
children: MindMapNode[];
};
export type GeoGebraData = {
code: string; // GeoGebra commands
topic?: string; // User's original topic
appType?: 'graphing' | 'geometry' | 'classic'; // App variant
base64State?: string; // Persisted applet state for faster reload
};
export type P5ModelProvider = 'gemini' | 'openrouter';
export type P5Data = {
code: string; // p5.js sketch code
topic?: string; // User's original topic/prompt
modelUsed?: P5ModelProvider; // Which AI model generated the code
};
export type CanvasElement = {
id: string;
type: ElementType;
x: number;
y: number;
w: number;
h: number;
color: string;
zIndex: number;
name: string;
content?: string; // Can contain HTML now
src?: string;
// Shape specific properties
shapeType?: ShapeType;
// Path specific properties
path?: string;
points?: number[][] | { x: number, y: number }[]; // For perfect-freehand: [x, y, pressure], or Shape vertices: {x, y}
strokeColor?: string;
strokeWidth?: number;
snapToBox?: boolean;
locked?: boolean;
rotation?: number;
// Text specific properties
textStyle?: TextStyle;
// New Complex Data Types
tableData?: TableData;
mindMapData?: MindMapData;
mermaidCode?: string;
// Board-specific config (for 'container' type elements)
boardConfig?: BoardConfig;
// GeoGebra animation data
geogebraData?: GeoGebraData;
// P5.js animation data
p5Data?: P5Data;
// Persistent metadata for reusable layout slots.
layoutSlot?: LayoutSlotMetadata;
// Transient state
justCreated?: boolean;
};
export type AspectRatioMode = 'page' | 'slide' | 'custom';
export type CanvasConfig = {
width: number;
height: number;
mode: AspectRatioMode;
presetName: string; // e.g., 'A4', '16:9'
isFlipbook: boolean;
borderRadius: number;
backgroundColor: string;
bleed: number; // in points (e.g., 9 for 1/8 inch)
showGuides: boolean;
gridRows: number;
gridCols: number;
showGrid: boolean;
};
// =====================
// Chat & AI Types
// =====================
export type AIModelId = 'gemini-3.5-flash-preview' | 'gemini-3-pro-preview';
export type AIModel = {
id: AIModelId;
name: string;
description: string;
icon: string; // emoji or icon name
specialization: 'layout' | 'analysis' | 'general';
};
export type ChatMessageRole = 'user' | 'assistant' | 'system';
export type ChatMessage = {
id: string;
role: ChatMessageRole;
content: string;
timestamp: number;
modelId?: AIModelId;
layoutPlan?: LayoutPlan; // Attached if AI proposes a layout
imageSearchResults?: Array<{ id: string; url: string; thumbnail: string; alt: string; photographer: string; photographerUrl: string }>; // Image search results
};
export type LayoutPlanElement = {
id: string;
type: ElementType;
name: string;
description: string;
x: number;
y: number;
w: number;
h: number;
content?: string;
src?: string;
mermaidCode?: string;
boardConfig?: BoardConfig;
textStyle?: TextStyle;
tableData?: TableData; // For table elements
shapeType?: ShapeType; // For shape elements
color?: string; // Shape fill color
points?: { x: number; y: number }[]; // Custom polygon vertices
};
export type LayoutPlan = {
id: string;
title: string;
description: string;
elements: LayoutPlanElement[];
reasoning: string;
status: 'pending' | 'approved' | 'modified' | 'rejected';
baseRevision?: number;
};
export type ChatSession = {
messages: ChatMessage[];
activeModelId: AIModelId;
pendingPlan: LayoutPlan | null;
isGenerating: boolean;
};