From 3ae0bb0968907dad1f730372f5309dc2cf0ea000 Mon Sep 17 00:00:00 2001 From: Solly Ross Date: Fri, 3 Feb 2017 23:17:44 -0500 Subject: [PATCH] Uncomment ES6 module syntax This removes the special comment part of the ES6 module syntax, opting to enable ES6 module syntax by default. It also appends `.js` to all import paths to better support in-browser loading. --- app/ui.js | 28 ++++++++-------------------- app/webutil.js | 6 ++---- core/base64.js | 2 +- core/des.js | 2 +- core/display.js | 9 ++++----- core/input/devices.js | 11 +++++------ core/input/keysym.js | 2 +- core/input/keysymdef.js | 2 +- core/input/util.js | 9 ++++----- core/input/xtscancodes.js | 2 +- core/rfb.js | 23 +++++++++++------------ core/util.js | 2 +- core/websock.js | 7 +++---- 13 files changed, 43 insertions(+), 62 deletions(-) diff --git a/app/ui.js b/app/ui.js index 56bd9f7..8009c38 100644 --- a/app/ui.js +++ b/app/ui.js @@ -11,14 +11,12 @@ /* jslint white: false, browser: true */ /* global window, document.getElementById, Util, WebUtil, RFB, Display */ -/* [module] - * import Util from "../core/util"; - * import KeyTable from "../core/input/keysym"; - * import keysyms from "../core/input/keysymdef"; - * import RFB from "../core/rfb"; - * import Display from "../core/display"; - * import WebUtil from "./webutil"; - */ +import Util from "../core/util.js"; +import KeyTable from "../core/input/keysym.js"; +import keysyms from "../core/input/keysymdef.js"; +import RFB from "../core/rfb.js"; +import Display from "../core/display.js"; +import WebUtil from "./webutil.js"; var UI; @@ -73,16 +71,6 @@ var UI; {'app': ["locale/" + Util.Localisation.language + ".js"]}); } - /* [begin skip-as-module] */ - // Load supporting scripts - WebUtil.load_scripts( - {'core': ["base64.js", "websock.js", "des.js", "input/keysymdef.js", - "input/xtscancodes.js", "input/util.js", "input/devices.js", - "display.js", "inflator.js", "rfb.js", "input/keysym.js"]}); - - window.onscriptsload = function () { UI.load(); }; - /* [end skip-as-module] */ - var _ = Util.Localisation.get; UI = { @@ -1755,7 +1743,7 @@ var UI; */ }; - /* [module] UI.load(); */ + UI.load(); })(); -/* [module] export default UI; */ +export default UI; diff --git a/app/webutil.js b/app/webutil.js index e6e6afb..6afd015 100644 --- a/app/webutil.js +++ b/app/webutil.js @@ -10,9 +10,7 @@ /*jslint bitwise: false, white: false, browser: true, devel: true */ /*global Util, window, document */ -/* [module] - * import Util from "../core/util"; - */ +import Util from "../core/util.js"; // Globals defined here var WebUtil = {}; @@ -308,4 +306,4 @@ WebUtil.load_scripts = function (files_by_dir) { } }; -/* [module] export default WebUtil; */ +export default WebUtil; diff --git a/core/base64.js b/core/base64.js index 2b4f948..3b9ebe5 100644 --- a/core/base64.js +++ b/core/base64.js @@ -112,4 +112,4 @@ var Base64 = { } }; /* End of Base64 namespace */ -/* [module] export default Base64; */ +export default Base64; diff --git a/core/des.js b/core/des.js index c9a4753..6268493 100644 --- a/core/des.js +++ b/core/des.js @@ -77,7 +77,7 @@ /* jslint white: false */ -/* [module] export default */ function DES(passwd) { +export default function DES(passwd) { "use strict"; // Tables, permutations, S-boxes, etc. diff --git a/core/display.js b/core/display.js index f7c437b..a1dac7a 100644 --- a/core/display.js +++ b/core/display.js @@ -10,12 +10,11 @@ /*jslint browser: true, white: false */ /*global Util, Base64, changeCursor */ -/* [module] - * import Util from "./util"; - * import Base64 from "./base64"; - */ +import Util from "./util.js"; +import Base64 from "./base64.js"; + -/* [module] export default */ function Display(defaults) { +export default function Display(defaults) { this._drawCtx = null; this._c_forceCanvas = false; diff --git a/core/input/devices.js b/core/input/devices.js index 2e41122..74317ca 100644 --- a/core/input/devices.js +++ b/core/input/devices.js @@ -8,12 +8,11 @@ /*jslint browser: true, white: false */ /*global window, Util */ -/* [module] - * import Util from "../util"; - * import KeyboardUtil from "./util"; - */ +import Util from "../util.js"; +import KeyboardUtil from "./util.js"; + -/* [module] export */ var Keyboard; +export var Keyboard; (function () { "use strict"; @@ -148,7 +147,7 @@ ]); })(); -/* [module] export */ var Mouse; +export var Mouse; (function () { Mouse = function (defaults) { diff --git a/core/input/keysym.js b/core/input/keysym.js index 5983c38..15cc1bc 100644 --- a/core/input/keysym.js +++ b/core/input/keysym.js @@ -379,4 +379,4 @@ var KeyTable = { XK_ydiaeresis: 0x00ff, /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */ }; -/* [module] export default KeyTable; */ +export default KeyTable; diff --git a/core/input/keysymdef.js b/core/input/keysymdef.js index c4d0ace..e618c16 100644 --- a/core/input/keysymdef.js +++ b/core/input/keysymdef.js @@ -21,4 +21,4 @@ var keysyms = (function(){ }; })(); -/* [module] export default keysyms */ +export default keysyms diff --git a/core/input/util.js b/core/input/util.js index 52b3128..f34a9ab 100644 --- a/core/input/util.js +++ b/core/input/util.js @@ -1,7 +1,6 @@ -/* [module] - * import KeyTable from "./keysym"; - * import keysyms from "./keysymdef"; - */ +import KeyTable from "./keysym.js"; +import keysyms from "./keysymdef.js"; + var KeyboardUtil = {}; @@ -676,4 +675,4 @@ KeyboardUtil.EscapeModifiers = function(next) { }; }; -/* [module] export default KeyboardUtil; */ +export default KeyboardUtil; diff --git a/core/input/xtscancodes.js b/core/input/xtscancodes.js index 542bcf7..611a80b 100644 --- a/core/input/xtscancodes.js +++ b/core/input/xtscancodes.js @@ -148,4 +148,4 @@ var XtScancode = { "MediaSelect": 0xE06D, }; -/* [module] export default XtScancode */ +export default XtScancode diff --git a/core/rfb.js b/core/rfb.js index baf5f3c..caf96cf 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -10,21 +10,20 @@ * (c) 2012 Michael Tinglof, Joe Balaz, Les Piech (Mercuri.ca) */ -/* [module] - * import Util from "./util"; - * import Display from "./display"; - * import { Keyboard, Mouse } from "./input/devices" - * import Websock from "./websock" - * import Base64 from "./base64"; - * import DES from "./des"; - * import KeyTable from "./input/keysym"; - * import XtScancode from "./input/xtscancodes"; - * import Inflator from "./inflator.mod"; - */ +import Util from "./util.js"; +import Display from "./display.js"; +import { Keyboard, Mouse } from "./input/devices.js"; +import Websock from "./websock.js"; +import Base64 from "./base64.js"; +import DES from "./des.js"; +import KeyTable from "./input/keysym.js"; +import XtScancode from "./input/xtscancodes.js"; +import Inflator from "./inflator.mod.js"; + /*jslint white: false, browser: true */ /*global window, Util, Display, Keyboard, Mouse, Websock, Websock_native, Base64, DES, KeyTable, Inflator, XtScancode */ -/* [module] export default */ function RFB(defaults) { +export default function RFB(defaults) { "use strict"; if (!defaults) { defaults = {}; diff --git a/core/util.js b/core/util.js index 550ef91..9f04891 100644 --- a/core/util.js +++ b/core/util.js @@ -618,4 +618,4 @@ Util.releaseCapture = function () { } }; -/* [module] export default Util; */ +export default Util; diff --git a/core/websock.js b/core/websock.js index 51d9b62..7cb0466 100644 --- a/core/websock.js +++ b/core/websock.js @@ -12,14 +12,13 @@ * read binary data off of the receive queue. */ -/* [module] - * import Util from "./util"; - */ +import Util from "./util.js"; + /*jslint browser: true, bitwise: true */ /*global Util*/ -/* [module] export default */ function Websock() { +export default function Websock() { "use strict"; this._websocket = null; // WebSocket object -- 2.39.2