| OLD | NEW | 
|---|
| 1 #!mojo mojo:js_content_handler | 1 #!mojo mojo:js_content_handler | 
| 2 // Copyright 2015 The Chromium Authors. All rights reserved. | 2 // Copyright 2015 The Chromium Authors. All rights reserved. | 
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be | 
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. | 
| 5 | 5 | 
| 6 // Simple JavaScript REPL example, using TerminalClient. | 6 // Simple JavaScript REPL example, using TerminalClient. | 
| 7 // | 7 // | 
| 8 // To run this, do something like: | 8 // To run this, do something like: | 
| 9 // | 9 // | 
| 10 //   $ sky/tools/mojodb start out/Debug mojo:moterm_example_app | 10 //   $ sky/tools/mojodb start out/Debug mojo:moterm_example_app | 
| 11 // | 11 // | 
| 12 // At the moterm_example_app prompt: | 12 // At the moterm_example_app prompt: | 
| 13 // | 13 // | 
| 14 //   :) file:///absolute/path/to/repl.js | 14 //   :) file:///absolute/path/to/repl.js | 
| 15 // | 15 // | 
| 16 // Then, at the repl.js prompt, enter JavaScript, e.g.: | 16 // Then, at the repl.js prompt, enter JavaScript, e.g.: | 
| 17 // | 17 // | 
| 18 //   > 1 + 2 | 18 //   > 1 + 2 | 
| 19 //   3 | 19 //   3 | 
| 20 //   > function f(x, y) { return x + y; } | 20 //   > function f(x, y) { return x + y; } | 
| 21 //   undefined | 21 //   undefined | 
| 22 //   > f("abc", 123) | 22 //   > f("abc", 123) | 
| 23 //   "abc123" | 23 //   "abc123" | 
| 24 // | 24 // | 
| 25 // (Note that multiple simultaneous REPLs will share the same global state, that | 25 // (Note that multiple simultaneous REPLs will share the same global state, that | 
| 26 // the global state will persist, etc. This is really just intended as a demo!) | 26 // the global state will persist, etc. This is really just intended as a demo!) | 
| 27 | 27 | 
| 28 define("main", [ | 28 define("main", [ | 
| 29   "mojo/services/public/js/application", | 29   "mojo/services/public/js/application", | 
| 30   "mojo/services/files/public/interfaces/types.mojom", | 30   "mojo/services/files/interfaces/types.mojom", | 
| 31   "mojo/services/terminal/public/interfaces/terminal_client.mojom", | 31   "mojo/services/terminal/public/interfaces/terminal_client.mojom", | 
| 32 ], function(application, files_types, terminal_client) { | 32 ], function(application, files_types, terminal_client) { | 
| 33   const Application = application.Application; | 33   const Application = application.Application; | 
| 34   const TerminalClient = terminal_client.TerminalClient; | 34   const TerminalClient = terminal_client.TerminalClient; | 
| 35   const Whence = files_types.Whence; | 35   const Whence = files_types.Whence; | 
| 36 | 36 | 
| 37   function stringToBytes(s) { | 37   function stringToBytes(s) { | 
| 38     return s.split("").map(function (c) { return c.charCodeAt(0); }); | 38     return s.split("").map(function (c) { return c.charCodeAt(0); }); | 
| 39   } | 39   } | 
| 40 | 40 | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 101 | 101 | 
| 102   class ReplApp extends Application { | 102   class ReplApp extends Application { | 
| 103     acceptConnection(initiatorURL, initiatorServiceExchange) { | 103     acceptConnection(initiatorURL, initiatorServiceExchange) { | 
| 104       initiatorServiceExchange.provideService(TerminalClient, | 104       initiatorServiceExchange.provideService(TerminalClient, | 
| 105                                               TerminalClientImpl); | 105                                               TerminalClientImpl); | 
| 106     } | 106     } | 
| 107   } | 107   } | 
| 108 | 108 | 
| 109   return ReplApp; | 109   return ReplApp; | 
| 110 }); | 110 }); | 
| OLD | NEW | 
|---|