c-smile / sciter-sdk

Sciter is an embeddable HTML/CSS/scripting engine
http://sciter.com
Other
2.11k stars 223 forks source link

Add support for live-reloading of modified HTML/CSS files for uSciter. #164

Closed pravic closed 4 years ago

pravic commented 4 years ago

Andrew, a feature to consider.

This PR adds a new checkbox for uSciter which enables live-reloading of the current file.

The main purpose is to reload the current file as soon as it or any dependent HTML or CSS files are modified.

I intentionally skip TIS files because they (usually) do not affect UI but they are modified quite frequently. However, may be it is reasonable to monitor graphics resources (PNG/SVG) as well.

Essentially live-reloading works as this:

This feature request is opened for discussion and the code can be changed. Also I realize that uSciter is quite simple and may be there is no intention to evolve it.

c-smile commented 4 years ago

Why not to use FileMonitor : System.watch(path) ? See: https://sciter.com/docs/content/script/System.htm

pravic commented 4 years ago

It's easier to check a few needed files rather than to monitor all the modified files in the directory.

Also, what exactly directory to register for System.watch? The most common ancestor for all tracked files? Because they can lay in various directories.

c-smile commented 4 years ago

FileMonitor, when it is set on a directory, tracks any changes of any file in that directory. Monitor is shallow - it does not go inside sub-directories.

Consider /images/ folder for example. You may have written something like that uses foo.png that is not there yet. Ideally the html shall be refreshed to show the image when it will put there, no?

pravic commented 4 years ago

So, the file monitor doesn't track subdirectories - it have to be set for each parent directory of each tracked resource.

However, the image example makes sense. I should add the support of new files. I'll rewrite the code using the file watch, thanks!

pravic commented 4 years ago

Well, closing this in favor of upstream changes :+1: