{"id":38240220,"url":"https://github.com/tinywasm/devwatch","last_synced_at":"2026-01-17T01:12:38.331Z","repository":{"id":309456520,"uuid":"1033946753","full_name":"tinywasm/devwatch","owner":"tinywasm","description":"fsnotify implementation Watches file system changes in a project directory, triggering custom handlers for file and folder events, and supporting browser reloads and selective file ignoring.","archived":false,"fork":false,"pushed_at":"2026-01-09T19:56:45.000Z","size":201,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-14T13:51:12.373Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/tinywasm.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-07T15:38:47.000Z","updated_at":"2026-01-09T19:56:48.000Z","dependencies_parsed_at":"2025-08-12T02:38:32.680Z","dependency_job_id":"24d6ada7-4498-41cf-b731-9a11d0443aa1","html_url":"https://github.com/tinywasm/devwatch","commit_stats":null,"previous_names":["cdvelop/devwatch","tinywasm/devwatch"],"tags_count":50,"template":false,"template_full_name":null,"purl":"pkg:github/tinywasm/devwatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinywasm%2Fdevwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinywasm%2Fdevwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinywasm%2Fdevwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinywasm%2Fdevwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinywasm","download_url":"https://codeload.github.com/tinywasm/devwatch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinywasm%2Fdevwatch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28491089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T00:50:05.742Z","status":"ssl_error","status_checked_at":"2026-01-17T00:43:11.982Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":[],"created_at":"2026-01-17T01:12:38.255Z","updated_at":"2026-01-17T01:12:38.310Z","avatar_url":"https://github.com/tinywasm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# devwatch\n\u003c!-- START_SECTION:BADGES_SECTION --\u003e\n\u003ca href=\"docs/img/badges.svg\"\u003e\u003cimg src=\"docs/img/badges.svg\" alt=\"Project Badges\" title=\"Generated by devflow from github.com/tinywasm/devflow\"\u003e\u003c/a\u003e\n\u003c!-- END_SECTION:BADGES_SECTION --\u003e\n\nfsnotify implementation Watches file system changes in a project directory, triggering custom handlers for file and folder events, and supporting browser reloads and selective file ignoring.\n\n## Public API\n\n### Main Types\n\n```go\n// FilesEventHandlers unifies asset and Go file event handling.\n// It allows handlers to specify which file extensions they support and how to process them.\ntype FilesEventHandlers interface {\n\tMainInputFileRelativePath() string // eg: go =\u003e \"app/server/main.go\" | js =\u003e\"app/pwa/public/main.js\"\n\t// NewFileEvent handles file events (create, remove, write, rename).\n\tNewFileEvent(fileName, extension, filePath, event string) error\n\tSupportedExtensions() []string // eg: [\".go\"], [\".js\",\".css\"], etc.\n\tUnobservedFiles() []string     // eg: main.exe, main.js\n}\n\n// Folder event handler interface\n// event: create, remove, write, rename\n type FolderEvent interface {\n     NewFolderEvent(folderName, path, event string) error\n }\n\n// Main configuration struct\n type WatchConfig struct {\n     AppRootDir         string               // Project root directory\n     FilesEventHandlers []FilesEventHandlers // All file event handlers are managed here\n     FolderEvents       FolderEvent          // Handler for folder events\n     BrowserReload      func() error         // Function to reload the browser\n     Logger             func(message ...any) // Log output\n     ExitChan           chan bool            // Channel to signal exit\n     UnobservedFiles    func() []string      // Files/folders to ignore (e.g. .git, .vscode)\n }\n\n type DevWatch struct {\n     *WatchConfig\n     // ... (internal fields)\n }\n```\n\n### Initialization and Usage\n\n```go\n// Create your handlers that implement the FilesEventHandlers interface\n// Example handlers:\n// assetsHandler handles .css, .js, .html\n// goServerHandler handles .go files for the server\n// tinyWasmHandler handles .go files for wasm and .js for runtime detection\n\n// Create configuration\ncfg := \u0026devwatch.WatchConfig{\n    AppRootDir:      \"/path/to/your/app\",\n    FilesEventHandlers: []devwatch.FilesEventHandlers{\n        assetsHandler,\n        goServerHandler,\n        tinyWasmHandler,\n    },\n    FolderEvents:    yourFolderHandler,\n    BrowserReload:   yourReloadFunc,\n    Logger:          func(message ...any) { fmt.Println(message...) },\n    ExitChan:        make(chan bool),\n    UnobservedFiles: func() []string { return []string{\".git\", \".vscode\"} },\n}\n\n// Create watcher\nwatcher := devwatch.New(cfg)\n\n// Start the watcher (example with WaitGroup)\nvar wg sync.WaitGroup\nwg.Add(1)\ngo watcher.FileWatcherStart(\u0026wg)\n```\n\n### Notes\n\n- Implement your own handlers for `FilesEventHandlers` and `FolderEvent` according to your application logic.\n- Each handler in `FilesEventHandlers` must specify the file extensions it supports via the `SupportedExtensions()` method.\n- For `.go` files, the system automatically identifies the correct handler(s) using `godepfind` dependency logic.\n- The handlers are processed in the order they are registered in the `FilesEventHandlers` slice.\n- Use the `ExitChan` channel to stop the watcher gracefully.\n\n\n## [Contributing](https://github.com/tinywasm/cdvelop/blob/main/CONTRIBUTING.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinywasm%2Fdevwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinywasm%2Fdevwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinywasm%2Fdevwatch/lists"}