import Ratio from "./math/Ratio"; import { Cell, Doc, Grid } from "./types"; function defaultDoc(): Doc { const defaultCells: Cell[] = Array.from({ length: 16 }, () => ({ widthRatio: new Ratio(1, 16), })); return { grids: [ { id: window.crypto.randomUUID(), baseCellSize: 48, baseCellWidthRatio: new Ratio(1, 16), parts: [ { rows: Array.from({ length: 4 }, () => ({ cells: [...defaultCells], })), }, ], }, ], }; } export default class Notive { doc: Doc = defaultDoc(); gridsById = Object.fromEntries(this.doc.grids.map((grid) => [grid.id, grid])); getGrid(id: string): Grid | undefined { return this.gridsById[id]; } } window.notive = new Notive();