When compiling top level stuff put it in a store record, don't const them. More cleaning
This commit is contained in:
parent
a1caaf54e7
commit
13d582419e
4 changed files with 14 additions and 42 deletions
|
|
@ -5,7 +5,6 @@ import { prettyPrint } from './ast'
|
|||
import type { AST, Definition } from './ast'
|
||||
import { measure } from './ui';
|
||||
|
||||
const STORAGE_KEY = 'cg-definitions';
|
||||
const CHANGELOG_KEY = 'cg-changelog';
|
||||
|
||||
export const store: Record<string, any> = {};
|
||||
|
|
@ -153,7 +152,7 @@ export const _rt = {
|
|||
}
|
||||
|
||||
// Save standalone defs
|
||||
for (const def of definitions) {
|
||||
for (const def of definitions.values()) {
|
||||
const content = prettyPrint(def) + '\n';
|
||||
fetch('/api/save', {
|
||||
method: 'POST',
|
||||
|
|
@ -264,6 +263,9 @@ export const _rt = {
|
|||
|
||||
if (defs.length > 0) {
|
||||
const def = defs[0];
|
||||
const existing = definitions.get(def.name);
|
||||
if (existing?.module) def.module = existing.module;
|
||||
if (existing?.annotation && !def.annotation) def.annotation = existing.annotation;
|
||||
recompile(def.name, def.body!);
|
||||
definitions.set(def.name, def);
|
||||
const source = prettyPrint(def);
|
||||
|
|
@ -383,6 +385,7 @@ export function syncToAst(name: string) {
|
|||
name,
|
||||
body: valueToAst(store[name]),
|
||||
annotation: existing?.annotation,
|
||||
module: existing?.module,
|
||||
};
|
||||
definitions.set(name, newDef); // valueToAst(store[name]));
|
||||
// const source = prettyPrint({ kind: 'definition', name, body: definitions.get(name)! });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue