Closed pravic closed 4 years ago
Why not to use FileMonitor : System.watch(path)
?
See:
https://sciter.com/docs/content/script/System.htm
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.
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?
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!
Well, closing this in favor of upstream changes :+1:
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:
view.onRequestResponse
hook in order to track the all requests to local (e.g. file://) HTML and CSS files that are loaded in uSciter's view (of course, the old hook is preserved because it is needed by Inspector)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.