Skip to content

Commit

Permalink
Enable noVNC to become Browserifiable
Browse files Browse the repository at this point in the history
This commit restructures noVNC, splitting it into the core directory
and the app directory, with the former containing core noVNC parts,
and the latter containing parts specific to the application.
  • Loading branch information
DirectXMan12 committed Sep 16, 2016
1 parent 7a16304 commit ae51030
Show file tree
Hide file tree
Showing 66 changed files with 1,754 additions and 1,829 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ tests/data_*.js
utils/rebind.so
utils/websockify
node_modules
build
lib
recordings
21 changes: 21 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
app
core
favicon.ico
.gitmodules
node_modules
.*
*~
*.swp
*.swo
tests
.travis.yml
utils
docs/notes
docs/links
docs/release.txt
docs/rfb_notes
docs/*.pdf
vnc.html
vnc_auto.html
karma.conf.js
docs/flash_policy.txt
46 changes: 20 additions & 26 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ Public License 2.0). The noVNC core library is composed of the
Javascript code necessary for full noVNC operation. This includes (but
is not limited to):

include/base64.js
include/des.js
include/display.js
include/input.js
include/keysym.js
include/logo.js
include/playback.js
include/rfb.js
include/ui.js
include/util.js
include/websock.js
include/webutil.js
include/xtscancodes.js
core/base64.js
core/des.js
core/display.js
core/input.js
core/keysym.js
core/logo.js
core/playback.js
core/rfb.js
app/ui.js
core/util.js
core/websock.js
app/webutil.js
core/xtscancodes.js

The HTML, CSS, font and images files that included with the noVNC
source distibution (or repository) are not considered part of the
Expand All @@ -29,12 +29,12 @@ The HTML, CSS, font and image files are licensed as follows:

*.html : 2-Clause BSD license

include/*.css : 2-Clause BSD license
app/styles/*.css : 2-Clause BSD license

include/Orbitron* : SIL Open Font License 1.1
app/styles/Orbitron* : SIL Open Font License 1.1
(Copyright 2009 Matt McInerney)

images/ : Creative Commons Attribution-ShareAlike
app/images/ : Creative Commons Attribution-ShareAlike
http://creativecommons.org/licenses/by-sa/3.0/

Some portions of noVNC are copyright to their individual authors.
Expand All @@ -45,18 +45,12 @@ The are several files and projects that have been incorporated into
the noVNC core library. Here is a list of those files and the original
licenses (all MPL 2.0 compatible):

include/base64.js : MPL 2.0
core/base64.js : MPL 2.0

include/des.js : Various BSD style licenses
core/des.js : Various BSD style licenses

include/chrome-app/tcp-stream.js
: Apache 2.0 license

utils/websockify
utils/websocket.py : LGPL 3

utils/inflator.partial.js
include/inflator.js : MIT (for pako)
utils/inflator.mod.js
include/inflator.js : MIT (for pako)

Any other files not mentioned above are typically marked with
a copyright/license header at the top of the file. The default noVNC
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion include/base.css → app/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ html {
/* Control bar */
#noVNC_control_bar {
position:fixed;

display:block;
height:36px;
left:0;
Expand Down
File renamed without changes.
File renamed without changes.
376 changes: 196 additions & 180 deletions include/ui.js → app/ui.js

Large diffs are not rendered by default.

23 changes: 6 additions & 17 deletions include/webutil.js → app/webutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,12 @@
/*jslint bitwise: false, white: false, browser: true, devel: true */
/*global Util, window, document */

// Globals defined here
var WebUtil = {}, $D;

/*
* Simple DOM selector by ID
/* [module]
* import Util from "../core/util";
*/
if (!window.$D) {
window.$D = function (id) {
if (document.getElementById) {
return document.getElementById(id);
} else if (document.all) {
return document.all[id];
} else if (document.layers) {
return document.layers[id];
}
return undefined;
};
}

// Globals defined here
var WebUtil = {};

/*
* ------------------------------------------------------
Expand Down Expand Up @@ -290,3 +277,5 @@ WebUtil.injectParamIfMissing = function (path, param, value) {
return elem.pathname + elem.search + elem.hash;
}
};

/* [module] export default WebUtil; */
4 changes: 3 additions & 1 deletion include/base64.js → core/base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var Base64 = {
console.error("Illegal character code " + data.charCodeAt(i) + " at position " + i);
continue;
}

// Collect data into leftdata, update bitcount
leftdata = (leftdata << 6) | c;
leftbits += 6;
Expand All @@ -111,3 +111,5 @@ var Base64 = {
return result;
}
}; /* End of Base64 namespace */

/* [module] export default Base64; */
12 changes: 6 additions & 6 deletions include/des.js → core/des.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
* without fee is hereby granted, provided that this copyright notice is kept
* intact.
*
* without fee is hereby granted, provided that this copyright notice is kept
* intact.
*
* WIDGET WORKSHOP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
* OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WIDGET WORKSHOP SHALL NOT BE LIABLE
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*
*
* THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
* CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
* PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
Expand Down Expand Up @@ -77,7 +77,7 @@

/* jslint white: false */

