{"id":30660055,"url":"https://github.com/tmattio/mosaic","last_synced_at":"2025-08-31T13:43:36.785Z","repository":{"id":301813051,"uuid":"1010377460","full_name":"tmattio/mosaic","owner":"tmattio","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-20T01:24:50.000Z","size":6437,"stargazers_count":43,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-31T05:54:02.915Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmattio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-29T00:01:18.000Z","updated_at":"2025-08-12T10:47:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"da2c928c-6db7-4d65-a0ee-7828e4de41b3","html_url":"https://github.com/tmattio/mosaic","commit_stats":null,"previous_names":["tmattio/mosaic"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tmattio/mosaic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmattio%2Fmosaic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmattio%2Fmosaic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmattio%2Fmosaic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmattio%2Fmosaic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmattio","download_url":"https://codeload.github.com/tmattio/mosaic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmattio%2Fmosaic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272988782,"owners_count":25026959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-31T13:43:36.165Z","updated_at":"2025-08-31T13:43:36.752Z","avatar_url":"https://github.com/tmattio.png","language":"OCaml","readme":"# Mosaic\n\nA modern, declarative terminal UI framework for OCaml with a React-inspired API powered by algebraic effects.\n\n## Overview\n\nMosaic is a high-performance terminal UI framework that brings React's component model and hooks to the terminal applications. It combines three powerful foundations:\n\n1. **[Matrix](./matrix)** - A highly optimized terminal toolkit with efficient grid representation, damage tracking, and double-buffered rendering\n2. **[Toffee](./toffee)** - A pure OCaml port of the Taffy layout engine, providing CSS Grid, Flexbox, and Block layouts\n3. **Algebraic Effects** - OCaml 5's effect system enables a direct-style React-like API with hooks\n\n## Quick Start\n\n### React-Style with Hooks (Algebraic Effects)\n\n```ocaml\nopen Mosaic\n\nlet counter () =\n  (* Direct-style state management via algebraic effects *)\n  let count, set_count = use_state 0 in\n  \n  (* Direct-style effect with cleanup *)\n  use_effect (fun () -\u003e\n    Printf.printf \"Count changed to %d\\n\" count;\n    Some (fun () -\u003e Printf.printf \"Cleanup for %d\\n\" count)\n  ) [Dep.pack count];\n  \n  (* Direct-style keyboard handler *)\n  use_keyboard ~key:(Char '+') (fun () -\u003e \n    set_count (count + 1)\n  );\n  \n  (* Toffee-powered flexbox layout *)\n  vbox ~gap:(`Cells 1) [\n    text ~style:Style.(fg (rgb 100 200 255) ++ bold) \n      (Printf.sprintf \"Count: %d\" count);\n    hbox ~gap:(`Cells 2) [\n      button ~label:\"Increment\" ~on_click:(fun () -\u003e \n        set_count (count + 1)\n      ) ();\n      button ~label:\"Decrement\" ~on_click:(fun () -\u003e \n        set_count (count - 1)\n      ) ();\n    ];\n  ]\n\nlet () = run counter\n```\n\n### The Elm Architecture\n\n```ocaml\nopen Mosaic_tea\n\ntype model = { count: int }\ntype msg = Increment | Decrement | Reset\n\nlet init () = { count = 0 }, Cmd.none\n\nlet update msg model =\n  match msg with\n  | Increment -\u003e { count = model.count + 1 }, Cmd.none\n  | Decrement -\u003e { count = model.count - 1 }, Cmd.none\n  | Reset -\u003e { count = 0 }, Cmd.none\n\nlet view model =\n  Ui.vbox [\n    Ui.text (Printf.sprintf \"Count: %d\" model.count);\n    Ui.hbox [\n      Ui.text \"[+] Increment\";\n      Ui.text \"[-] Decrement\";\n      Ui.text \"[r] Reset\";\n    ];\n  ]\n\nlet subscriptions _ =\n  Sub.batch [\n    Sub.on_key (Char '+') Increment;\n    Sub.on_key (Char '-') Decrement;\n    Sub.on_key (Char 'r') Reset;\n  ]\n\nlet () = \n  run (app ~init ~update ~view ~subscriptions ())\n```\n\n## License\n\nMosaic is licensed under the ISC license. See [LICENSE](LICENSE) for details.\n","funding_links":[],"categories":["\u003ca name=\"C\"\u003e\u003c/a\u003eC"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmattio%2Fmosaic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmattio%2Fmosaic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmattio%2Fmosaic/lists"}