boom, back up and running again

This commit is contained in:
Chris Kruining 2024-11-05 07:34:55 +01:00
parent b3fbc46cfd
commit b8e3a76768
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2

View file

@ -61,12 +61,12 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
const tabs = createMemo(() => filesContext.files().map(({ key, handle }) => { const tabs = createMemo(() => filesContext.files().map(({ key, handle }) => {
const [api, setApi] = createSignal<GridApi>(); const [api, setApi] = createSignal<GridApi>();
const [entries, setEntries] = createSignal<Entries>(new Map()); const [entries, setEntries] = createSignal<Entries>(new Map());
const [files, setFiles] = createSignal<Map<string, { key: string, handle: FileSystemFileHandle }>>(new Map()); const [files, setFiles] = createSignal<Map<string, { id: string, handle: FileSystemFileHandle }>>(new Map());
(async () => { (async () => {
const files = await Array.fromAsync( const files = await Array.fromAsync(
filter(handle.values(), entry => entry.kind === 'file'), filter(handle.values(), entry => entry.kind === 'file'),
async file => [file.name.split('.').at(0)!, { handle: file, key: await file.getUniqueId() }] as const async file => [file.name.split('.').at(0)!, { handle: file, id: await file.getUniqueId() }] as const
); );
setFiles(new Map(files)); setFiles(new Map(files));
@ -80,6 +80,7 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
const tab = createMemo(() => { const tab = createMemo(() => {
const name = active(); const name = active();
return tabs().find(t => t.handle.name === name); return tabs().find(t => t.handle.name === name);
}); });
const api = createMemo(() => tab()?.api()); const api = createMemo(() => tab()?.api());
@ -145,7 +146,10 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
handle, handle,
existing.entries().reduce((aggregate, [key, value]) => { existing.entries().reduce((aggregate, [key, value]) => {
let obj = aggregate; let obj = aggregate;
const [k, lastPart] = splitAt(key, key.lastIndexOf('.')); const i = key.lastIndexOf('.');
if (i !== -1) {
const [k, lastPart] = splitAt(key, i);
for (const part of k.split('.')) { for (const part of k.split('.')) {
if (!Object.hasOwn(obj, part)) { if (!Object.hasOwn(obj, part)) {
@ -156,6 +160,10 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
} }
obj[lastPart] = value; obj[lastPart] = value;
}
else {
obj[key] = value;
}
return aggregate; return aggregate;
}, {} as Record<string, any>) }, {} as Record<string, any>)
@ -172,14 +180,6 @@ const Editor: Component<{ root: FileSystemDirectoryHandle }> = (props) => {
})(); })();
}); });
createEffect(() => {
console.log(mutatedFiles());
});
createEffect(() => {
console.log(mutatedData());
});
const [prompt, setPrompt] = createSignal<PromptApi>(); const [prompt, setPrompt] = createSignal<PromptApi>();
const commands = { const commands = {