function DES(passwd) {
/* [module] export default */ function DES(passwd) {
"use strict";

// Tables, permutations, S-boxes, etc.
Expand Down Expand Up @@ -273,4 +273,4 @@ function DES(passwd) {
setKeys(passwd); // Setup keys
return {'encrypt': encrypt}; // Public interface

} // function DES
}; // function DES
146 changes: 75 additions & 71 deletions include/display.js → core/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,97 +10,101 @@
/*jslint browser: true, white: false */
/*global Util, Base64, changeCursor */

var Display;
/* [module]
* import Util from "./util";
* import Base64 from "./base64";
*/

(function () {
"use strict";
/* [module] export default */ function Display(defaults) {
this._drawCtx = null;
this._c_forceCanvas = false;

var SUPPORTS_IMAGEDATA_CONSTRUCTOR = false;
try {
new ImageData(new Uint8ClampedArray(4), 1, 1);
SUPPORTS_IMAGEDATA_CONSTRUCTOR = true;
} catch (ex) {
// ignore failure
}
this._renderQ = []; // queue drawing actions for in-oder rendering

Display = function (defaults) {
this._drawCtx = null;
this._c_forceCanvas = false;
// the full frame buffer (logical canvas) size
this._fb_width = 0;
this._fb_height = 0;

this._renderQ = []; // queue drawing actions for in-oder rendering
// the size limit of the viewport (start disabled)
this._maxWidth = 0;
this._maxHeight = 0;

// the full frame buffer (logical canvas) size
this._fb_width = 0;
this._fb_height = 0;
// the visible "physical canvas" viewport
this._viewportLoc = { 'x': 0, 'y': 0, 'w': 0, 'h': 0 };
this._cleanRect = { 'x1': 0, 'y1': 0, 'x2': -1, 'y2': -1 };

// the size limit of the viewport (start disabled)
this._maxWidth = 0;
this._maxHeight = 0;
this._prevDrawStyle = "";
this._tile = null;
this._tile16x16 = null;
this._tile_x = 0;
this._tile_y = 0;

// the visible "physical canvas" viewport
this._viewportLoc = { 'x': 0, 'y': 0, 'w': 0, 'h': 0 };
this._cleanRect = { 'x1': 0, 'y1': 0, 'x2': -1, 'y2': -1 };
Util.set_defaults(this, defaults, {
'true_color': true,
'colourMap': [],
'scale': 1.0,
'viewport': false,
'render_mode': ''
});

this._prevDrawStyle = "";
this._tile = null;
this._tile16x16 = null;
this._tile_x = 0;
this._tile_y = 0;
Util.Debug(">> Display.constructor");

Util.set_defaults(this, defaults, {
'true_color': true,
'colourMap': [],
'scale': 1.0,
'viewport': false,
'render_mode': ''
});
if (!this._target) {
throw new Error("Target must be set");
}

Util.Debug(">> Display.constructor");
if (typeof this._target === 'string') {
throw new Error('target must be a DOM element');
}

if (!this._target) {
throw new Error("Target must be set");
}
if (!this._target.getContext) {
throw new Error("no getContext method");
}

if (typeof this._target === 'string') {
throw new Error('target must be a DOM element');
}
if (!this._drawCtx) {
this._drawCtx = this._target.getContext('2d');
}

if (!this._target.getContext) {
throw new Error("no getContext method");
}
Util.Debug("User Agent: " + navigator.userAgent);
if (Util.Engine.gecko) { Util.Debug("Browser: gecko " + Util.Engine.gecko); }
if (Util.Engine.webkit) { Util.Debug("Browser: webkit " + Util.Engine.webkit); }
if (Util.Engine.trident) { Util.Debug("Browser: trident " + Util.Engine.trident); }
if (Util.Engine.presto) { Util.Debug("Browser: presto " + Util.Engine.presto); }

if (!this._drawCtx) {
this._drawCtx = this._target.getContext('2d');
}
this.clear();

Util.Debug("User Agent: " + navigator.userAgent);
if (Util.Engine.gecko) { Util.Debug("Browser: gecko " + Util.Engine.gecko); }
if (Util.Engine.webkit) { Util.Debug("Browser: webkit " + Util.Engine.webkit); }
if (Util.Engine.trident) { Util.Debug("Browser: trident " + Util.Engine.trident); }
if (Util.Engine.presto) { Util.Debug("Browser: presto " + Util.Engine.presto); }
// Check canvas features
if ('createImageData' in this._drawCtx) {
this._render_mode = 'canvas rendering';
} else {
throw new Error("Canvas does not support createImageData");
}

this.clear();
if (this._prefer_js === null) {
Util.Info("Prefering javascript operations");
this._prefer_js = true;
}

// Check canvas features
if ('createImageData' in this._drawCtx) {
this._render_mode = 'canvas rendering';
} else {
throw new Error("Canvas does not support createImageData");
}
// Determine browser support for setting the cursor via data URI scheme
if (this._cursor_uri || this._cursor_uri === null ||
this._cursor_uri === undefined) {
this._cursor_uri = Util.browserSupportsCursorURIs();
}

if (this._prefer_js === null) {
Util.Info("Prefering javascript operations");
this._prefer_js = true;
}
Util.Debug("<< Display.constructor");
};

// Determine browser support for setting the cursor via data URI scheme
if (this._cursor_uri || this._cursor_uri === null ||
this._cursor_uri === undefined) {
this._cursor_uri = Util.browserSupportsCursorURIs();
}
(function () {
"use strict";

var SUPPORTS_IMAGEDATA_CONSTRUCTOR = false;
try {
new ImageData(new Uint8ClampedArray(4), 1, 1);
SUPPORTS_IMAGEDATA_CONSTRUCTOR = true;
} catch (ex) {
// ignore failure
}

Util.Debug("<< Display.constructor");
};

Display.prototype = {
// Public methods
Expand Down
Loading

0 comments on commit ae51030

Please sign in to comment.