wd-41

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 7 Imported by: 0

README ΒΆ

(w)eb (d)evelopment-(41)

Go Report Card wakatime

Test coverage: 75.640% πŸ˜ŒπŸ‘

This is a simple static webserver which live reloads your web-browser on changes to the hosted files.

Usage

wd-41 s|serve <relative directory> or wd-41 s|serve for hosting the current work directory

Getting started

go install github.com/baalimago/wd-41@latest

You may also use the setup script:

curl -fsSL https://raw.githubusercontent.com/baalimago/wd-41/main/setup.sh | sh

Architecture

  1. First the content of the website is copied to a temporary directory, this is the mirrored content
  2. Every mirrored file is inspectd for type, if it's text/html, a delta-streamer.js script is injected
  3. The web server is started, hosting the mirrored content
  4. The delta-streamer.js in turn sets up a websocket connection to the wd-41 webserver
  5. The original file system is monitored, on any file changes:
    1. the new file is copied to the mirror (including injections)
    2. the file name is propagated to the browser via the websocket
  6. The delta-streamer.js script then checks if the current window origin is the updated file. If so, it reloads the page.
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                                 
       β”‚ Web Developer β”‚                                                 
       β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                                                 
               β”‚                                                         
       [writes <content>]                                                
               β”‚                                                         
               β–Ό                                                         
 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          
 β”‚ website-directory/<content> β”‚        β”‚ file system notify  β”‚          
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          
               β”‚                                  β”‚                      
               β”‚                      [update mirrored content]          
               β–Ό                                  β”‚                      
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚                      
     β”‚ ws-script injector β”‚β—„β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                              
               β”‚                                                         
               β”‚                                                         
               β–Ό                                                         
   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                            
   β”‚ tmp-abcd1234/<content> β”‚                                            
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                            
               β”‚                                                         
       [serves <content>]                                                
               β”‚                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β–Ό                               β”‚         Browser        β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚                        β”‚
β”‚          Web Server          β”‚               β”‚  β”Œβ”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ [localhost:<port>/<content>] │◄───[reload────┼─►│ ws β”‚  β”‚ <content> β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     page]     β”‚  β””β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
                                               β”‚                        β”‚
                                               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher πŸ‡»πŸ‡³