{"id":16880038,"url":"https://github.com/mlhiter/laura","last_synced_at":"2025-10-14T17:31:45.217Z","repository":{"id":195514168,"uuid":"692936890","full_name":"mlhiter/laura","owner":"mlhiter","description":"to create a minimal frontend framework","archived":false,"fork":false,"pushed_at":"2023-09-18T13:29:13.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-22T09:12:46.247Z","etag":null,"topics":["framework"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mlhiter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-09-18T02:19:48.000Z","updated_at":"2023-09-18T13:29:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"3dfd51fa-64ab-49c9-85bc-097db260e7ea","html_url":"https://github.com/mlhiter/laura","commit_stats":null,"previous_names":["mlhiter/laura"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mlhiter/laura","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlhiter%2Flaura","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlhiter%2Flaura/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlhiter%2Flaura/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlhiter%2Flaura/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlhiter","download_url":"https://codeload.github.com/mlhiter/laura/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlhiter%2Flaura/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020077,"owners_count":26086806,"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-10-14T02:00:06.444Z","response_time":60,"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":["framework"],"created_at":"2024-10-13T15:57:02.800Z","updated_at":"2025-10-14T17:31:45.182Z","avatar_url":"https://github.com/mlhiter.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### 一，框架基本做了什么？\n\n#### 1，响应性（Reactivity）\n\n```html\n//without\n\u003cp id=\"cool-para\"\u003e\u003c/p\u003e\n\u003cscript\u003e\n  const coolPara = 'Lorem ipsum.';\n  const el = document.getElementById('cool-para');\n  el.innerText = coolPara;\n\u003c/script\u003e\n\n//with（Vue）\n\u003cscript setup\u003e\n  const coolPara = 'Lorem ipsum.';\n\u003c/script\u003e\n\u003ctemplate\u003e\n  \u003cp\u003e{{ coolPara }}\u003c/p\u003e\n\u003c/template\u003e\n\n//or（React）\nexport default function Para() {\n  const coolPara = 'Lorem ipsum';\n  return \u003cp\u003e{ coolPara }\u003c/p\u003e;\n}\n```\n\n可以看到书写的代码量大大减少，但是这不是主要原因；\n\n主要原因是这将UI和数据绑定组合在一起，我们只需要更改script里的数据即可更新template里的UI显示。\n\n#### 2，组合性（Composability）\n\n```html\n//with\n\u003c!-- Defining the component --\u003e\n\u003ccomponent name=\"cool-para\"\u003e\n  \u003cp\u003e\n    \u003ccontent /\u003e\n  \u003c/p\u003e\n\u003c/component\u003e\n\n\u003c!-- Using the component --\u003e\n\u003ccool-para\u003eLorem ipsum.\u003c/cool-para\u003e\n```\n\n我们可以通过定义组件并且在不同的地方重用它来提高复用率，就像定义函数使用函数一样，但是这是在原始的HTML情况下不具有的。\n\n#### 3，模板化（templating）\n\nVue中的template和React中的JSX的Component，用来展示的部分就是模板。\n\n为什么称为模板呢，因为它的数据是可变的，其他非数据部分不变，数据部分变就像模板一样喽。\n\n#### 4，虚拟DOM（virtual DOM）\n\n一种概念或者技术，简单的说就是我们虚构出一个DOM树存在内存里，当我们更新数据的时候，虚拟DOM树会检查自己哪里发生改变，然后仅改变真正DOM树的这一部分。\n\n为什么要在数据与真实DOM之间加上这样一层虚拟DOM呢？因为如果直接操控真实DOM经常会产生非常大的改变，损耗性能而且慢。而我们通过虚拟DOM可以做到仅改变我们想要改变的那一小部分的真实DOM，并且虚拟DOM存在内存里的代价是相对较小的（比直接操控真实DOM小）。\n\n#### 5，状态管理（state management）\n\n状态是框架的本质，状态的改变会导致相应的组件使用状态的新值来重新渲染其模板。\n\n### #参考文章\n\n[Building a Frontend Framework; Reactivity and Composability With Zero Dependencies --- 构建前端框架；零依赖性的反应性和可组合性 (18alan.space)](https://18alan.space/posts/how-hard-is-it-to-build-a-frontend-framework.html)\n\n[Frontend framework --- 前端框架 (mfrachet.github.io)](https://mfrachet.github.io/create-frontend-framework/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlhiter%2Flaura","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlhiter%2Flaura","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlhiter%2Flaura/lists"}