Adding clear-storage helper button

This commit is contained in:
Dustin Swan 2026-02-06 23:39:36 -07:00
parent 8c3237e0db
commit eef4daf8ec
No known key found for this signature in database
GPG key ID: 30D46587E2100467
3 changed files with 13 additions and 2 deletions

View file

@ -6,7 +6,7 @@ import { runApp } from './runtime';
import { builtins } from './builtins';
import { CGError } from './error';
import { createStore, startTracking, stopTracking, buildDependents } from './store';
import { loadStore } from './persistence';
import { loadStore, clearStore } from './persistence';
import stdlibCode from './stdlib.cg?raw';
import designTokensCode from './design-tokens.cg?raw';
@ -19,6 +19,11 @@ import textInputCode from './textinput-test.cg?raw';
const canvas = document.createElement('canvas') as HTMLCanvasElement;
document.body.appendChild(canvas);
const clearButton = document.getElementById('clear-storage');
if (clearButton) {
clearButton.onclick = () => clearStore();
}
const cgCode = stdlibCode + '\n' +
designTokensCode + '\n' +
uiComponentsCode + '\n' +

View file

@ -25,5 +25,5 @@ export function loadStore(): Record<string, { body: AST, source: string }> | nul
}
export function clearStore() {
localStorage.remove(STORAGE_KEY);
localStorage.removeItem(STORAGE_KEY);
}