3939define ( function ( require , exports , module ) {
4040
4141
42- var EventDispatcher = require ( "utils/EventDispatcher" ) ;
42+ const EventDispatcher = require ( "utils/EventDispatcher" ) ;
4343
4444 // Text of the script we'll inject into the browser that handles protocol requests.
45- var LiveDevProtocolRemote = require ( "text!LiveDevelopment/BrowserScripts/LiveDevProtocolRemote.js" ) ,
45+ const LiveDevProtocolRemote = require ( "text!LiveDevelopment/BrowserScripts/LiveDevProtocolRemote.js" ) ,
4646 DocumentObserver = require ( "text!LiveDevelopment/BrowserScripts/DocumentObserver.js" ) ,
4747 RemoteFunctions = require ( "text!LiveDevelopment/BrowserScripts/RemoteFunctions.js" ) ,
4848 EditorManager = require ( "editor/EditorManager" ) ,
4949 LiveDevMultiBrowser = require ( "LiveDevelopment/LiveDevMultiBrowser" ) ,
5050 HTMLInstrumentation = require ( "LiveDevelopment/MultiBrowserImpl/language/HTMLInstrumentation" ) ,
5151 FileViewController = require ( "project/FileViewController" ) ;
5252
53+ const LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME = "phoenix_live_preview_scripts_instrumented_345Tt96G4.js" ;
54+
5355 /**
5456 * @private
5557 * Active connections.
@@ -232,13 +234,13 @@ define(function (require, exports, module) {
232234 * Includes the <script> tags.
233235 * @return {string }
234236 */
235- function getRemoteFunctionsScript ( ) {
236- var script = "" ;
237+ function _getRemoteFunctionsScript ( ) {
238+ let script = "" ;
237239 // Inject DocumentObserver into the browser (tracks related documents)
238240 script += DocumentObserver ;
239241 // Inject remote functions into the browser.
240- script += "window ._LD=(" + RemoteFunctions + "(" + JSON . stringify ( LiveDevMultiBrowser . config ) + "))" ;
241- return "<script> \n" + script + "</script> \n" ;
242+ script += "\nwindow ._LD=(" + RemoteFunctions + "(" + JSON . stringify ( LiveDevMultiBrowser . config ) + "))" ;
243+ return "\n" + script + "\n" ;
242244 }
243245
244246 /**
@@ -247,14 +249,25 @@ define(function (require, exports, module) {
247249 * This script will also include the script required by the transport, if any.
248250 * @return {string }
249251 */
250- function getRemoteScript ( ) {
251- var transportScript = _transport . getRemoteScript ( ) || "" ;
252- var remoteFunctionsScript = getRemoteFunctionsScript ( ) || "" ;
252+ function getRemoteScriptContents ( ) {
253+ const transportScript = _transport . getRemoteScript ( ) || "" ;
254+ const remoteFunctionsScript = _getRemoteFunctionsScript ( ) || "" ;
253255 return transportScript +
254- "<script> \n" + LiveDevProtocolRemote + "</script> \n" +
256+ "\n" + LiveDevProtocolRemote + "\n" +
255257 remoteFunctionsScript ;
256258 }
257259
260+ /**
261+ * Returns a script that should be injected into the HTML that's launched in the
262+ * browser in order to handle protocol requests. Includes the <script> tags.
263+ * This script will also include the script required by the transport, if any.
264+ * @return {string }
265+ */
266+ function getRemoteScript ( ) {
267+ // give a wrong random file name that wont have a possibility of an actual file name
268+ return `\n\t\t<script src="${ LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME } "></script>` ;
269+ }
270+
258271 /**
259272 * Protocol method. Evaluates the given script in the browser (in global context), and returns a promise
260273 * that will be fulfilled with the result of the script, if any.
@@ -374,6 +387,7 @@ define(function (require, exports, module) {
374387 // public API
375388 exports . setTransport = setTransport ;
376389 exports . getRemoteScript = getRemoteScript ;
390+ exports . getRemoteScriptContents = getRemoteScriptContents ;
377391 exports . evaluate = evaluate ;
378392 exports . setStylesheetText = setStylesheetText ;
379393 exports . getStylesheetText = getStylesheetText ;
@@ -382,4 +396,5 @@ define(function (require, exports, module) {
382396 exports . close = close ;
383397 exports . getConnectionIds = getConnectionIds ;
384398 exports . closeAllConnections = closeAllConnections ;
399+ exports . LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME = LIVE_DEV_REMOTE_SCRIPTS_FILE_NAME ;
385400} ) ;
0 commit comments