-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Issue by jasonsanjose
Thursday Oct 16, 2014 at 17:21 GMT
Originally opened as adobe#475
Proof of concept to serve brackets core www files over a static file HTTP node server.
After running into various issues with the security model (or lack of) in CEF combined with the issues when using the file:
protocol, I thought it would be fun to see what it would take to serve Brackets over HTTP within brackets-shell using the built-in node server.
Overall, this is not required for any current/planned features. However, I think it would help Brackets get closer to moving into the browser if we could transition away from file:
first within brackets-shell.
Changes:
appshell/node-core/Server.js
- We already had an HTTP server in place for
NodeConnection
to read the/api
JSON (i.e. http://localhost:[node_port]/api) - Changed the request handler to support static file serving from either the "hacked" location /dev/src or installed /www
- We already had an HTTP server in place for
appshell/node-core/thirdparty/conenct
- Use
static
middleware to serve files
- Use
- Force Brackets to load a page that redirects to the HTTP URL as soon as node setup is complete:
brackets.app.getNodeState(function (err, port) {
if (err) {
console.log("Failed to create local HTTP server");
} else {
window.location.href = "http://localhost:" + port + "/index.html";
}
});
There's still more to do on the www side. We wouldn't need to shift to a node-based FS since we're in brackets-shell and can still access brackets.fs
. However, a lot of www code (particularly extension loading) assumes a file:
URL. Here's the console log on init:
Download the React DevTools for a better development experience: http://fb.me/react-devtools /thirdparty/react.js:4356
[Extension] Error -- could not read native directory: /extensions/default /utils/ExtensionLoader.js:331
[Extension] Error -- could not read native directory: /extensions/dev /utils/ExtensionLoader.js:331
[NodeDomain] Error loading domain "fileWatcher": Unable to load one of the modules: /./filesystem/impls/appshell/node/FileWatcherDomain, reason: Cannot find module '/./filesystem/impls/appshell/node/FileWatcherDomain' /utils/NodeDomain.js:146
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:51518/Users/jasonsj/Library/Application%20Support/Brackets/extensions/user/brackets-beautify/main.js
[Extension] failed to load /Users/jasonsj/Library/Application Support/Brackets/extensions/user/brackets-beautify Error: Script error for: main
http://requirejs.org/docs/errors.html#scripterror /utils/ExtensionLoader.js:214
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:51518/Users/jasonsj/Library/Application%20Support/Brackets/extensions/user/brackets-bower/main.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:51518/Users/jasonsj/Library/Application%20Support/Brackets/extensions/user/brackets-parfait-extension/main.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:51518/Users/jasonsj/Library/Application%20Support/Brackets/extensions/user/brackets-sass/main.js
[Extension] failed to load /Users/jasonsj/Library/Application Support/Brackets/extensions/user/brackets-bower Error: Script error for: main
http://requirejs.org/docs/errors.html#scripterror /utils/ExtensionLoader.js:214
[Extension] failed to load /Users/jasonsj/Library/Application Support/Brackets/extensions/user/brackets-parfait-extension Error: Script error for: main
http://requirejs.org/docs/errors.html#scripterror /utils/ExtensionLoader.js:214
[Extension] failed to load /Users/jasonsj/Library/Application Support/Brackets/extensions/user/brackets-sass Error: Script error for: main
http://requirejs.org/docs/errors.html#scripterror /utils/ExtensionLoader.js:214
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:51518/Users/jasonsj/Library/Application%20Support/Brackets/extensions/user/gruehle.markdown-preview/main.js
[Extension] failed to load /Users/jasonsj/Library/Application Support/Brackets/extensions/user/gruehle.markdown-preview Error: Script error for: main
http://requirejs.org/docs/errors.html#scripterror /utils/ExtensionLoader.js:214
Failed to watch root: /Users/jasonsj/Github/brackets/ Unable to load one of the modules: /./filesystem/impls/appshell/node/FileWatcherDomain, reason: Cannot find module '/./filesystem/impls/appshell/node/FileWatcherDomain' /filesystem/FileSystem.js:869
Error watching project root: /Users/jasonsj/Github/brackets/ Unable to load one of the modules: /./filesystem/impls/appshell/node/FileWatcherDomain, reason: Cannot find module '/./filesystem/impls/appshell/node/FileWatcherDomain' /project/ProjectManager.js:753
[Extensions] Failed to connect to node
Arguments[1]
jasonsanjose included the following code: https://github.com/adobe/brackets-shell/pull/475/commits