forked from adobe/brackets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Reverse Inspect in Live Preview using WebSockets, and now forwa… (
adobe#13044) * Added Reverse Inspect in Live Preview using WebSockets, and now forward inspect brings the html element in focus to the viewport in Live Preview * Added commands to start and close the WebSocketServer used in Live Preview and also now port is read from preferences file * Addressed review comments- used window.scrollTo instead of scrollIntoViewIfNeeded, added a check for port number in RemoteFunctions and some minor changes * Added dependency of ws in the root directory * Used window.document instead of defining global document in RemoteFunctions.js * Added JSDoc description in WebSocketTransportDomain.js and used lodash instead of for loop in HTMLInstrumentation.js * Added copy task of copying LiveDevelopment/transports to dist
- Loading branch information
Showing
11 changed files
with
345 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2017 - present Adobe Systems Incorporated. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
/** | ||
* This transport provides a WebSocket connection between Brackets and a live browser preview. | ||
* This is just a thin wrapper around the Node extension (WebSocketTransportDomain) that actually | ||
* provides the WebSocket server and handles the communication. We also rely on an injected script in | ||
* the browser for the other end of the transport. | ||
*/ | ||
|
||
define(function (require, exports, module) { | ||
"use strict"; | ||
|
||
var FileUtils = require("file/FileUtils"), | ||
NodeDomain = require("utils/NodeDomain"), | ||
EditorManager = require("editor/EditorManager"), | ||
HTMLInstrumentation = require("language/HTMLInstrumentation"); | ||
|
||
// The node extension that actually provides the WebSocket server. | ||
|
||
var domainPath = FileUtils.getNativeBracketsDirectoryPath() + "/" + FileUtils.getNativeModuleDirectoryPath(module) + "/node/WebSocketTransportDomain"; | ||
|
||
var WebSocketTransportDomain = new NodeDomain("webSocketTransport", domainPath); | ||
|
||
// Events | ||
|
||
WebSocketTransportDomain.on("message", function (obj, message) { | ||
console.log("WebSocketTransport - event - message" + " - " + message); | ||
var editor = EditorManager.getActiveEditor(), | ||
position = HTMLInstrumentation.getPositionFromTagId(editor, parseInt(message, 10)); | ||
if (position) { | ||
editor.setCursorPos(position.line, position.ch, true); | ||
} | ||
}); | ||
|
||
function createWebSocketServer(port) { | ||
WebSocketTransportDomain.exec("start", parseInt(port, 10)); | ||
} | ||
|
||
function closeWebSocketServer() { | ||
WebSocketTransportDomain.exec("close"); | ||
} | ||
|
||
exports.createWebSocketServer = createWebSocketServer; | ||
exports.closeWebSocketServer = closeWebSocketServer; | ||
}); |
Oops, something went wrong.