From c7440247b01ad733a4bf51fcd3675bff088a3428 Mon Sep 17 00:00:00 2001 From: mgreminger Date: Thu, 19 Dec 2024 14:24:19 -0600 Subject: [PATCH] refactor: port MathCell.svelte to runes mode Brakes other things, all cell types will need to be ported before all tests will pass. Having non-runes and runes components access the same stores causes reactivity issues for the non-runes components. --- src/App.svelte | 4 +- src/Cell.svelte | 10 +- src/CellList.svelte | 2 +- src/DataTableCell.svelte | 2 +- src/GenerateCodeDialog.svelte | 7 +- src/MathCell.svelte | 154 +++++++++--------- src/MathField.svelte | 2 +- src/cells/Cells.ts | 2 +- src/cells/DataTableCell.ts | 2 +- src/cells/FluidCell.ts | 2 +- src/cells/{MathCell.ts => MathCell.svelte.ts} | 10 +- .../{MathField.ts => MathField.svelte.ts} | 8 +- src/cells/PiecewiseCell.ts | 2 +- src/cells/PlotCell.ts | 4 +- src/cells/SystemCell.ts | 2 +- src/cells/TableCell.ts | 2 +- src/keyboard/Keyboard.ts | 2 +- src/parser/LatexToSympy.ts | 2 +- src/stores.ts | 4 +- src/types.ts | 4 +- tsconfig.json | 4 +- 21 files changed, 121 insertions(+), 110 deletions(-) rename src/cells/{MathCell.ts => MathCell.svelte.ts} (82%) rename src/cells/{MathField.ts => MathField.svelte.ts} (90%) diff --git a/src/App.svelte b/src/App.svelte index 811bf3f3..f7d8d112 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -2,7 +2,7 @@ import { onDestroy, onMount, tick, type ComponentEvents } from "svelte"; import { type Cell, cellFactory } from "./cells/Cells"; import { BaseCell } from "./cells/BaseCell"; - import MathCell from "./cells/MathCell"; + import MathCell from "./cells/MathCell.svelte"; import TableCell from "./cells/TableCell"; import DataTableCell, { type InterpolationFunction } from "./cells/DataTableCell"; import PlotCell from "./cells/PlotCell"; @@ -24,7 +24,7 @@ import { getHash, API_GET_PATH, API_SAVE_PATH } from "./database/utility"; import type { SheetPostBody, History } from "./database/types"; import CellList from "./CellList.svelte"; - import type { MathField } from "./cells/MathField"; + import type { MathField } from "./cells/MathField.svelte"; import DocumentTitle from "./DocumentTitle.svelte"; import UnitsDocumentation from "./UnitsDocumentation.svelte"; import KeyboardShortcuts from "./KeyboardShortcuts.svelte"; diff --git a/src/Cell.svelte b/src/Cell.svelte index ef33fb1a..2781d82f 100644 --- a/src/Cell.svelte +++ b/src/Cell.svelte @@ -15,7 +15,7 @@ import DeletedCellElement from "./DeletedCell.svelte"; import InsertCellElement from "./InsertCell.svelte"; - import MathCell from "./cells/MathCell"; + import MathCell from "./cells/MathCell.svelte"; import PlotCell from "./cells/PlotCell"; import TableCell from "./cells/TableCell"; import DataTableCell from "./cells/DataTableCell"; @@ -255,10 +255,10 @@ > {#if cell instanceof MathCell} import type { ModalInfo } from "./types"; - import MathCell from "./cells/MathCell"; + import MathCell from "./cells/MathCell.svelte"; import type { MathCellConfig } from "./sheet/Sheet"; import { cells, results, system_results, activeCell, mathCellChanged } from "./stores"; import Cell from "./Cell.svelte"; diff --git a/src/DataTableCell.svelte b/src/DataTableCell.svelte index db75962e..bb1541d2 100644 --- a/src/DataTableCell.svelte +++ b/src/DataTableCell.svelte @@ -21,7 +21,7 @@ import { convertArrayUnits, unitsEquivalent, unitsValid } from "./utility.js"; import type DataTableCell from "./cells/DataTableCell"; - import type { MathField as MathFieldClass } from "./cells/MathField"; + import type { MathField as MathFieldClass } from "./cells/MathField.svelte"; import MathField from "./MathField.svelte"; import DataTableInput from "./DataTableInput.svelte"; diff --git a/src/GenerateCodeDialog.svelte b/src/GenerateCodeDialog.svelte index 0ad37db1..db2cf6db 100644 --- a/src/GenerateCodeDialog.svelte +++ b/src/GenerateCodeDialog.svelte @@ -4,8 +4,9 @@ import { results, cells, mathCellChanged } from './stores'; import type { CodeFunctionQueryStatement } from './parser/types'; import type { Cell } from './cells/Cells'; - import MathCell from './cells/MathCell'; - import { type FiniteImagResult, type Result, type MatrixResult, isMatrixResult } from './resultTypes'; + import MathCell from './cells/MathCell.svelte'; + import { type FiniteImagResult, type Result, type MatrixResult, isMatrixResult, + isDataTableResult } from './resultTypes'; import { PYTHON_RESERVED } from './utility'; import { InlineLoading, CodeSnippet } from 'carbon-components-svelte'; import Information from "carbon-icons-svelte/lib/Information.svelte"; @@ -225,7 +226,7 @@ ${parameterNames.map(parameterConversionMap).filter(value => value !== "").map(( $: { const tempResult = $results[index]; - if (tempResult && !(tempResult instanceof Array)) { + if (tempResult && !(tempResult instanceof Array) && !isDataTableResult(tempResult)) { result = tempResult; } else { result = null; diff --git a/src/MathCell.svelte b/src/MathCell.svelte index f6c2721a..90dea8d3 100644 --- a/src/MathCell.svelte +++ b/src/MathCell.svelte @@ -1,15 +1,15 @@