MCPcopy Create free account
hub / github.com/esengine/esengine / CompileDialog

Function CompileDialog

packages/editor-app/src/components/CompileDialog.tsx:15–143  ·  view source on GitHub ↗
({
    isOpen,
    onClose,
    compiler,
    context,
    initialOptions
}: CompileDialogProps<TOptions>)

Source from the content-addressed store, hash-verified

13}
14
15export function CompileDialog<TOptions = unknown>({
16 isOpen,
17 onClose,
18 compiler,
19 context,
20 initialOptions
21}: CompileDialogProps<TOptions>) {
22 const { t } = useLocale();
23 const [options, setOptions] = useState<TOptions>(initialOptions as TOptions);
24 const [isCompiling, setIsCompiling] = useState(false);
25 const [result, setResult] = useState<CompileResult | null>(null);
26 const [validationError, setValidationError] = useState<string | null>(null);
27
28 useEffect(() => {
29 if (isOpen && initialOptions) {
30 setOptions(initialOptions);
31 setResult(null);
32 setValidationError(null);
33 }
34 }, [isOpen, initialOptions]);
35
36 useEffect(() => {
37 if (compiler.validateOptions && options) {
38 const error = compiler.validateOptions(options);
39 setValidationError(error);
40 }
41 }, [options, compiler]);
42
43 if (!isOpen) return null;
44
45 const handleCompile = async () => {
46 if (validationError) {
47 return;
48 }
49
50 setIsCompiling(true);
51 setResult(null);
52
53 try {
54 const compileResult = await compiler.compile(options, context);
55 setResult(compileResult);
56 } catch (error) {
57 setResult({
58 success: false,
59 message: `${t('compileDialog.compileFailed')}: ${error}`,
60 errors: [String(error)]
61 });
62 } finally {
63 setIsCompiling(false);
64 }
65 };
66
67 return (
68 <div className="compile-dialog-overlay">
69 <div className="compile-dialog">
70 <div className="compile-dialog-header">
71 <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
72 <Cpu size={20} />

Callers

nothing calls this directly

Calls 4

useLocaleFunction · 0.90
validateOptionsMethod · 0.65
createConfigUIMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected