Saving glyphs

This commit is contained in:
Dustin Swan 2026-02-22 13:49:26 -07:00
parent 2e05df8035
commit f426573f96
No known key found for this signature in database
GPG key ID: 30D46587E2100467
3 changed files with 78 additions and 9 deletions

View file

@ -62,6 +62,7 @@ export const _rt = {
: { _tag: 'None' },
len: (xs: any[] | string) => xs.length,
// str: (x: any) => String(x),
int: (x: any) => typeof x === 'number' ? Math.floor(x) : parseInt(x, 10) || 0,
show: (value: any): string => {
if (value === null || value === undefined) return "None";
if (typeof value === 'string') return value;
@ -126,8 +127,12 @@ export const _rt = {
store[name] = pathOrValue;
} else {
const path = pathOrValue as string[];
if (store[name] === undefined) store[name] = {};
let obj = store[name];
for (let i = 0; i < path.length - 1; i++) {
if (obj[path[i]] === undefined || obj[path[i]] === null) {
obj[path[i]] = {};
}
obj = obj[path[i]];
}
obj[path[path.length - 1]] = maybeValue;
@ -327,7 +332,8 @@ function valueToAst(value: any): AST {
}
export function syncToAst(name: string) {
if (definitions.has(name)) {
// if (definitions.has(name)) {
if (name in store) {
definitions.set(name, valueToAst(store[name]));
const source = prettyPrint({ kind: 'definition', name, body: definitions.get(name)! });
appendChangeLog(name, source);