refactor(sdk): stabilize widget kinds + broaden goView media keys

This commit is contained in:
clawdbot 2026-01-29 00:44:44 +08:00
parent 2cab730bf9
commit 31ad748735
2 changed files with 18 additions and 4 deletions

View File

@ -137,6 +137,12 @@ function isIframe(c: GoViewComponentLike): boolean {
k.includes('browser') ||
k.includes('webpage') ||
k.includes('website') ||
// Dashboard/report embeds are almost always iframes.
k.includes('grafana') ||
k.includes('powerbi') ||
k.includes('metabase') ||
k.includes('superset') ||
k.includes('tableau') ||
// Chinese low-code widgets / dashboards sometimes label this more directly.
k.includes('网页') ||
k.includes('嵌入') ||
@ -199,19 +205,24 @@ function isVideo(c: GoViewComponentLike): boolean {
return (
k.includes('mp4') ||
k.includes('media') ||
// "player" is broad; keep it but prefer more specific matches above.
k.includes('player') ||
// player implementation names frequently used in low-code widgets
k.includes('flvjs') ||
k.includes('hlsjs') ||
k.includes('dplayer') ||
k.includes('vlc') ||
// streaming/protocol keywords (often used directly as widget keys)
k.includes('stream') ||
k.includes('rtsp') ||
k.includes('rtmp') ||
k.includes('webrtc') ||
k.includes('srt') ||
k.includes('wss') ||
k.includes('ws') ||
k.includes('hls') ||
k.includes('m3u8') ||
k.includes('flv') ||
k.includes('webrtc') ||
k.includes('dash') ||
// common low-code names for live streams
k.includes('live') ||

View File

@ -15,9 +15,14 @@ export interface Transform {
scaleY?: number;
}
// Keep this as a literal union (instead of inferring from WidgetNode['type']) so that
// discriminated-union narrowing stays stable across packages and we avoid accidental `never`
// issues in editor switch statements.
export type WidgetKind = 'text' | 'image' | 'iframe' | 'video';
export interface WidgetNodeBase {
id: string;
type: string;
type: WidgetKind;
rect: Rect;
transform?: Transform;
locked?: boolean;
@ -90,8 +95,6 @@ export interface VideoWidgetNode extends WidgetNodeBase {
export type WidgetNode = TextWidgetNode | ImageWidgetNode | IframeWidgetNode | VideoWidgetNode;
export type WidgetKind = WidgetNode['type'];
export type WidgetNodeByType = {
text: TextWidgetNode;
image: ImageWidgetNode;