-
Notifications
You must be signed in to change notification settings - Fork 235
WIP: Adds basic support for LiveReload when watching/previewing #420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This is really awesome, thanks! I assume that it's a work in progress from the todo list? Weekends are typically family time so I don't do much OSS, but I'll review this early next week and get you comments if I have any. With regard to unit tests - I'm not totally strict about everything needing to have tests. In general I prefer to test component integration or anything that may break in the future due to refactoring. This is probably worth at least a couple tests, for example to make sure the engine is sending the correct signals. I'll get you better feedback once I've had a chance to take a look. Thanks again! |
6511dc1 to
1095ab4
Compare
|
Rebased onto develop. Yep, a WIP. I've been using this pull to develop my blog and am happy with the current LiveReload support. I want to move onto hardening the code somewhat now - going to look into adding some test coverage now. Questions: |
1095ab4 to
fb3cd89
Compare
|
I wouldn't worry too much about documentation. The easiest thing is probably just to add another paragraph to https://wyam.io/docs/usage/command-line#embedded-web-server. I think you can remove that from the todo list here - it's easy enough to write a little something up after the fact. I also noticed some tests, which is great. I'm going to try and get a release out later today or early tomorrow. I would love to include this in there. I'm going to bring down the PR and try it out locally, but assuming I don't hit any bumps are there any reasons why this isn't ready to roll? |
|
So I'm running into a little trouble. I'm hitting a Suspect it's because we're trying to bind to a specific IP address. Also found this issue from SignalR that suggests there's no good way around it other than running the application as an admin. I noticed you have the comment "This must be 127.0.0.1 due to http.sys hostname verification" - can you expand on that a little? It wouldn't work if we |
|
Some additional brainstorming - what do you think about the preview server doing some simple HTML injection for every HTML request? I.e., if LiveReload is active, inject the |
|
I'm seeing the following network error in Chrome (happens whether I use |
If
That's odd. I'll bring up a VM and try to reproduce. I'm not running under admin rights.
Love the idea! I was preparing a module for that, however, I didn't want to duplicate code with https://wyam.io/modules/htmlinsert. What do you think is the best way to handle that? I guess this is also where the browser extensions come into play.
When running with verbose logging, what do you get?
|
|
Got a VM working, steps I went through:
I couldn't reproduce any issues. 😿 |
|
Oh, crap, are you running Windows 7? Forgot that Websockets (from System.Net) are not supported by Microsoft under anything less than Windows 8. https://msdn.microsoft.com/en-us/library/system.net.websockets(v=vs.110).aspx This is due to an issue with http.sys. The library I'm using turns out to use System.Net.Websockets - Owin.Websockets. I looked for others but Livereload requires that the server serve the files + the socket on the same port. This would be impossible with Owin running. EDIT: We need this: bryceg/Owin.WebSocket#20 |
|
I'll look into getting a Windows 7 compatible library to work nicely with Owin. The upgrade connection code for Owin is rather simple, I might just fork the two above libraries. |
b7ae5b7 to
ec97434
Compare
|
Rebased with develop - now using Fleck. @daveaglick I believe this should work now under Windows 7. I'm going to have to find a Windows 7 VM somewhere to test it properly... |
|
Thanks for the continued effort on this one. My main dev box is Win 7 so I should be able to give this a go in the next couple days. |
|
Okay, taking a look at this now... With regard to code injection:
My opinion is that it shouldn't be in a module at all. If the injection is done through a module than that means that the configuration (or recipe) would need to know about it. LiveReload should be totally outside the scope of the configuration IMO and should be a lower-level concern. My thinking was that an OWIN middleware would do some simple text scanning for |
|
Looked briefly at Fleck - looks like a good choice. While it's not .NET Core yet, it does look like it's in the works in statianzo/Fleck#175 (last activity 10 days ago). That's important since Wyam will be going .NET Core before too long as well. |
Oh, didn't think about that, basically need to create some middleware that runs after static file requests that detects content type (.html or .htm) and injects in the LR scripts at the end of the I'm thinking it should be best effort - if the HTML is malformed or missing a body tag, give up. This means we could easily just use built-in XML parsing to reduce our dependencies. I'll look into the middleware when I have some time, maybe today. Do you want this feature in this pull, or another down the road?
Unfortunately had to fork the Owin middleware (https://github.com/Silvenga/Owin.WebSocket) and had to publish Owin.WebSocket.Fleck with Owin.WebSocket bundled as the nuget.org version was too old. Kind of a hack - I'll look into upgrading Fleck when dotNetCore version is stabilized. |
Don't worry about it right now - I'll probably do a little hacking and add this myself right after merge. Made some progress today - still getting some web socket errors on my client, but I think I'm getting close to figuring out why. I'm still alternating between access denied errors while running the LiveReload server and WebSocket connection errors on the client. I am gaining a much better appreciation for the mechanics of what's going on though, so the exercise has been helpful. Going to need to stop for the day soon, but I'll pick it up again tomorrow. I'm hoping to get stuff straightened out on my side so I can merge this in soon. It's a great feature. |
Well then, I need to find a Windows 7 VM. |
|
Added testing around hostname verifications. Windows 7 should fail to run the tests though... @daveaglick it only happens under <= Windows 7 from what I can tell. Windows 7 needs URL Reservations (http://stackoverflow.com/questions/24976425/running-self-hosted-owin-web-api-under-non-admin-account) for everything except Windows 8+ does seem count The test |
|
Root cause - It doesn't look like the required delegates are being registered by Katana with OWIN. This means that no websockets can take place. http://owin.org/spec/extensions/owin-WebSocket-Extension-v0.4.0.htm This is painful... I wonder if upgrading to Kestrel would help (or be practical). |
ed61245 to
b44585f
Compare
|
If it means anything, got Kestrel to work under Windows 7 with Websockets (I only upgraded the LR server)... It should inplace upgrade from using Kantana on the preview server (as Owin compatibility is kept). It might even be prefered considering the move to dotNetCore. This would completely move this project away from http.sys and bring compatibility to Mono. My current branch is full of hacks (not required in the end) and is a mess, I'll cleanup before committing. I did however have issues with VS2015 not playing nice with |
b44585f to
32f5902
Compare
52f42ed to
72212ad
Compare
|
Rebased onto develop with #449. Everything looks good under W10/W7 - interface binding should no longer be an issue and sockets just work. This also includes the injection middleware with some test coverage. |
72212ad to
eb7a654
Compare
|
Yay! I'll take a look first thing in the morning and hopefully get it merged ASAP now. |
|
Wow. Just wow. It works and it's totally amazing. Going to merge in a minute. Fantastic work, and thanks for sticking with it while we worked out all the bumps. |
* Added basic support for LiveReload when watching + previewing. * Support for standalone LR host when watching. * Added basic coverage on LiveReloadServer. * Added support for Win7 using Fleck web sockets. * Added hostname tests. * Added script injection support. * Disabled hostname tests under CI - requires a x86 runner.


This pull request adds basic support for the LiveReload protocol when watching and previewing. Created as I use (https://github.com/gruntjs/grunt-contrib-watch#optionslivereload) religiously and due to my chronic lazyness problem (I'm getting help).
TODO
livereload.jsdirectly (required by the LiveReload protocol).livereload.jsin the site source. e.g. https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei?hl=enAdd support for alerts.Questions
Is the protocol implemented sufficiently?IsReloadClientServiceLocatorimplemented sufficiently?