RealBlocks / shared /types.ts
incognitolm
Phase A
06a5f5e
Raw
History Blame Contribute Delete
2.22 kB
// ─── Shared Types ───
// Used by both client and server.
// ─── CSS ───
export interface CssRule {
id: string;
selector: string;
type: 'id' | 'class' | 'element' | 'universal' | 'attribute' | 'pseudo-class' | 'pseudo-element';
properties: CssProperty[];
mediaQuery?: string;
enabled: boolean;
}
export interface CssProperty {
id: string;
name: string;
value: string;
important: boolean;
type: 'standard' | 'variable' | 'custom';
unit: string;
}
// ─── Version History ───
export interface VersionDiffs {
id: string;
projectId: string;
timestamp: number;
userId: string;
username: string;
parentId: string | null;
message: string;
type: 'save' | 'restore' | 'branch';
diffs: Diff[];
}
export interface Diff {
id?: string;
fileId: string;
op: 'content_change' | 'file_add' | 'file_remove' | 'file_rename' | 'css_rule_change' | 'element_change' | 'project_meta_change';
oldValue?: any;
newValue?: any;
path?: string;
}
// ─── Visual Editor Outlines ───
export interface OutlineSlot {
id: string;
parentId: string;
index: number;
occupiedBy: string | null;
}
// ─── Collaboration ───
export interface PointerPosition {
x: number;
y: number;
userId: string;
username: string;
}
export interface BlockDragState {
blockId: string;
x: number;
y: number;
userId: string;
}
export interface TextCursorState {
fieldId: string;
fileId: string;
cursorPosition: number;
userId: string;
username: string;
active: boolean;
}
// ─── Element Registry ───
export interface ElementRef {
id: string;
tagName: string;
classes: string[];
attributes: Record<string, string>;
fileId: string;
linkedTo: string[];
}
// ─── File Upload ───
export interface UploadProgress {
fileName: string;
bytesReceived: number;
totalBytes: number;
status: 'uploading' | 'processing' | 'done' | 'error';
}
// ─── Block Node ───
export interface BlockNodeData {
id: string;
blockId: string;
position: { x: number; y: number };
config: Record<string, any>;
connections: Record<string, string>;
size?: { w: number; h: number };
}