Files
tweakcn/types/live-preview-embed.ts
Sahaj Jain 5fe4958db2 Feature/preview external (#225)
* Enhance Preview Panel and Support External Websites (#184)

* feat: Add Block Viewer for Preview Panel

* feat: support theme injection for external websites

* refactor: Improve Naming and Composition

* Support for Google Fonts in Preview script and Error Feedback (#202)

* feat: Add support for loading Google Fonts in the embed script.

* feat: Add error state and UI feedback

* fix font loading by overriding classes

* add reset button + update some ui

* syntax highlighting plus copy changes

* rename script

* update ui for connection status

* ui

* zustand store for preview state

* use nuqs for active preview tab

* get shadows working

* refactor

* A

* add tracking

---------

Co-authored-by: Luis Llanes <137589205+llanesluis@users.noreply.github.com>
Co-authored-by: Luis Llanes <luisllaboj@gmail.com>
2025-10-12 02:15:57 +05:30

43 lines
1.2 KiB
TypeScript

import type { ThemeEditorState } from "@/types/editor";
// Keep in sync with public/live-preview-embed-script.js TWEAKCN_MESSAGE
export const MESSAGE = {
PING: "TWEAKCN_PING",
PONG: "TWEAKCN_PONG",
CHECK_SHADCN: "TWEAKCN_CHECK_SHADCN",
SHADCN_STATUS: "TWEAKCN_SHADCN_STATUS",
THEME_UPDATE: "TWEAKCN_THEME_UPDATE",
THEME_APPLIED: "TWEAKCN_THEME_APPLIED",
EMBED_LOADED: "TWEAKCN_EMBED_LOADED",
EMBED_ERROR: "TWEAKCN_EMBED_ERROR",
} as const;
export type MessageType = (typeof MESSAGE)[keyof typeof MESSAGE];
export interface ShadcnStatusPayload {
supported: boolean;
}
export interface ThemeUpdatePayload {
themeState: ThemeEditorState;
}
export type EmbedMessage =
| { type: typeof MESSAGE.PING }
| { type: typeof MESSAGE.PONG }
| { type: typeof MESSAGE.CHECK_SHADCN }
| { type: typeof MESSAGE.SHADCN_STATUS; payload: ShadcnStatusPayload }
| { type: typeof MESSAGE.THEME_UPDATE; payload: ThemeUpdatePayload }
| { type: typeof MESSAGE.THEME_APPLIED }
| { type: typeof MESSAGE.EMBED_LOADED }
| { type: typeof MESSAGE.EMBED_ERROR; payload: { error: string } };
export type IframeStatus =
| "unknown"
| "checking"
| "connected"
| "supported"
| "unsupported"
| "missing"
| "error";