{"id":24326719,"url":"https://github.com/transclusion/runtime","last_synced_at":"2026-05-03T22:33:01.140Z","repository":{"id":86682064,"uuid":"104500013","full_name":"transclusion/runtime","owner":"transclusion","description":"** IN ALPHA ** An isomorphic runtime for functional JavaScript programs.","archived":false,"fork":false,"pushed_at":"2018-04-03T22:31:55.000Z","size":111,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-14T16:54:15.074Z","etag":null,"topics":["framework","functional","isomorphic","javascript","virtual-dom"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/transclusion.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2017-09-22T17:18:07.000Z","updated_at":"2018-01-11T20:33:28.000Z","dependencies_parsed_at":"2023-03-06T11:00:27.526Z","dependency_job_id":null,"html_url":"https://github.com/transclusion/runtime","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/transclusion/runtime","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transclusion%2Fruntime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transclusion%2Fruntime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transclusion%2Fruntime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transclusion%2Fruntime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/transclusion","download_url":"https://codeload.github.com/transclusion/runtime/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/transclusion%2Fruntime/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32587818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"ssl_error","status_checked_at":"2026-05-03T22:09:10.534Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["framework","functional","isomorphic","javascript","virtual-dom"],"created_at":"2025-01-17T21:14:16.089Z","updated_at":"2026-05-03T22:33:01.134Z","avatar_url":"https://github.com/transclusion.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @transclusion/runtime\n\nAn isomorphic runtime for functional JavaScript programs.\n\n## Features\n\n* **Inspired by Elm**. Based on concepts similar to Elm’s – in good ol’ JavaScript – with server-side support.\n* **Pure.** Write view components using pure functions. Handle side-effects in separate handler functions.\n* **Typed**. Written in TypeScript.\n\n## Documentation\n\n### Philosophy\n\n`runtime` separates application logic between the browser, worker and server.\n\n| Scope                               | Responsibility                                                                                                                                                                             |\n| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| [Browser](packages/runtime-browser) | Responsible for updating the DOM and using other Web APIs such as Animation, History, Geolocation, and so on.                                                                              |\n| [Worker](packages/runtime-worker)   | Responsible for keeping track of application state, virtual DOM and diffing. The worker also handles network requests.                                                                     |\n| [Server](packages/runtime-server)   | Responsible for rendering the initial state of a program, given a set of input properties such as URL path, query parameters, cookies and so on. The server also handles network requests. |\n\n### Motivation for using a worker thread\n\n**Using a worker thread** for maintaining application state and diffing the virtual DOM, keeps heavy operations away\nfrom the main UI thread. **The main UI thread** should mostly be idle, and sometimes perform DOM operations and interact\nwith other Web APIs.\n\n## Getting started\n\nFirst install the dependencies:\n\n```sh\nnpm install @transclusion/vdom -S\nnpm install @transclusion/runtime-core -S\nnpm install @transclusion/runtime-browser -S\nnpm install @transclusion/runtime-server -S\nnpm install @transclusion/runtime-worker -S\n```\n\n### Create a program called `root.js`\n\nComponents in `runtime` are called _programs_ (like in Elm).\n\n```jsx\n/** @jsx createVElement */\n\nimport {createVElement} from '@transclusion/vdom'\n\n// Expose message/command types that will be sent to the browser\nexport const ports = {\n  history: ['history/POP_STATE', 'history/PUSH_STATE', 'history/REPLACE_STATE']\n}\n\n// Initialize the program’s model value\nexport function init(props) {\n  return [{path: props.path, state: props.state, title: props.title}, null]\n}\n\n// Update the program’s model value (after which the view is re-rendered)\nexport function update(model, msg) {\n  switch (msg.type) {\n    case 'history/POP_STATE':\n    case 'history/PUSH_STATE':\n    case 'history/REPLACE_STATE':\n      return [{...model, path: msg.path, state: msg.state, title: msg.title}, null]\n    default:\n      return [model, null]\n  }\n}\n\nfunction navView() {\n  return (\n    \u003cdiv\u003e\n      \u003ca href=\"/\" on={{click: {type: 'history/PUSH_STATE', path: '/', preventDefault: true}}}\u003e\n        Home\n      \u003c/a\u003e{' '}\n      \u003ca href=\"/blog\" on={{click: {type: 'history/PUSH_STATE', path: '/blog', preventDefault: true}}}\u003e\n        Blog\n      \u003c/a\u003e\n    \u003c/div\u003e\n  )\n}\n\n// Render the view as virtual DOM\nexport function view(model) {\n  switch (model.path) {\n    case '/':\n      return (\n        \u003cdiv\u003e\n          {navView()}\n          \u003ch1\u003eHome screen\u003c/h1\u003e\n        \u003c/div\u003e\n      )\n    case '/blog':\n      return (\n        \u003cdiv\u003e\n          {navView()}\n          \u003ch1\u003eBlog screen\u003c/h1\u003e\n        \u003c/div\u003e\n      )\n    default:\n      return (\n        \u003cdiv\u003e\n          {navView()}\n          \u003ch1\u003eNot found: {model.path}\u003c/h1\u003e\n        \u003c/div\u003e\n      )\n  }\n}\n```\n\n### In the browser\n\n```js\nimport {run} from '@transclusion/runtime-browser'\n\nconst rootElm = document.getElementById('root')\n\nrun(\n  {\n    element: rootElm.firstChild,\n    props: __INITIAL_PROPS__,\n    worker: new Worker('worker.js')\n  },\n  ({ports}) =\u003e {\n    ports.history.subscribe(msg =\u003e {\n      switch (msg.type) {\n        case 'history/PUSH_STATE':\n          history.pushState(msg.state, msg.title, msg.path)\n          break\n        case 'history/REPLACE_STATE':\n          history.replaceState(msg.state, msg.title, msg.path)\n          break\n      }\n    })\n\n    window.addEventListener('popstate', event =\u003e {\n      ports.history.send({\n        type: 'history/POP_STATE',\n        path: location.pathname,\n        state: event.state,\n        title: document.title\n      })\n    })\n  }\n)\n```\n\n### In the worker\n\n```js\nimport {run} from '@transclusion/runtime-worker'\nimport * as root from './root'\n\nrun({\n  program: root,\n  scope: this\n})\n```\n\n### On the server\n\n```js\nimport {run} from '@transclusion/runtime-server'\nimport express from 'express'\nimport * as root from './root'\n\nconst app = express()\n\napp.get('/*', (req, res) =\u003e {\n  run({\n    program: root,\n    props: {path: req.path}\n  })\n    .then(context =\u003e {\n      res.send(`\u003c!DOCTYPE html\u003e\n  \u003chtml\u003e\n  \u003chead\u003e\u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv id=\"root\"\u003e${context.html}\u003c/div\u003e\n    \u003cscript\u003e\n    var __INITIAL_PROPS__ = ${JSON.stringify(context.model)}\n    \u003c/script\u003e\n    \u003cscript src=\"browser.js\"\u003e\u003c/script\u003e\n  \u003c/body\u003e\n  \u003c/html\u003e`)\n    })\n    .catch(err =\u003e {\n      res.status(500)\n      res.send(err.stack)\n    })\n})\n\napp.listen(3000)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransclusion%2Fruntime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftransclusion%2Fruntime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransclusion%2Fruntime/lists"}