Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Allow live preview session to live longer after a currentDocumentChange #4801

Merged
merged 1 commit into from
Aug 23, 2013

Conversation

jasonsanjose
Copy link
Member

Fix for #3970

Keeps live documents open longer. Previously documents would close after a currentDocumentChange event. Also refactors how/when we update the StaticServer request filters.

@jasonsanjose
Copy link
Member Author

Added a fix for #4786 to rewrite HTTP responses for CSSDocument too.

* Enable instrumented CSS
* @param enabled {boolean}
*/
CSSDocument.prototype.setInstrumentationEnabled = function setInstrumentationEnabled(enabled) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this method needed? The code in ServerRequestManager always checks for the presence of this method before calling it, so it seems like it is safe to be omitted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need this (or an equivalent flag) to distinguish a document that can provide it's own HTTP response (see ServerRequestManager.add(). I think the intent is clearer for HTMLDocument in the case where we're not using StaticServer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the function names added twice in this 2 new methods?

@gruehle
Copy link
Member

gruehle commented Aug 21, 2013

Running with a custom Live Preview Base URL is broken. The UserServerProvider class doesn't have a setRequestFilterPaths method.

@gruehle
Copy link
Member

gruehle commented Aug 21, 2013

One of the Live Development unit tests is failing.

@gruehle
Copy link
Member

gruehle commented Aug 21, 2013

Initial review complete.

@jasonsanjose
Copy link
Member Author

I'm starting to think that it makes more sense to move the ServerRequestManager methods to StaticServerProvider and UserServerProvider. @gruehle thoughts?

$(Inspector.Page).on("frameNavigated.NetworkAgent", _onFrameNavigated);
$(Inspector.Network).on("requestWillBeSent.NetworkAgent", _onRequestWillBeSent);
}

/** Unload the agent */
function unload() {
_urlRequested = {};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When unloaded, wasURLRequested should return false always.

@jasonsanjose
Copy link
Member Author

So, I took on the refactoring. In addition to pushing ServerRequestManager down into each server provider I...

  • Split them up and named them (properly) as FileServer, UserServer and StaticServer with a BaseServer base class
  • I also was able to extract a lot of the path/url munging that happened in LiveDevelopment
  • Moved the request filtering (StaticServer specific code) into StaticServer...brilliant 👍

FileServer.prototype.urlToPath = function (url) {
var path;

if (url.indexOf("file://") === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use PREFIX here and eliminate the extra '/' check on line 76.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@gruehle
Copy link
Member

gruehle commented Aug 22, 2013

Should BaseServer.js, FileServer.js, LiveDevServerManager.js and UserServer.js be moved into a new Servers directory? That would help with source organization.

@gruehle
Copy link
Member

gruehle commented Aug 22, 2013

2nd review complete.

@jasonsanjose
Copy link
Member Author

Moved the servers to LiveDevelopment/Servers

/**
* Returns a base url for current project.
*
* @return {String}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use lower cases for String

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

* Create a live version of a Brackets document
* @param {Document} doc
* @param {Editor} editor
* @return {HTMLDocument|CSSDocument}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function return null too. So it should be {?(HTMLDocument|CSSDocument)}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@TomMalbran
Copy link
Contributor

I think I am done now, reviewing the JSDocs :)

@jasonsanjose
Copy link
Member Author

@gruehle ready for review


/**
* @constructor
* Server for file: URLs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add @extends {BaseServer} on all this Servers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

fix bugs and disconnect handling

add jsdoc. remove unnecessary close/reopen of live dev connection.

fix for #4786 add CSSDocument to ServerRequestManager to rewrite HTTP responses on refresh

Refactor ServerRequestManager and all live dev server providers into BaseServer, FileServer, UserServer and StaticServer.

fix jshint errors

code review comments

code review comments from TomMalbran

more jsdoc comments from @TomMalbran

revert move of LiveDevServerManager to keep compatibility with theseus

Adapt older servers (theseus) to work with new API

break compatibility with older servers, including older versions of theseus

fix typo
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants