From 52d25c1f298d5e0fc10d12df0b327a2e425a7698 Mon Sep 17 00:00:00 2001 From: Alex Michael Berry Date: Sun, 8 Dec 2024 01:44:46 -0500 Subject: [PATCH] starting ligature desktop rewrite --- README.md | 4 +- package-lock.json | 178 ++------------------------------ package.json | 6 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 4 +- src-tauri/src/main.rs | 2 +- src/components/Application.tsx | 30 ++++++ src/components/EditCell.tsx | 76 -------------- src/components/Editor.tsx | 41 -------- src/components/NotebookEdit.tsx | 12 --- src/components/NotebookView.tsx | 11 -- src/components/ViewCell.tsx | 27 ----- src/index.tsx | 4 +- src/main.css | 32 +----- 14 files changed, 56 insertions(+), 373 deletions(-) create mode 100644 src/components/Application.tsx delete mode 100644 src/components/EditCell.tsx delete mode 100644 src/components/Editor.tsx delete mode 100644 src/components/NotebookEdit.tsx delete mode 100644 src/components/NotebookView.tsx delete mode 100644 src/components/ViewCell.tsx diff --git a/README.md b/README.md index 1769bda..ca30351 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# LigatureNotebook +# Ligature Desktop -See https://tauri.app/v1/guides/getting-started/prerequisites for setting up a development environment. +See https://v2.tauri.app/start/prerequisites/ for setting up a development environment. Once this has been setup run the following. ``` diff --git a/package-lock.json b/package-lock.json index 2398252..b13e4f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,23 +1,23 @@ { - "name": "ligature-notebook", + "name": "ligature-desktop", "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "ligature-notebook", + "name": "ligature-desktop", "version": "0.1.0", "license": "MPL-2.0", "dependencies": { "@ligature/ligature": "^0.8.0", "@ligature/ligature-components": "^0.8.0", - "@shoelace-style/shoelace": "^2.17.1", "@tauri-apps/api": "^2", "@tauri-apps/plugin-dialog": "^2.0.0", "@tauri-apps/plugin-fs": "^2.0.0", "@tauri-apps/plugin-shell": "^2", "marked": "^14.1.3", - "solid-js": "^1.9.2" + "solid-js": "^1.9.2", + "split.js": "^1.6.5" }, "devDependencies": { "@tauri-apps/cli": "^2", @@ -428,15 +428,6 @@ "w3c-keyname": "^2.2.4" } }, - "node_modules/@ctrl/tinycolor": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-4.1.0.tgz", - "integrity": "sha512-WyOx8cJQ+FQus4Mm4uPIZA64gbk3Wxh0so5Lcii0aJifqwoVOlfFtorjLE0Hen4OYyHZMXDWqMmaQemBhgxFRQ==", - "license": "MIT", - "engines": { - "node": ">=14" - } - }, "node_modules/@esbuild/aix-ppc64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", @@ -828,31 +819,6 @@ "node": ">=12" } }, - "node_modules/@floating-ui/core": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.8.tgz", - "integrity": "sha512-7XJ9cPU+yI2QeLS+FCSlqNFZJq8arvswefkZrYI1yQBbftw6FyrZOxYSh+9S7z7TpeWlRt9zJ5IhM1WIL334jA==", - "license": "MIT", - "dependencies": { - "@floating-ui/utils": "^0.2.8" - } - }, - "node_modules/@floating-ui/dom": { - "version": "1.6.11", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.11.tgz", - "integrity": "sha512-qkMCxSR24v2vGkhYDo/UzxfJN3D4syqSjyuTFz6C7XcpU1pASPRieNI0Kj5VP3/503mOfYiGY891ugBX1GlABQ==", - "license": "MIT", - "dependencies": { - "@floating-ui/core": "^1.6.0", - "@floating-ui/utils": "^0.2.8" - } - }, - "node_modules/@floating-ui/utils": { - "version": "0.2.8", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.8.tgz", - "integrity": "sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig==", - "license": "MIT" - }, "node_modules/@jest/schemas": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", @@ -966,30 +932,6 @@ "tabulator-tables": "^6.3.0" } }, - "node_modules/@lit-labs/ssr-dom-shim": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.2.1.tgz", - "integrity": "sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ==", - "license": "BSD-3-Clause" - }, - "node_modules/@lit/react": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@lit/react/-/react-1.0.6.tgz", - "integrity": "sha512-QIss8MPh6qUoFJmuaF4dSHts3qCsA36S3HcOLiNPShxhgYPr4XJRnCBKPipk85sR9xr6TQrOcDMfexwbNdJHYA==", - "license": "BSD-3-Clause", - "peerDependencies": { - "@types/react": "17 || 18" - } - }, - "node_modules/@lit/reactive-element": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@lit/reactive-element/-/reactive-element-2.0.4.tgz", - "integrity": "sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ==", - "license": "BSD-3-Clause", - "dependencies": { - "@lit-labs/ssr-dom-shim": "^1.2.0" - } - }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.24.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz", @@ -1214,45 +1156,6 @@ "win32" ] }, - "node_modules/@shoelace-style/animations": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@shoelace-style/animations/-/animations-1.2.0.tgz", - "integrity": "sha512-avvo1xxkLbv2dgtabdewBbqcJfV0e0zCwFqkPMnHFGbJbBHorRFfMAHh1NG9ymmXn0jW95ibUVH03E1NYXD6Gw==", - "license": "MIT", - "funding": { - "type": "individual", - "url": "https://github.com/sponsors/claviska" - } - }, - "node_modules/@shoelace-style/localize": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/@shoelace-style/localize/-/localize-3.2.1.tgz", - "integrity": "sha512-r4C9C/5kSfMBIr0D9imvpRdCNXtUNgyYThc4YlS6K5Hchv1UyxNQ9mxwj+BTRH2i1Neits260sR3OjKMnplsFA==", - "license": "MIT" - }, - "node_modules/@shoelace-style/shoelace": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@shoelace-style/shoelace/-/shoelace-2.17.1.tgz", - "integrity": "sha512-fB9+bPHLg5zVwPbBKEqY3ghyttkJq9RuUzFMTZKweKrNKKDMUACtI8DlMYUqNwpdZMJhf7a0xeak6vFVBSxcbQ==", - "license": "MIT", - "dependencies": { - "@ctrl/tinycolor": "^4.0.2", - "@floating-ui/dom": "^1.5.3", - "@lit/react": "^1.0.0", - "@shoelace-style/animations": "^1.1.0", - "@shoelace-style/localize": "^3.1.2", - "composed-offset-position": "^0.0.4", - "lit": "^3.0.0", - "qr-creator": "^1.0.0" - }, - "engines": { - "node": ">=14.17.0" - }, - "funding": { - "type": "individual", - "url": "https://github.com/sponsors/claviska" - } - }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -1548,30 +1451,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/prop-types": { - "version": "15.7.13", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.13.tgz", - "integrity": "sha512-hCZTSvwbzWGvhqxp/RqVqwU999pBf2vp7hzIjiYOsl8wqOmUxkQ6ddw1cV3l8811+kdUFus/q4d1Y3E3SyEifA==", - "license": "MIT", - "peer": true - }, - "node_modules/@types/react": { - "version": "18.3.11", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.11.tgz", - "integrity": "sha512-r6QZ069rFTjrEYgFdOck1gK7FLVsgJE7tTz0pQBczlBNUhBNk0MQH4UbnFSwjpQLMkLzgqvBBa+qGpLje16eTQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "@types/prop-types": "*", - "csstype": "^3.0.2" - } - }, - "node_modules/@types/trusted-types": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", - "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", - "license": "MIT" - }, "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -1731,12 +1610,6 @@ "dev": true, "license": "MIT" }, - "node_modules/composed-offset-position": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/composed-offset-position/-/composed-offset-position-0.0.4.tgz", - "integrity": "sha512-vMlvu1RuNegVE0YsCDSV/X4X10j56mq7PCIyOKK74FxkXzGLwhOUmdkJLSdOBOMwWycobGUMgft2lp+YgTe8hw==", - "license": "MIT" - }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -2078,37 +1951,6 @@ "node": ">=6" } }, - "node_modules/lit": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/lit/-/lit-3.2.1.tgz", - "integrity": "sha512-1BBa1E/z0O9ye5fZprPtdqnc0BFzxIxTTOO/tQFmyC/hj1O3jL4TfmLBw0WEwjAokdLwpclkvGgDJwTIh0/22w==", - "license": "BSD-3-Clause", - "dependencies": { - "@lit/reactive-element": "^2.0.4", - "lit-element": "^4.1.0", - "lit-html": "^3.2.0" - } - }, - "node_modules/lit-element": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lit-element/-/lit-element-4.1.1.tgz", - "integrity": "sha512-HO9Tkkh34QkTeUmEdNYhMT8hzLid7YlMlATSi1q4q17HE5d9mrrEHJ/o8O2D0cMi182zK1F3v7x0PWFjrhXFew==", - "license": "BSD-3-Clause", - "dependencies": { - "@lit-labs/ssr-dom-shim": "^1.2.0", - "@lit/reactive-element": "^2.0.4", - "lit-html": "^3.2.0" - } - }, - "node_modules/lit-html": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/lit-html/-/lit-html-3.2.1.tgz", - "integrity": "sha512-qI/3lziaPMSKsrwlxH/xMgikhQ0EGOX2ICU73Bi/YHFvz2j/yMCIrw4+puF2IpQ4+upd3EWbvnHM9+PnJn48YA==", - "license": "BSD-3-Clause", - "dependencies": { - "@types/trusted-types": "^2.0.2" - } - }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -2257,12 +2099,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/qr-creator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/qr-creator/-/qr-creator-1.0.0.tgz", - "integrity": "sha512-C0cqfbS1P5hfqN4NhsYsUXePlk9BO+a45bAQ3xLYjBL3bOIFzoVEjs79Fado9u9BPBD3buHi3+vY+C8tHh4qMQ==", - "license": "MIT" - }, "node_modules/react-is": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", @@ -2373,6 +2209,12 @@ "node": ">=0.10.0" } }, + "node_modules/split.js": { + "version": "1.6.5", + "resolved": "https://registry.npmjs.org/split.js/-/split.js-1.6.5.tgz", + "integrity": "sha512-mPTnGCiS/RiuTNsVhCm9De9cCAUsrNFFviRbADdKiiV+Kk8HKp/0fWu7Kr8pi3/yBmsqLFHuXGT9UUZ+CNLwFw==", + "license": "MIT" + }, "node_modules/style-mod": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.2.tgz", diff --git a/package.json b/package.json index a84c92c..084af52 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "ligature-notebook", + "name": "ligature-desktop", "version": "0.1.0", "type": "module", "private": true, @@ -13,13 +13,13 @@ "dependencies": { "@ligature/ligature": "^0.8.0", "@ligature/ligature-components": "^0.8.0", - "@shoelace-style/shoelace": "^2.17.1", "@tauri-apps/api": "^2", "@tauri-apps/plugin-dialog": "^2.0.0", "@tauri-apps/plugin-fs": "^2.0.0", "@tauri-apps/plugin-shell": "^2", "marked": "^14.1.3", - "solid-js": "^1.9.2" + "solid-js": "^1.9.2", + "split.js": "^1.6.5" }, "devDependencies": { "@tauri-apps/cli": "^2", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 72c663a..6cd7c67 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1843,7 +1843,7 @@ dependencies = [ ] [[package]] -name = "ligature-notebook" +name = "ligature-desktop" version = "0.1.0" dependencies = [ "serde", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index cc4f4f1..574c412 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ligature-notebook" +name = "ligature-desktop" version = "0.1.0" description = "A Desktop Application for Working with Ligature" authors = ["Alex Michael Berry"] @@ -11,7 +11,7 @@ edition = "2021" # The `_lib` suffix may seem redundant but it is necessary # to make the lib name unique and wouldn't conflict with the bin name. # This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 -name = "ligature_notebook_lib" +name = "ligature_desktop_lib" crate-type = ["staticlib", "cdylib", "rlib"] [build-dependencies] diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ebb1f00..b3562c5 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -2,5 +2,5 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] fn main() { - ligature_notebook_lib::run() + ligature_desktop_lib::run() } diff --git a/src/components/Application.tsx b/src/components/Application.tsx new file mode 100644 index 0000000..faffcdd --- /dev/null +++ b/src/components/Application.tsx @@ -0,0 +1,30 @@ +import { onMount } from "solid-js" +import Split from "split.js" +import { showEditor } from "@ligature/ligature-components/src/editor/editor" +import { run as runScript } from "@ligature/ligature" +import { EditorView } from "codemirror"; + + +export function Application() { + let editor: EditorView = null; + onMount(() => { + Split(["#top", "#results"], { direction: "vertical"}) + editor = showEditor("#editor") + }) + + function run() { + console.log(runScript(editor.state.doc.toString())) + } + + return
+
+
+ +
+
+
+
+ Results +
+
+} diff --git a/src/components/EditCell.tsx b/src/components/EditCell.tsx deleted file mode 100644 index 1e82e23..0000000 --- a/src/components/EditCell.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import { appendAfter, lookupCell, moveDown, moveUp, removeCell, updateSource, updateType } from "./Store"; -import { ViewCell } from "./ViewCell"; -import { Match, Switch, createSignal } from "solid-js"; - -const editIcon = "../../static/icons/pencil.svg" -const editText = "Edit" - -const saveIcon = "../../static/icons/save.svg" -const saveText = "Save" - -export function EditCell(props: {id: number }) { - - let text - let markdownRadio - let wanderRadio - const [editMode, setEditMode] = createSignal(false) - const editSaveIcon = () => { - if (editMode()) { - return saveIcon - } else { - return editIcon - } - } - const editSaveAlt = () => { - if (editMode()) { - return saveText - } else { - return editText - } - } - - function callEdit() { - const isEditMode = setEditMode(!editMode()) - - if (!isEditMode) { - updateSource(props.id, text.value) - if (markdownRadio.checked) { - updateType(props.id, "markdown") - } else { - updateType(props.id, "wander") - } - } else { - const cell = lookupCell(props.id) - text.value = cell.source - if (cell.type == "wander") { - wanderRadio.checked = true - } else { - markdownRadio.checked = true - } - } - } - - return
- callEdit()}>{editSaveAlt()} - {moveUp(props.id)}}>Move Cell Up - {moveDown(props.id)}}>Move Cell Down - {appendAfter(props.id)}}>Append New Cell - {removeCell(props.id)}}>Remove Cell - - -
-
- - - - -
- -
-
- - - -
-
-} diff --git a/src/components/Editor.tsx b/src/components/Editor.tsx deleted file mode 100644 index 5aacf09..0000000 --- a/src/components/Editor.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import "@shoelace-style/shoelace/dist/themes/light.css" -import '@shoelace-style/shoelace/dist/components/button/button' -import '@shoelace-style/shoelace/dist/components/button-group/button-group' -import { addCell, newDocument, openDocument, saveDocument } from "./Store"; -import { createSignal, Match, Switch } from "solid-js"; -import { NotebookView } from "./NotebookView"; -import { NotebookEdit } from "./NotebookEdit"; - -let [inEditMode, setInEditMode] = createSignal(true) - -let viewEditLabel = () => { - if (inEditMode()) { - return "View" - } else { - return "Edit" - } -} - -export function Editor() { - return
-
- - Add - {setInEditMode(!inEditMode())}}>{viewEditLabel} - New - Save - Open - -
- - - - - - - - -
-
-
-} diff --git a/src/components/NotebookEdit.tsx b/src/components/NotebookEdit.tsx deleted file mode 100644 index fbfdbc5..0000000 --- a/src/components/NotebookEdit.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { For } from "solid-js"; -import { store } from "./Store"; -import { EditCell } from "./EditCell"; - -export function NotebookEdit() { - return <> - - {(cell, index) => - - } - -} diff --git a/src/components/NotebookView.tsx b/src/components/NotebookView.tsx deleted file mode 100644 index 98a6893..0000000 --- a/src/components/NotebookView.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { For } from "solid-js"; -import { store } from "./Store"; -import { ViewCell } from "./ViewCell"; - -export function NotebookView() { - return - {(cell, index) => { - return - }} - -} diff --git a/src/components/ViewCell.tsx b/src/components/ViewCell.tsx deleted file mode 100644 index 39a923d..0000000 --- a/src/components/ViewCell.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { marked } from "marked"; -import { Match, Switch } from "solid-js"; -import { lookupCell } from "./Store"; -import { run } from "@ligature/ligature"; -import { printNetwork } from "@ligature/ligature-components/src/text/text" - -export function ViewCell(props: {id: number}) { - const id = props.id - const cell = lookupCell(id) - return
- - -
Empty Cell
-
- - - -
- - -
{printNetwork(run(cell.source))}
-
- - - -
-} diff --git a/src/index.tsx b/src/index.tsx index 14a9063..eca58c5 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,5 +1,5 @@ import './main.css' import { render } from 'solid-js/web'; -import { Editor } from './components/Editor'; +import { Application } from './components/Application'; -render(Editor, document.querySelector("#root")); +render(Application, document.querySelector("#root")); diff --git a/src/main.css b/src/main.css index ba21a61..fdd0485 100644 --- a/src/main.css +++ b/src/main.css @@ -2,15 +2,11 @@ html, body { margin: 0; height: 100% } - -#content, #main { + +#content, #main, #root { height: 100%; } -.cell { - padding: 20px; -} - body { font-family: SourceCodePro, monospace; height: 100%; @@ -18,24 +14,6 @@ body { #results { font-family: SourceCodePro, monospace; - margin: 2em; -} - -.status { - padding-left:.8em; - padding-top:.4em; -} - -#split-panel { - height: 100%; - display: grid; - grid-template-columns: 300px 10px 1fr; -} - -.gutter { - grid-row: 1/-1; - cursor: col-resize; - grid-column: 2; } .gutter { @@ -44,7 +22,7 @@ body { background-position: 50%; } -.gutter.gutter-horizontal { - background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg=='); - cursor: col-resize; +.gutter.gutter-vertical { + background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAFAQMAAABo7865AAAABlBMVEVHcEzMzMzyAv2sAAAAAXRSTlMAQObYZgAAABBJREFUeF5jOAMEEAIEEFwAn3kMwcB6I2AAAAAASUVORK5CYII='); + cursor: row-resize; }