mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-27 11:56:20 +00:00
- Add host-rendered native IDE primitives (PluginCodeEditor/Monaco, PluginDataGrid/@tanstack/react-virtual, PluginSplitPane, PluginErCanvas) with Shadow DOM slot projection (zero iframes, zero plugin JS in renderer) - Expand Remote DOM budgets, expose full 22 Netcatty semantic CSS tokens, add dblclick/contextmenu/scroll/selection events, cursor-anchored PluginPopover, database theme icon, and full-bleed chrome flag - Add dynamic user-approved TCP/TLS byte streams (incl. localhost opt-in blocking internal control ports), in-band STARTTLS upgrade with cert fingerprint confirmation, durable revocable Vault SSH host bindings, plugin-owned encrypted secrets, native ui.openFile/saveFile streaming handles, 4 MiB clipboard, and prefix-filtered storage.keys - Optimize plugin view image pipeline with pooled sandboxed rasterizer window (auto-destroyed on idle/error/dispose), LRU version+hash cache in PluginViewResources, transient failure eviction in HostDrawnViewHost, renderer-side session deduplication, and RemoteImageElement cache + retry - Temporarily enable plugin host by default in hostBootstrap.cjs (marked TODO(revert), opt-out via NETCATTY_PLUGIN_DEV=0)
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import React, { useMemo } from 'react';
|
|
import { LazyLoadBoundary } from '../../ui/lazy-load-boundary';
|
|
import { PluginCodeEditor } from './PluginCodeEditor';
|
|
import { PluginDataGrid } from './PluginDataGrid';
|
|
import { PluginErCanvas } from './PluginErCanvas';
|
|
import type {
|
|
PluginCodeEditorWidgetProps,
|
|
PluginDataGridWidgetProps,
|
|
PluginErCanvasWidgetProps,
|
|
PluginWidgetEventCallback,
|
|
} from './types';
|
|
|
|
export type SlottedWidgetKind = 'code-editor' | 'data-grid' | 'er-canvas';
|
|
|
|
export function parseWidgetPropsJson<T extends object>(raw: string | undefined): T {
|
|
if (!raw) return {} as T;
|
|
try {
|
|
const parsed = JSON.parse(raw);
|
|
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
return parsed as T;
|
|
}
|
|
} catch {
|
|
// Policy already validates widget props; fall back to empty props defensively.
|
|
}
|
|
return {} as T;
|
|
}
|
|
|
|
export function PluginSlottedWidget({
|
|
kind,
|
|
rawProps,
|
|
onWidgetEvent,
|
|
}: {
|
|
kind: SlottedWidgetKind;
|
|
rawProps: string | undefined;
|
|
onWidgetEvent: PluginWidgetEventCallback;
|
|
}) {
|
|
const parsedProps = useMemo(() => parseWidgetPropsJson<Record<string, unknown>>(rawProps), [rawProps]);
|
|
|
|
return (
|
|
<LazyLoadBoundary
|
|
name={`Plugin ${kind}`}
|
|
fallback={<div className="flex h-full w-full items-center justify-center p-4 text-xs text-destructive">Unable to render plugin widget.</div>}
|
|
>
|
|
{kind === 'code-editor' && (
|
|
<PluginCodeEditor {...(parsedProps as PluginCodeEditorWidgetProps)} onWidgetEvent={onWidgetEvent} />
|
|
)}
|
|
{kind === 'data-grid' && (
|
|
<PluginDataGrid {...(parsedProps as PluginDataGridWidgetProps)} onWidgetEvent={onWidgetEvent} />
|
|
)}
|
|
{kind === 'er-canvas' && (
|
|
<PluginErCanvas {...(parsedProps as PluginErCanvasWidgetProps)} onWidgetEvent={onWidgetEvent} />
|
|
)}
|
|
</LazyLoadBoundary>
|
|
);
|
|
}
|