import { DevStore } from '@shared/storage/DevStore'; import useKC_DABR_WASM from 'kc-dabr-wasm'; import React, { useEffect } from 'react'; import { createRoot } from 'react-dom/client'; const manifest = chrome.runtime.getManifest(); /** * Handles editing the storage for a specific area. * * @param areaName - The name of the storage area. * @returns A function that accepts changes and sets them in the storage. */ const handleEditStorage = (areaName: 'local' | 'sync' | 'session') => (changes: Record) => { chrome.storage[areaName].set(changes); }; interface JSONEditorProps { data: unknown; onChange: ReturnType; } function JSONEditor(props: JSONEditorProps) { const { data, onChange } = props; const [isEditing, setIsEditing] = React.useState(false); const [json, setJson] = React.useState(JSON.stringify(data, null, 2)); useEffect(() => { setJson(JSON.stringify(data, null, 2)); }, [data]); const handleChange = (e: React.ChangeEvent) => { setJson(e.target.value); }; const handleSave = () => { try { const updates = JSON.parse(json); onChange(updates); setIsEditing(false); } catch (e) { console.error(e); // eslint-disable-next-line no-alert alert('Invalid JSON'); } }; return (
{isEditing ? (