|
|
|
|
@ -101,6 +101,22 @@ export const _rt = {
|
|
|
|
|
const printed = prettyPrint(ast);
|
|
|
|
|
return printed;
|
|
|
|
|
},
|
|
|
|
|
saveImage: () => {
|
|
|
|
|
const saved: Record<string, string> = {};
|
|
|
|
|
for (const [name, ast] of definitions) {
|
|
|
|
|
const source = prettyPrint({ kind: 'definition', name, body: ast });
|
|
|
|
|
saved[name] = source;
|
|
|
|
|
}
|
|
|
|
|
const content = Object.values(saved).join('\n\n');
|
|
|
|
|
const blob = new Blob([content], { type: 'text/plain' });
|
|
|
|
|
const url = URL.createObjectURL(blob);
|
|
|
|
|
const a = document.createElement('a');
|
|
|
|
|
a.href = url;
|
|
|
|
|
a.download = `cg-image-${new Date().toISOString().slice(0, 19).replace(/[T:]/g, '-')}.cg`;
|
|
|
|
|
a.click();
|
|
|
|
|
URL.revokeObjectURL(url);
|
|
|
|
|
return { _tag: 'Ok' };
|
|
|
|
|
},
|
|
|
|
|
rebind: (name: string, pathOrValue: any, maybeValue?: any) => {
|
|
|
|
|
if (maybeValue === undefined) {
|
|
|
|
|
store[name] = pathOrValue;
|
|
|
|
|
|