From 36fc63780a539dce029250a5e73bb18928653336 Mon Sep 17 00:00:00 2001 From: Adrien Jaguenet Date: Fri, 19 Jun 2026 01:18:36 +0200 Subject: [PATCH] early version: modular block files, full template set, tab UI, OpenGL defaults --- ARCHITECTURE.md | 318 +++++++++ README.md | 517 +++++++++++++++ app.js | 451 +++++++++++++ blocks-algo.js | 375 +++++++++++ blocks-data.js | 490 ++++++++++++++ blocks-proc.js | 237 +++++++ dom.js | 22 + draw.js | 207 ++++++ error.js | 31 + helpers.js | 291 +++++++++ icons/ATTRIBUTION.md | 30 + icons/arrow-right-circle.svg | 16 + icons/book-open.svg | 16 + icons/database.svg | 17 + icons/diamond.svg | 15 + icons/file-plus.svg | 18 + icons/file-text.svg | 19 + icons/folder-plus.svg | 17 + icons/function-square.svg | 15 + icons/git-branch.svg | 18 + icons/grid.svg | 19 + icons/ruler.svg | 19 + icons/sliders.svg | 23 + icons/terminal.svg | 16 + icons/variable.svg | 18 + index.html | 399 +++++++++++- .../fonts/woff-v2/MathJax_AMS-Regular.woff | Bin 0 -> 40808 bytes .../woff-v2/MathJax_Calligraphic-Bold.woff | Bin 0 -> 9908 bytes .../woff-v2/MathJax_Calligraphic-Regular.woff | Bin 0 -> 9600 bytes .../fonts/woff-v2/MathJax_Fraktur-Bold.woff | Bin 0 -> 22340 bytes .../woff-v2/MathJax_Fraktur-Regular.woff | Bin 0 -> 21480 bytes .../fonts/woff-v2/MathJax_Main-Bold.woff | Bin 0 -> 34464 bytes .../fonts/woff-v2/MathJax_Main-Italic.woff | Bin 0 -> 20832 bytes .../fonts/woff-v2/MathJax_Main-Regular.woff | Bin 0 -> 34160 bytes .../woff-v2/MathJax_Math-BoldItalic.woff | Bin 0 -> 19776 bytes .../fonts/woff-v2/MathJax_Math-Italic.woff | Bin 0 -> 19360 bytes .../fonts/woff-v2/MathJax_Math-Regular.woff | Bin 0 -> 19288 bytes .../fonts/woff-v2/MathJax_SansSerif-Bold.woff | Bin 0 -> 15944 bytes .../woff-v2/MathJax_SansSerif-Italic.woff | Bin 0 -> 14628 bytes .../woff-v2/MathJax_SansSerif-Regular.woff | Bin 0 -> 12660 bytes .../fonts/woff-v2/MathJax_Script-Regular.woff | Bin 0 -> 11852 bytes .../fonts/woff-v2/MathJax_Size1-Regular.woff | Bin 0 -> 5792 bytes .../fonts/woff-v2/MathJax_Size2-Regular.woff | Bin 0 -> 5464 bytes .../fonts/woff-v2/MathJax_Size3-Regular.woff | Bin 0 -> 3244 bytes .../fonts/woff-v2/MathJax_Size4-Regular.woff | Bin 0 -> 5148 bytes .../woff-v2/MathJax_Typewriter-Regular.woff | Bin 0 -> 17604 bytes .../fonts/woff-v2/MathJax_Vector-Bold.woff | Bin 0 -> 1116 bytes .../fonts/woff-v2/MathJax_Vector-Regular.woff | Bin 0 -> 1136 bytes .../chtml/fonts/woff-v2/MathJax_Zero.woff | Bin 0 -> 1368 bytes lib/mathjax/tex-mml-chtml.js | 1 + main.js | 203 ------ persist.js | 243 +++++++ style.css | 610 +++++++++++++++--- wcblock.js | 199 ++++++ wcprogram.js | 242 +++++++ 55 files changed, 4790 insertions(+), 322 deletions(-) create mode 100644 ARCHITECTURE.md create mode 100644 README.md create mode 100644 app.js create mode 100644 blocks-algo.js create mode 100644 blocks-data.js create mode 100644 blocks-proc.js create mode 100644 dom.js create mode 100644 draw.js create mode 100644 error.js create mode 100644 helpers.js create mode 100644 icons/ATTRIBUTION.md create mode 100644 icons/arrow-right-circle.svg create mode 100644 icons/book-open.svg create mode 100644 icons/database.svg create mode 100644 icons/diamond.svg create mode 100644 icons/file-plus.svg create mode 100644 icons/file-text.svg create mode 100644 icons/folder-plus.svg create mode 100644 icons/function-square.svg create mode 100644 icons/git-branch.svg create mode 100644 icons/grid.svg create mode 100644 icons/ruler.svg create mode 100644 icons/sliders.svg create mode 100644 icons/terminal.svg create mode 100644 icons/variable.svg create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff create mode 100644 lib/mathjax/output/chtml/fonts/woff-v2/MathJax_Zero.woff create mode 100644 lib/mathjax/tex-mml-chtml.js delete mode 100644 main.js create mode 100644 persist.js create mode 100644 wcblock.js create mode 100644 wcprogram.js diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md new file mode 100644 index 0000000..9839f83 --- /dev/null +++ b/ARCHITECTURE.md @@ -0,0 +1,318 @@ +# Architecture + +## Stack + +Pure vanilla HTML/CSS/JS — no frameworks, no build tools. MathJax v3 for LaTeX rendering is the only runtime dependency (loaded before app scripts). Eight JS modules loaded in dependency order at the end of ``. + +## Load Order + +``` +index.html + └─ style.css + └─ lib/mathjax/tex-mml-chtml.js → MathJax v3 (LaTeX→HTML rendering) + └─ dom.js → $, $id, svgNamespace, STORAGE_KEY + └─ helpers.js → splitValueAndUnit, rebuildSelect, refresh* functions + └─ error.js → showError, closeError + └─ draw.js → routeBetween, drawpath, shadow link system + └─ wcblock.js → WCBlock base (drag/drop, link system, code traversal) + └─ blocks-algo.js → Algorithm tab blocks (WCStart, WCEnd, WCOutput, WCDecision, + │ WCAssign, WCExpression, WCVarRef) + └─ blocks-data.js → Data & Measurement tab blocks (WCQuantity, WCUnit, WCBoolean, + │ WCScalar, WCString, WCArray) + └─ blocks-proc.js → Procedure blocks (WCProcedure, WCProcCall) + └─ wcprogram.js → WCProgram + block registry + registration calls + └─ persist.js → saveWorkspace, loadWorkspace, newWorkspace + └─ app.js → entry point, setupUI, main() +``` + +## File Roles + +### `dom.js` — Global constants & DOM shortcuts + +Provides app-wide constants that every module depends on: + +- `$` — `document.querySelector.bind(document)` — concise single-element selector +- `$id` — `document.getElementById.bind(document)` — concise ID lookup +- `svgNamespace` — `"http://www.w3.org/2000/svg"` — for SVG element creation +- `STORAGE_KEY` — `"workspace"` — localStorage key for persistence + +### `helpers.js` — Utility functions & dropdown refresh + +Pure helper functions (no module dependencies beyond DOM): + +- `splitValueAndUnit(str, defaultNum)` — parses `"5 km"` → `{numVal: 5, unitSuffix: "km"}` +- `rebuildSelect(sel, placeholder, values, current)` — replaces `