{"id":22904581,"url":"https://github.com/baalimago/wd-41","last_synced_at":"2025-04-05T15:02:58.619Z","repository":{"id":253572085,"uuid":"838012377","full_name":"baalimago/wd-41","owner":"baalimago","description":"Web-Development 41, a static web server with live-reload","archived":false,"fork":false,"pushed_at":"2024-11-30T11:28:30.000Z","size":67,"stargazers_count":147,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T14:05:15.315Z","etag":null,"topics":["cli","development","golang","web-development-tools","websocket"],"latest_commit_sha":null,"homepage":"","language":"Go","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/baalimago.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":"2024-08-04T17:29:37.000Z","updated_at":"2025-01-16T03:57:16.000Z","dependencies_parsed_at":"2024-08-23T17:25:53.783Z","dependency_job_id":"75f52c28-ca41-4e3e-be48-5248fb820cbb","html_url":"https://github.com/baalimago/wd-41","commit_stats":null,"previous_names":["baalimago/wd-40","baalimago/wd-41"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baalimago%2Fwd-41","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baalimago%2Fwd-41/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baalimago%2Fwd-41/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baalimago%2Fwd-41/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baalimago","download_url":"https://codeload.github.com/baalimago/wd-41/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353729,"owners_count":20925329,"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","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":["cli","development","golang","web-development-tools","websocket"],"created_at":"2024-12-14T02:46:35.381Z","updated_at":"2025-04-05T15:02:58.601Z","avatar_url":"https://github.com/baalimago.png","language":"Go","funding_links":[],"categories":["Server Applications","development","服务器应用程序"],"sub_categories":["HTTP Clients","HTTP客户端"],"readme":"# (w)eb (d)evelopment-(41)\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/baalimago/wd-41)](https://goreportcard.com/report/github.com/baalimago/wd-41)\n[![wakatime](https://wakatime.com/badge/user/018cc8d2-3fd9-47ef-81dc-e4ad645d5f34/project/3bc921ec-dc23-4222-bf00-578f2eda0cbd.svg)](https://wakatime.com/badge/user/018cc8d2-3fd9-47ef-81dc-e4ad645d5f34/project/3bc921ec-dc23-4222-bf00-578f2eda0cbd)\n\nTest coverage: 76.640% 😌👏\n\nThis is a simple static webserver which live reloads your web-browser on changes to the hosted files.\n\n## Usage\n\n`wd-41 s|serve \u003crelative directory\u003e` or `wd-41 s|serve` for hosting the current work directory\n\n## Getting started\n\n```bash\ngo install github.com/baalimago/wd-41@latest\n```\n\nYou may also use the setup script:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/baalimago/wd-41/main/setup.sh | sh\n```\n\n## Architecture\n\n1. First the content of the website is copied to a temporary directory, this is the _mirrored content_\n1. Every mirrored file is inspected for type, if it's text/html, a `delta-streamer.js` script is injected\n1. The web server is started, hosting the _mirrored_ content\n1. The `delta-streamer.js` in turn sets up a websocket connection to the wd-41 webserver\n1. The original file system is monitored, on any file changes:\n   1. the new file is copied to the mirror (including injections)\n   1. the file name is propagated to the browser via the websocket\n1. The `delta-streamer.js` script then checks if the current window origin is the updated file. If so, it reloads the page.\n\n```\n       ┌───────────────┐\n       │ Web Developer │\n       └───────┬───────┘\n               │\n       [writes \u003ccontent\u003e]\n               │\n               ▼\n ┌─────────────────────────────┐        ┌─────────────────────┐\n │ website-directory/\u003ccontent\u003e │        │ file system notify  │\n └─────────────┬───────────────┘        └─────────┬───────────┘\n               │                                  │\n               │                      [update mirrored content]\n               ▼                                  │\n     ┌────────────────────┐                       │\n     │ ws-script injector │◄──────────────────────┘\n     └─────────┬──────────┘\n               │\n               │\n               ▼\n   ┌────────────────────────┐\n   │ tmp-abcd1234/\u003ccontent\u003e │\n   └───────────┬────────────┘\n               │\n       [serves \u003ccontent\u003e]\n               │                               ┌────────────────────────┐\n               ▼                               │         Browser        │\n┌──────────────────────────────┐               │                        │\n│          Web Server          │               │  ┌────┐  ┌───────────┐ │\n│ [localhost:\u003cport\u003e/\u003ccontent\u003e] │◄───[reload────┼─►│ ws │  │ \u003ccontent\u003e │ │\n└──────────────────────────────┘     page]     │  └────┘  └───────────┘ │\n                                               │                        │\n                                               └────────────────────────┘\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaalimago%2Fwd-41","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaalimago%2Fwd-41","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaalimago%2Fwd-41/lists"}