Enforce indentation
This commit is contained in:
parent
1404984668
commit
7b536961b2
|
@ -24,5 +24,10 @@
|
||||||
// Enforced coding style
|
// Enforced coding style
|
||||||
|
|
||||||
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
||||||
|
"indent": ["error", 4, { "SwitchCase": 1,
|
||||||
|
"CallExpression": { "arguments": "first" },
|
||||||
|
"ArrayExpression": "first",
|
||||||
|
"ObjectExpression": "first",
|
||||||
|
"ignoreComments": true }],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ export class Localizer {
|
||||||
}
|
}
|
||||||
if (elem.hasAttribute("label") &&
|
if (elem.hasAttribute("label") &&
|
||||||
isAnyOf(elem.tagName, ["MENUITEM", "MENU", "OPTGROUP",
|
isAnyOf(elem.tagName, ["MENUITEM", "MENU", "OPTGROUP",
|
||||||
"OPTION", "TRACK"])) {
|
"OPTION", "TRACK"])) {
|
||||||
translateAttribute(elem, "label");
|
translateAttribute(elem, "label");
|
||||||
}
|
}
|
||||||
// FIXME: Should update "lang"
|
// FIXME: Should update "lang"
|
||||||
|
|
|
@ -140,18 +140,18 @@ export default class Keyboard {
|
||||||
// possibly others).
|
// possibly others).
|
||||||
if (browser.isMac()) {
|
if (browser.isMac()) {
|
||||||
switch (keysym) {
|
switch (keysym) {
|
||||||
case KeyTable.XK_Super_L:
|
case KeyTable.XK_Super_L:
|
||||||
keysym = KeyTable.XK_Alt_L;
|
keysym = KeyTable.XK_Alt_L;
|
||||||
break;
|
break;
|
||||||
case KeyTable.XK_Super_R:
|
case KeyTable.XK_Super_R:
|
||||||
keysym = KeyTable.XK_Super_L;
|
keysym = KeyTable.XK_Super_L;
|
||||||
break;
|
break;
|
||||||
case KeyTable.XK_Alt_L:
|
case KeyTable.XK_Alt_L:
|
||||||
keysym = KeyTable.XK_Mode_switch;
|
keysym = KeyTable.XK_Mode_switch;
|
||||||
break;
|
break;
|
||||||
case KeyTable.XK_Alt_R:
|
case KeyTable.XK_Alt_R:
|
||||||
keysym = KeyTable.XK_ISO_Level3_Shift;
|
keysym = KeyTable.XK_ISO_Level3_Shift;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,8 +313,8 @@ export default class Keyboard {
|
||||||
}
|
}
|
||||||
|
|
||||||
const event = new KeyboardEvent('keyup',
|
const event = new KeyboardEvent('keyup',
|
||||||
{ key: downList[code],
|
{ key: downList[code],
|
||||||
code: code });
|
code: code });
|
||||||
target.dispatchEvent(event);
|
target.dispatchEvent(event);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
30
core/rfb.js
30
core/rfb.js
|
@ -166,7 +166,7 @@ export default class RFB extends EventTargetMixin {
|
||||||
this._canvas.tabIndex = -1;
|
this._canvas.tabIndex = -1;
|
||||||
this._screen.appendChild(this._canvas);
|
this._screen.appendChild(this._canvas);
|
||||||
|
|
||||||
this._cursor = new Cursor();
|
this._cursor = new Cursor();
|
||||||
|
|
||||||
// populate encHandlers with bound versions
|
// populate encHandlers with bound versions
|
||||||
this._encHandlers[encodings.encodingRaw] = RFB.encodingHandlers.RAW.bind(this);
|
this._encHandlers[encodings.encodingRaw] = RFB.encodingHandlers.RAW.bind(this);
|
||||||
|
@ -966,7 +966,7 @@ export default class RFB extends EventTargetMixin {
|
||||||
this.dispatchEvent(new CustomEvent(
|
this.dispatchEvent(new CustomEvent(
|
||||||
"credentialsrequired",
|
"credentialsrequired",
|
||||||
{ detail: { types: ["username", "password", "target"] } }));
|
{ detail: { types: ["username", "password", "target"] } }));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const xvp_auth_str = String.fromCharCode(this._rfb_credentials.username.length) +
|
const xvp_auth_str = String.fromCharCode(this._rfb_credentials.username.length) +
|
||||||
|
@ -1938,7 +1938,7 @@ RFB.encodingHandlers = {
|
||||||
if (this._sock.rQwait("RAW", this._FBU.bytes)) { return false; }
|
if (this._sock.rQwait("RAW", this._FBU.bytes)) { return false; }
|
||||||
const cur_y = this._FBU.y + (this._FBU.height - this._FBU.lines);
|
const cur_y = this._FBU.y + (this._FBU.height - this._FBU.lines);
|
||||||
const curr_height = Math.min(this._FBU.lines,
|
const curr_height = Math.min(this._FBU.lines,
|
||||||
Math.floor(this._sock.rQlen() / (this._FBU.width * pixelSize)));
|
Math.floor(this._sock.rQlen() / (this._FBU.width * pixelSize)));
|
||||||
let data = this._sock.get_rQ();
|
let data = this._sock.get_rQ();
|
||||||
let index = this._sock.get_rQi();
|
let index = this._sock.get_rQi();
|
||||||
if (this._fb_depth == 8) {
|
if (this._fb_depth == 8) {
|
||||||
|
@ -2488,18 +2488,18 @@ RFB.encodingHandlers = {
|
||||||
let msg = "";
|
let msg = "";
|
||||||
// The y-position indicates the status code from the server
|
// The y-position indicates the status code from the server
|
||||||
switch (this._FBU.y) {
|
switch (this._FBU.y) {
|
||||||
case 1:
|
case 1:
|
||||||
msg = "Resize is administratively prohibited";
|
msg = "Resize is administratively prohibited";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
msg = "Out of resources";
|
msg = "Out of resources";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
msg = "Invalid screen layout";
|
msg = "Invalid screen layout";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
msg = "Unknown reason";
|
msg = "Unknown reason";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Log.Warn("Server did not accept the resize request: "
|
Log.Warn("Server did not accept the resize request: "
|
||||||
+ msg);
|
+ msg);
|
||||||
|
|
|
@ -11,30 +11,30 @@ export default class EventTargetMixin {
|
||||||
this._listeners = null;
|
this._listeners = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
addEventListener(type, callback) {
|
addEventListener(type, callback) {
|
||||||
if (!this._listeners) {
|
if (!this._listeners) {
|
||||||
this._listeners = new Map();
|
this._listeners = new Map();
|
||||||
}
|
}
|
||||||
if (!this._listeners.has(type)) {
|
if (!this._listeners.has(type)) {
|
||||||
this._listeners.set(type, new Set());
|
this._listeners.set(type, new Set());
|
||||||
}
|
}
|
||||||
this._listeners.get(type).add(callback);
|
this._listeners.get(type).add(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeEventListener(type, callback) {
|
removeEventListener(type, callback) {
|
||||||
if (!this._listeners || !this._listeners.has(type)) {
|
if (!this._listeners || !this._listeners.has(type)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._listeners.get(type).delete(callback);
|
this._listeners.get(type).delete(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatchEvent(event) {
|
dispatchEvent(event) {
|
||||||
if (!this._listeners || !this._listeners.has(event.type)) {
|
if (!this._listeners || !this._listeners.has(event.type)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this._listeners.get(event.type).forEach((callback) => {
|
this._listeners.get(event.type).forEach((callback) => {
|
||||||
callback.call(this, event);
|
callback.call(this, event);
|
||||||
}, this);
|
}, this);
|
||||||
return !event.defaultPrevented;
|
return !event.defaultPrevented;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,17 +20,17 @@ chai.use(function (_chai, utils) {
|
||||||
console.log("expected data: %o, actual data: %o", target_data, data);
|
console.log("expected data: %o, actual data: %o", target_data, data);
|
||||||
}
|
}
|
||||||
this.assert(same,
|
this.assert(same,
|
||||||
"expected #{this} to have displayed the image #{exp}, but instead it displayed #{act}",
|
"expected #{this} to have displayed the image #{exp}, but instead it displayed #{act}",
|
||||||
"expected #{this} not to have displayed the image #{act}",
|
"expected #{this} not to have displayed the image #{act}",
|
||||||
target_data,
|
target_data,
|
||||||
data);
|
data);
|
||||||
});
|
});
|
||||||
|
|
||||||
_chai.Assertion.addMethod('sent', function (target_data) {
|
_chai.Assertion.addMethod('sent', function (target_data) {
|
||||||
const obj = this._obj;
|
const obj = this._obj;
|
||||||
obj.inspect = () => {
|
obj.inspect = () => {
|
||||||
const res = { _websocket: obj._websocket, rQi: obj._rQi, _rQ: new Uint8Array(obj._rQ.buffer, 0, obj._rQlen),
|
const res = { _websocket: obj._websocket, rQi: obj._rQi, _rQ: new Uint8Array(obj._rQ.buffer, 0, obj._rQlen),
|
||||||
_sQ: new Uint8Array(obj._sQ.buffer, 0, obj._sQlen) };
|
_sQ: new Uint8Array(obj._sQ.buffer, 0, obj._sQlen) };
|
||||||
res.prototype = obj;
|
res.prototype = obj;
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
@ -51,10 +51,10 @@ chai.use(function (_chai, utils) {
|
||||||
console.log("expected data: %o, actual data: %o", target_data, data);
|
console.log("expected data: %o, actual data: %o", target_data, data);
|
||||||
}
|
}
|
||||||
this.assert(same,
|
this.assert(same,
|
||||||
"expected #{this} to have sent the data #{exp}, but it actually sent #{act}",
|
"expected #{this} to have sent the data #{exp}, but it actually sent #{act}",
|
||||||
"expected #{this} not to have sent the data #{act}",
|
"expected #{this} not to have sent the data #{act}",
|
||||||
Array.prototype.slice.call(target_data),
|
Array.prototype.slice.call(target_data),
|
||||||
Array.prototype.slice.call(data));
|
Array.prototype.slice.call(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
_chai.Assertion.addProperty('array', function () {
|
_chai.Assertion.addProperty('array', function () {
|
||||||
|
@ -77,9 +77,9 @@ chai.use(function (_chai, utils) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.assert(same,
|
this.assert(same,
|
||||||
"expected #{this} to have elements deeply equal to #{exp}",
|
"expected #{this} to have elements deeply equal to #{exp}",
|
||||||
"expected #{this} not to have elements deeply equal to #{exp}",
|
"expected #{this} not to have elements deeply equal to #{exp}",
|
||||||
Array.prototype.slice.call(target));
|
Array.prototype.slice.call(target));
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < obj.length; i++) {
|
for (let i = 0; i < obj.length; i++) {
|
||||||
if (obj[i] != target[i]) {
|
if (obj[i] != target[i]) {
|
||||||
|
@ -89,9 +89,9 @@ chai.use(function (_chai, utils) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.assert(same,
|
this.assert(same,
|
||||||
"expected #{this} to have elements equal to #{exp}",
|
"expected #{this} to have elements equal to #{exp}",
|
||||||
"expected #{this} not to have elements equal to #{exp}",
|
"expected #{this} not to have elements equal to #{exp}",
|
||||||
Array.prototype.slice.call(target));
|
Array.prototype.slice.call(target));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_super.apply(this, arguments);
|
_super.apply(this, arguments);
|
||||||
|
|
|
@ -51,8 +51,8 @@ export default class RecordingPlayer {
|
||||||
this._disconnected = disconnected;
|
this._disconnected = disconnected;
|
||||||
|
|
||||||
if (this._encoding === undefined) {
|
if (this._encoding === undefined) {
|
||||||
const frame = this._frames[0];
|
const frame = this._frames[0];
|
||||||
const start = frame.indexOf('{', 1) + 1;
|
const start = frame.indexOf('{', 1) + 1;
|
||||||
if (frame.slice(start).startsWith('UkZC')) {
|
if (frame.slice(start).startsWith('UkZC')) {
|
||||||
this._encoding = 'base64';
|
this._encoding = 'base64';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,7 +11,7 @@ describe('Helpers', function() {
|
||||||
it('should map ASCII characters to keysyms', function() {
|
it('should map ASCII characters to keysyms', function() {
|
||||||
expect(keysyms.lookup('a'.charCodeAt())).to.be.equal(0x61);
|
expect(keysyms.lookup('a'.charCodeAt())).to.be.equal(0x61);
|
||||||
expect(keysyms.lookup('A'.charCodeAt())).to.be.equal(0x41);
|
expect(keysyms.lookup('A'.charCodeAt())).to.be.equal(0x41);
|
||||||
});
|
});
|
||||||
it('should map Latin-1 characters to keysyms', function() {
|
it('should map Latin-1 characters to keysyms', function() {
|
||||||
expect(keysyms.lookup('ø'.charCodeAt())).to.be.equal(0xf8);
|
expect(keysyms.lookup('ø'.charCodeAt())).to.be.equal(0xf8);
|
||||||
|
|
||||||
|
|
|
@ -30,15 +30,15 @@ function push8(arr, num) {
|
||||||
function push16(arr, num) {
|
function push16(arr, num) {
|
||||||
"use strict";
|
"use strict";
|
||||||
arr.push((num >> 8) & 0xFF,
|
arr.push((num >> 8) & 0xFF,
|
||||||
num & 0xFF);
|
num & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
function push32(arr, num) {
|
function push32(arr, num) {
|
||||||
"use strict";
|
"use strict";
|
||||||
arr.push((num >> 24) & 0xFF,
|
arr.push((num >> 24) & 0xFF,
|
||||||
(num >> 16) & 0xFF,
|
(num >> 16) & 0xFF,
|
||||||
(num >> 8) & 0xFF,
|
(num >> 8) & 0xFF,
|
||||||
num & 0xFF);
|
num & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Remote Frame Buffer Protocol Client', function() {
|
describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
|
@ -286,7 +286,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
describe('#clipboardPasteFrom', function () {
|
describe('#clipboardPasteFrom', function () {
|
||||||
it('should send the given text in a paste event', function () {
|
it('should send the given text in a paste event', function () {
|
||||||
const expected = {_sQ: new Uint8Array(11), _sQlen: 0,
|
const expected = {_sQ: new Uint8Array(11), _sQlen: 0,
|
||||||
_sQbufferSize: 11, flush: () => {}};
|
_sQbufferSize: 11, flush: () => {}};
|
||||||
RFB.messages.clientCutText(expected, 'abc');
|
RFB.messages.clientCutText(expected, 'abc');
|
||||||
client.clipboardPasteFrom('abc');
|
client.clipboardPasteFrom('abc');
|
||||||
expect(client._sock).to.have.sent(expected._sQ);
|
expect(client._sock).to.have.sent(expected._sQ);
|
||||||
|
@ -376,10 +376,10 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
it('should update the viewport when the remote session resizes', function () {
|
it('should update the viewport when the remote session resizes', function () {
|
||||||
// Simple ExtendedDesktopSize FBU message
|
// Simple ExtendedDesktopSize FBU message
|
||||||
const incoming = [ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
const incoming = [ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xfe, 0xcc,
|
0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xfe, 0xcc,
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
|
||||||
0x00, 0x00, 0x00, 0x00 ];
|
0x00, 0x00, 0x00, 0x00 ];
|
||||||
|
|
||||||
sinon.spy(client._display, "viewportChangeSize");
|
sinon.spy(client._display, "viewportChangeSize");
|
||||||
|
|
||||||
|
@ -566,10 +566,10 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
it('should update the scaling when the remote session resizes', function () {
|
it('should update the scaling when the remote session resizes', function () {
|
||||||
// Simple ExtendedDesktopSize FBU message
|
// Simple ExtendedDesktopSize FBU message
|
||||||
const incoming = [ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
const incoming = [ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xfe, 0xcc,
|
0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xfe, 0xcc,
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
|
||||||
0x00, 0x00, 0x00, 0x00 ];
|
0x00, 0x00, 0x00, 0x00 ];
|
||||||
|
|
||||||
sinon.spy(client._display, "autoscale");
|
sinon.spy(client._display, "autoscale");
|
||||||
|
|
||||||
|
@ -619,10 +619,10 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
it('should request a resize when initially connecting', function () {
|
it('should request a resize when initially connecting', function () {
|
||||||
// Simple ExtendedDesktopSize FBU message
|
// Simple ExtendedDesktopSize FBU message
|
||||||
const incoming = [ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
const incoming = [ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x04, 0x00, 0x04, 0xff, 0xff, 0xfe, 0xcc,
|
0x00, 0x04, 0x00, 0x04, 0xff, 0xff, 0xfe, 0xcc,
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04,
|
||||||
0x00, 0x00, 0x00, 0x00 ];
|
0x00, 0x00, 0x00, 0x00 ];
|
||||||
|
|
||||||
// First message should trigger a resize
|
// First message should trigger a resize
|
||||||
|
|
||||||
|
@ -715,10 +715,10 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
it('should not try to override a server resize', function () {
|
it('should not try to override a server resize', function () {
|
||||||
// Simple ExtendedDesktopSize FBU message
|
// Simple ExtendedDesktopSize FBU message
|
||||||
const incoming = [ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
const incoming = [ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x04, 0x00, 0x04, 0xff, 0xff, 0xfe, 0xcc,
|
0x00, 0x04, 0x00, 0x04, 0xff, 0xff, 0xfe, 0xcc,
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04,
|
||||||
0x00, 0x00, 0x00, 0x00 ];
|
0x00, 0x00, 0x00, 0x00 ];
|
||||||
|
|
||||||
client._sock._websocket._receive_data(new Uint8Array(incoming));
|
client._sock._websocket._receive_data(new Uint8Array(incoming));
|
||||||
|
|
||||||
|
@ -827,7 +827,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
describe('connecting', function () {
|
describe('connecting', function () {
|
||||||
it('should open the websocket connection', function () {
|
it('should open the websocket connection', function () {
|
||||||
const client = new RFB(document.createElement('div'),
|
const client = new RFB(document.createElement('div'),
|
||||||
'ws://HOST:8675/PATH');
|
'ws://HOST:8675/PATH');
|
||||||
sinon.spy(client._sock, 'open');
|
sinon.spy(client._sock, 'open');
|
||||||
this.clock.tick();
|
this.clock.tick();
|
||||||
expect(client._sock.open).to.have.been.calledOnce;
|
expect(client._sock.open).to.have.been.calledOnce;
|
||||||
|
@ -1357,7 +1357,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
const spy = sinon.spy();
|
const spy = sinon.spy();
|
||||||
client.addEventListener("securityfailure", spy);
|
client.addEventListener("securityfailure", spy);
|
||||||
const failure_data = [0, 0, 0, 1, 0, 0, 0, 12, 115, 117, 99, 104,
|
const failure_data = [0, 0, 0, 1, 0, 0, 0, 12, 115, 117, 99, 104,
|
||||||
32, 102, 97, 105, 108, 117, 114, 101];
|
32, 102, 97, 105, 108, 117, 114, 101];
|
||||||
client._sock._websocket._receive_data(new Uint8Array(failure_data));
|
client._sock._websocket._receive_data(new Uint8Array(failure_data));
|
||||||
expect(spy.args[0][0].detail.status).to.equal(1);
|
expect(spy.args[0][0].detail.status).to.equal(1);
|
||||||
expect(spy.args[0][0].detail.reason).to.equal('such failure');
|
expect(spy.args[0][0].detail.reason).to.equal('such failure');
|
||||||
|
@ -1416,8 +1416,8 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
|
|
||||||
function send_server_init(opts, client) {
|
function send_server_init(opts, client) {
|
||||||
const full_opts = { width: 10, height: 12, bpp: 24, depth: 24, big_endian: 0,
|
const full_opts = { width: 10, height: 12, bpp: 24, depth: 24, big_endian: 0,
|
||||||
true_color: 1, red_max: 255, green_max: 255, blue_max: 255,
|
true_color: 1, red_max: 255, green_max: 255, blue_max: 255,
|
||||||
red_shift: 16, green_shift: 8, blue_shift: 0, name: 'a name' };
|
red_shift: 16, green_shift: 8, blue_shift: 0, name: 'a name' };
|
||||||
for (let opt in opts) {
|
for (let opt in opts) {
|
||||||
full_opts[opt] = opts[opt];
|
full_opts[opt] = opts[opt];
|
||||||
}
|
}
|
||||||
|
@ -1664,7 +1664,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
client._display.blitRgbxImage(0, 0, 4, 2, new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
|
client._display.blitRgbxImage(0, 0, 4, 2, new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
|
||||||
|
|
||||||
const info = [{ x: 0, y: 2, width: 2, height: 2, encoding: 0x01},
|
const info = [{ x: 0, y: 2, width: 2, height: 2, encoding: 0x01},
|
||||||
{ x: 2, y: 2, width: 2, height: 2, encoding: 0x01}];
|
{ x: 2, y: 2, width: 2, height: 2, encoding: 0x01}];
|
||||||
// data says [{ old_x: 2, old_y: 0 }, { old_x: 0, old_y: 0 }]
|
// data says [{ old_x: 2, old_y: 0 }, { old_x: 0, old_y: 0 }]
|
||||||
const rects = [[0, 2, 0, 0], [0, 0, 0, 0]];
|
const rects = [[0, 2, 0, 0], [0, 0, 0, 0]];
|
||||||
send_fbu_msg([info[0]], [rects[0]], client, 2);
|
send_fbu_msg([info[0]], [rects[0]], client, 2);
|
||||||
|
@ -1683,9 +1683,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
|
|
||||||
it('should handle the RAW encoding', function () {
|
it('should handle the RAW encoding', function () {
|
||||||
const info = [{ x: 0, y: 0, width: 2, height: 2, encoding: 0x00 },
|
const info = [{ x: 0, y: 0, width: 2, height: 2, encoding: 0x00 },
|
||||||
{ x: 2, y: 0, width: 2, height: 2, encoding: 0x00 },
|
{ x: 2, y: 0, width: 2, height: 2, encoding: 0x00 },
|
||||||
{ x: 0, y: 2, width: 4, height: 1, encoding: 0x00 },
|
{ x: 0, y: 2, width: 4, height: 1, encoding: 0x00 },
|
||||||
{ x: 0, y: 3, width: 4, height: 1, encoding: 0x00 }];
|
{ x: 0, y: 3, width: 4, height: 1, encoding: 0x00 }];
|
||||||
// data is in bgrx
|
// data is in bgrx
|
||||||
const rects = [
|
const rects = [
|
||||||
[0x00, 0x00, 0xff, 0, 0x00, 0xff, 0x00, 0, 0x00, 0xff, 0x00, 0, 0x00, 0x00, 0xff, 0],
|
[0x00, 0x00, 0xff, 0, 0x00, 0xff, 0x00, 0, 0x00, 0xff, 0x00, 0, 0x00, 0x00, 0xff, 0],
|
||||||
|
@ -1698,9 +1698,9 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
|
|
||||||
it('should handle the RAW encoding in low colour mode', function () {
|
it('should handle the RAW encoding in low colour mode', function () {
|
||||||
const info = [{ x: 0, y: 0, width: 2, height: 2, encoding: 0x00 },
|
const info = [{ x: 0, y: 0, width: 2, height: 2, encoding: 0x00 },
|
||||||
{ x: 2, y: 0, width: 2, height: 2, encoding: 0x00 },
|
{ x: 2, y: 0, width: 2, height: 2, encoding: 0x00 },
|
||||||
{ x: 0, y: 2, width: 4, height: 1, encoding: 0x00 },
|
{ x: 0, y: 2, width: 4, height: 1, encoding: 0x00 },
|
||||||
{ x: 0, y: 3, width: 4, height: 1, encoding: 0x00 }];
|
{ x: 0, y: 3, width: 4, height: 1, encoding: 0x00 }];
|
||||||
const rects = [
|
const rects = [
|
||||||
[0x03, 0x03, 0x03, 0x03],
|
[0x03, 0x03, 0x03, 0x03],
|
||||||
[0x0c, 0x0c, 0x0c, 0x0c],
|
[0x0c, 0x0c, 0x0c, 0x0c],
|
||||||
|
@ -1716,7 +1716,7 @@ describe('Remote Frame Buffer Protocol Client', function() {
|
||||||
client._display.blitRgbxImage(0, 0, 4, 2, new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
|
client._display.blitRgbxImage(0, 0, 4, 2, new Uint8Array(target_data_check_arr.slice(0, 32)), 0);
|
||||||
|
|
||||||
const info = [{ x: 0, y: 2, width: 2, height: 2, encoding: 0x01},
|
const info = [{ x: 0, y: 2, width: 2, height: 2, encoding: 0x01},
|
||||||
{ x: 2, y: 2, width: 2, height: 2, encoding: 0x01}];
|
{ x: 2, y: 2, width: 2, height: 2, encoding: 0x01}];
|
||||||
// data says [{ old_x: 0, old_y: 0 }, { old_x: 0, old_y: 0 }]
|
// data says [{ old_x: 0, old_y: 0 }, { old_x: 0, old_y: 0 }]
|
||||||
const rects = [[0, 2, 0, 0], [0, 0, 0, 0]];
|
const rects = [[0, 2, 0, 0], [0, 0, 0, 0]];
|
||||||
send_fbu_msg(info, rects, client);
|
send_fbu_msg(info, rects, client);
|
||||||
|
|
|
@ -19,9 +19,9 @@ describe('Websock', function() {
|
||||||
});
|
});
|
||||||
describe('rQlen', function () {
|
describe('rQlen', function () {
|
||||||
it('should return the length of the receive queue', function () {
|
it('should return the length of the receive queue', function () {
|
||||||
sock.set_rQi(0);
|
sock.set_rQi(0);
|
||||||
|
|
||||||
expect(sock.rQlen()).to.equal(RQ_TEMPLATE.length);
|
expect(sock.rQlen()).to.equal(RQ_TEMPLATE.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return the proper length if we read some from the receive queue", function () {
|
it("should return the proper length if we read some from the receive queue", function () {
|
||||||
|
@ -247,7 +247,7 @@ describe('Websock', function() {
|
||||||
describe('lifecycle methods', function () {
|
describe('lifecycle methods', function () {
|
||||||
let old_WS;
|
let old_WS;
|
||||||
before(function () {
|
before(function () {
|
||||||
old_WS = WebSocket;
|
old_WS = WebSocket;
|
||||||
});
|
});
|
||||||
|
|
||||||
let sock;
|
let sock;
|
||||||
|
@ -357,8 +357,8 @@ describe('Websock', function() {
|
||||||
describe('WebSocket Receiving', function () {
|
describe('WebSocket Receiving', function () {
|
||||||
let sock;
|
let sock;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
sock = new Websock();
|
sock = new Websock();
|
||||||
sock._allocate_buffers();
|
sock._allocate_buffers();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support adding binary Uint8Array data to the receive queue', function () {
|
it('should support adding binary Uint8Array data to the receive queue', function () {
|
||||||
|
|
|
@ -14,29 +14,29 @@ let show_help = process.argv.length === 2;
|
||||||
let filename;
|
let filename;
|
||||||
|
|
||||||
for (let i = 2; i < process.argv.length; ++i) {
|
for (let i = 2; i < process.argv.length; ++i) {
|
||||||
switch (process.argv[i]) {
|
switch (process.argv[i]) {
|
||||||
case "--help":
|
case "--help":
|
||||||
case "-h":
|
case "-h":
|
||||||
show_help = true;
|
show_help = true;
|
||||||
break;
|
break;
|
||||||
case "--file":
|
case "--file":
|
||||||
case "-f":
|
case "-f":
|
||||||
default:
|
default:
|
||||||
filename = process.argv[i];
|
filename = process.argv[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filename) {
|
if (!filename) {
|
||||||
show_help = true;
|
show_help = true;
|
||||||
console.log("Error: No filename specified\n");
|
console.log("Error: No filename specified\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_help) {
|
if (show_help) {
|
||||||
console.log("Parses a *nix keysymdef.h to generate Unicode code point mappings");
|
console.log("Parses a *nix keysymdef.h to generate Unicode code point mappings");
|
||||||
console.log("Usage: node parse.js [options] filename:");
|
console.log("Usage: node parse.js [options] filename:");
|
||||||
console.log(" -h [ --help ] Produce this help message");
|
console.log(" -h [ --help ] Produce this help message");
|
||||||
console.log(" filename The keysymdef.h file to parse");
|
console.log(" filename The keysymdef.h file to parse");
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const buf = fs.readFileSync(filename);
|
const buf = fs.readFileSync(filename);
|
||||||
|
|
|
@ -71,17 +71,17 @@ const babelTransformFile = promisify(babel.transformFile);
|
||||||
// calling the callback for all normal files found.
|
// calling the callback for all normal files found.
|
||||||
function walkDir(base_path, cb, filter) {
|
function walkDir(base_path, cb, filter) {
|
||||||
return readdir(base_path)
|
return readdir(base_path)
|
||||||
.then((files) => {
|
.then((files) => {
|
||||||
const paths = files.map(filename => path.join(base_path, filename));
|
const paths = files.map(filename => path.join(base_path, filename));
|
||||||
return Promise.all(paths.map(filepath => lstat(filepath)
|
return Promise.all(paths.map(filepath => lstat(filepath)
|
||||||
.then((stats) => {
|
.then((stats) => {
|
||||||
if (filter !== undefined && !filter(filepath, stats)) return;
|
if (filter !== undefined && !filter(filepath, stats)) return;
|
||||||
|
|
||||||
if (stats.isSymbolicLink()) return;
|
if (stats.isSymbolicLink()) return;
|
||||||
if (stats.isFile()) return cb(filepath);
|
if (stats.isFile()) return cb(filepath);
|
||||||
if (stats.isDirectory()) return walkDir(filepath, cb, filter);
|
if (stats.isDirectory()) return walkDir(filepath, cb, filter);
|
||||||
})));
|
})));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function transform_html (legacy_scripts, only_legacy) {
|
function transform_html (legacy_scripts, only_legacy) {
|
||||||
|
@ -89,25 +89,25 @@ function transform_html (legacy_scripts, only_legacy) {
|
||||||
const src_html_path = path.resolve(__dirname, '..', 'vnc.html');
|
const src_html_path = path.resolve(__dirname, '..', 'vnc.html');
|
||||||
const out_html_path = path.resolve(paths.out_dir_base, 'vnc.html');
|
const out_html_path = path.resolve(paths.out_dir_base, 'vnc.html');
|
||||||
return readFile(src_html_path)
|
return readFile(src_html_path)
|
||||||
.then((contents_raw) => {
|
.then((contents_raw) => {
|
||||||
let contents = contents_raw.toString();
|
let contents = contents_raw.toString();
|
||||||
|
|
||||||
const start_marker = '<!-- begin scripts -->\n';
|
const start_marker = '<!-- begin scripts -->\n';
|
||||||
const end_marker = '<!-- end scripts -->';
|
const end_marker = '<!-- end scripts -->';
|
||||||
const start_ind = contents.indexOf(start_marker) + start_marker.length;
|
const start_ind = contents.indexOf(start_marker) + start_marker.length;
|
||||||
const end_ind = contents.indexOf(end_marker, start_ind);
|
const end_ind = contents.indexOf(end_marker, start_ind);
|
||||||
|
|
||||||
let new_script = '';
|
let new_script = '';
|
||||||
|
|
||||||
if (only_legacy) {
|
if (only_legacy) {
|
||||||
// Only legacy version, so include things directly
|
// Only legacy version, so include things directly
|
||||||
for (let i = 0;i < legacy_scripts.length;i++) {
|
for (let i = 0;i < legacy_scripts.length;i++) {
|
||||||
new_script += ` <script src="${legacy_scripts[i]}"></script>\n`;
|
new_script += ` <script src="${legacy_scripts[i]}"></script>\n`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Otherwise detect if it's a modern browser and select
|
// Otherwise detect if it's a modern browser and select
|
||||||
// variant accordingly
|
// variant accordingly
|
||||||
new_script += `\
|
new_script += `\
|
||||||
<script type="module">\n\
|
<script type="module">\n\
|
||||||
window._noVNC_has_module_support = true;\n\
|
window._noVNC_has_module_support = true;\n\
|
||||||
</script>\n\
|
</script>\n\
|
||||||
|
@ -125,17 +125,17 @@ function transform_html (legacy_scripts, only_legacy) {
|
||||||
</script>\n`;
|
</script>\n`;
|
||||||
|
|
||||||
// Original, ES6 modules
|
// Original, ES6 modules
|
||||||
new_script += ' <script type="module" crossorigin="anonymous" src="app/ui.js"></script>\n';
|
new_script += ' <script type="module" crossorigin="anonymous" src="app/ui.js"></script>\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
contents = contents.slice(0, start_ind) + `${new_script}\n` + contents.slice(end_ind);
|
contents = contents.slice(0, start_ind) + `${new_script}\n` + contents.slice(end_ind);
|
||||||
|
|
||||||
return contents;
|
return contents;
|
||||||
})
|
})
|
||||||
.then((contents) => {
|
.then((contents) => {
|
||||||
console.log(`Writing ${out_html_path}`);
|
console.log(`Writing ${out_html_path}`);
|
||||||
return writeFile(out_html_path, contents);
|
return writeFile(out_html_path, contents);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_lib_files(import_format, source_maps, with_app_dir, only_legacy) {
|
function make_lib_files(import_format, source_maps, with_app_dir, only_legacy) {
|
||||||
|
@ -176,130 +176,130 @@ function make_lib_files(import_format, source_maps, with_app_dir, only_legacy) {
|
||||||
const outFiles = [];
|
const outFiles = [];
|
||||||
|
|
||||||
const handleDir = (js_only, vendor_rewrite, in_path_base, filename) => Promise.resolve()
|
const handleDir = (js_only, vendor_rewrite, in_path_base, filename) => Promise.resolve()
|
||||||
.then(() => {
|
|
||||||
if (no_copy_files.has(filename)) return;
|
|
||||||
|
|
||||||
const out_path = path.join(out_path_base, path.relative(in_path_base, filename));
|
|
||||||
const legacy_path = path.join(legacy_path_base, path.relative(in_path_base, filename));
|
|
||||||
|
|
||||||
if(path.extname(filename) !== '.js') {
|
|
||||||
if (!js_only) {
|
|
||||||
console.log(`Writing ${out_path}`);
|
|
||||||
return copy(filename, out_path);
|
|
||||||
}
|
|
||||||
return; // skip non-javascript files
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.resolve()
|
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (only_legacy && !no_transform_files.has(filename)) {
|
if (no_copy_files.has(filename)) return;
|
||||||
return;
|
|
||||||
}
|
const out_path = path.join(out_path_base, path.relative(in_path_base, filename));
|
||||||
return ensureDir(path.dirname(out_path))
|
const legacy_path = path.join(legacy_path_base, path.relative(in_path_base, filename));
|
||||||
.then(() => {
|
|
||||||
console.log(`Writing ${out_path}`);
|
if(path.extname(filename) !== '.js') {
|
||||||
return copy(filename, out_path);
|
if (!js_only) {
|
||||||
})
|
console.log(`Writing ${out_path}`);
|
||||||
})
|
return copy(filename, out_path);
|
||||||
.then(() => ensureDir(path.dirname(legacy_path)))
|
}
|
||||||
.then(() => {
|
return; // skip non-javascript files
|
||||||
if (no_transform_files.has(filename)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const opts = babel_opts();
|
return Promise.resolve()
|
||||||
if (helper && helpers.optionsOverride) {
|
.then(() => {
|
||||||
helper.optionsOverride(opts);
|
if (only_legacy && !no_transform_files.has(filename)) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
return ensureDir(path.dirname(out_path))
|
||||||
|
.then(() => {
|
||||||
|
console.log(`Writing ${out_path}`);
|
||||||
|
return copy(filename, out_path);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.then(() => ensureDir(path.dirname(legacy_path)))
|
||||||
|
.then(() => {
|
||||||
|
if (no_transform_files.has(filename)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const opts = babel_opts();
|
||||||
|
if (helper && helpers.optionsOverride) {
|
||||||
|
helper.optionsOverride(opts);
|
||||||
|
}
|
||||||
// Adjust for the fact that we move the core files relative
|
// Adjust for the fact that we move the core files relative
|
||||||
// to the vendor directory
|
// to the vendor directory
|
||||||
if (vendor_rewrite) {
|
if (vendor_rewrite) {
|
||||||
opts.plugins.push(["import-redirect",
|
opts.plugins.push(["import-redirect",
|
||||||
{"root": legacy_path_base,
|
{"root": legacy_path_base,
|
||||||
"redirect": { "vendor/(.+)": "./vendor/$1"}}]);
|
"redirect": { "vendor/(.+)": "./vendor/$1"}}]);
|
||||||
}
|
|
||||||
|
|
||||||
return babelTransformFile(filename, opts)
|
|
||||||
.then((res) => {
|
|
||||||
console.log(`Writing ${legacy_path}`);
|
|
||||||
const {map} = res;
|
|
||||||
let {code} = res;
|
|
||||||
if (source_maps === true) {
|
|
||||||
// append URL for external source map
|
|
||||||
code += `\n//# sourceMappingURL=${path.basename(legacy_path)}.map\n`;
|
|
||||||
}
|
|
||||||
outFiles.push(`${legacy_path}`);
|
|
||||||
return writeFile(legacy_path, code)
|
|
||||||
.then(() => {
|
|
||||||
if (source_maps === true || source_maps === 'both') {
|
|
||||||
console.log(` and ${legacy_path}.map`);
|
|
||||||
outFiles.push(`${legacy_path}.map`);
|
|
||||||
return writeFile(`${legacy_path}.map`, JSON.stringify(map));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return babelTransformFile(filename, opts)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(`Writing ${legacy_path}`);
|
||||||
|
const {map} = res;
|
||||||
|
let {code} = res;
|
||||||
|
if (source_maps === true) {
|
||||||
|
// append URL for external source map
|
||||||
|
code += `\n//# sourceMappingURL=${path.basename(legacy_path)}.map\n`;
|
||||||
|
}
|
||||||
|
outFiles.push(`${legacy_path}`);
|
||||||
|
return writeFile(legacy_path, code)
|
||||||
|
.then(() => {
|
||||||
|
if (source_maps === true || source_maps === 'both') {
|
||||||
|
console.log(` and ${legacy_path}.map`);
|
||||||
|
outFiles.push(`${legacy_path}.map`);
|
||||||
|
return writeFile(`${legacy_path}.map`, JSON.stringify(map));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (with_app_dir && helper && helper.noCopyOverride) {
|
if (with_app_dir && helper && helper.noCopyOverride) {
|
||||||
helper.noCopyOverride(paths, no_copy_files);
|
helper.noCopyOverride(paths, no_copy_files);
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.resolve()
|
Promise.resolve()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const handler = handleDir.bind(null, true, false, in_path || paths.main);
|
const handler = handleDir.bind(null, true, false, in_path || paths.main);
|
||||||
const filter = (filename, stats) => !no_copy_files.has(filename);
|
const filter = (filename, stats) => !no_copy_files.has(filename);
|
||||||
return walkDir(paths.vendor, handler, filter);
|
return walkDir(paths.vendor, handler, filter);
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
const handler = handleDir.bind(null, true, !in_path, in_path || paths.core);
|
|
||||||
const filter = (filename, stats) => !no_copy_files.has(filename);
|
|
||||||
return walkDir(paths.core, handler, filter);
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
if (!with_app_dir) return;
|
|
||||||
const handler = handleDir.bind(null, false, false, in_path);
|
|
||||||
const filter = (filename, stats) => !no_copy_files.has(filename);
|
|
||||||
return walkDir(paths.app, handler, filter);
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
if (!with_app_dir) return;
|
|
||||||
|
|
||||||
if (!helper || !helper.appWriter) {
|
|
||||||
throw new Error(`Unable to generate app for the ${import_format} format!`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const out_app_path = path.join(legacy_path_base, 'app.js');
|
|
||||||
console.log(`Writing ${out_app_path}`);
|
|
||||||
return helper.appWriter(out_path_base, legacy_path_base, out_app_path)
|
|
||||||
.then((extra_scripts) => {
|
|
||||||
const rel_app_path = path.relative(out_path_base, out_app_path);
|
|
||||||
const legacy_scripts = extra_scripts.concat([rel_app_path]);
|
|
||||||
transform_html(legacy_scripts, only_legacy);
|
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (!helper.removeModules) return;
|
const handler = handleDir.bind(null, true, !in_path, in_path || paths.core);
|
||||||
console.log(`Cleaning up temporary files...`);
|
const filter = (filename, stats) => !no_copy_files.has(filename);
|
||||||
return Promise.all(outFiles.map((filepath) => {
|
return walkDir(paths.core, handler, filter);
|
||||||
unlink(filepath)
|
})
|
||||||
|
.then(() => {
|
||||||
|
if (!with_app_dir) return;
|
||||||
|
const handler = handleDir.bind(null, false, false, in_path);
|
||||||
|
const filter = (filename, stats) => !no_copy_files.has(filename);
|
||||||
|
return walkDir(paths.app, handler, filter);
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
if (!with_app_dir) return;
|
||||||
|
|
||||||
|
if (!helper || !helper.appWriter) {
|
||||||
|
throw new Error(`Unable to generate app for the ${import_format} format!`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const out_app_path = path.join(legacy_path_base, 'app.js');
|
||||||
|
console.log(`Writing ${out_app_path}`);
|
||||||
|
return helper.appWriter(out_path_base, legacy_path_base, out_app_path)
|
||||||
|
.then((extra_scripts) => {
|
||||||
|
const rel_app_path = path.relative(out_path_base, out_app_path);
|
||||||
|
const legacy_scripts = extra_scripts.concat([rel_app_path]);
|
||||||
|
transform_html(legacy_scripts, only_legacy);
|
||||||
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
if (!helper.removeModules) return;
|
||||||
|
console.log(`Cleaning up temporary files...`);
|
||||||
|
return Promise.all(outFiles.map((filepath) => {
|
||||||
|
unlink(filepath)
|
||||||
|
.then(() => {
|
||||||
// Try to clean up any empty directories if this
|
// Try to clean up any empty directories if this
|
||||||
// was the last file in there
|
// was the last file in there
|
||||||
const rmdir_r = dir =>
|
const rmdir_r = dir =>
|
||||||
rmdir(dir)
|
rmdir(dir)
|
||||||
.then(() => rmdir_r(path.dirname(dir)))
|
.then(() => rmdir_r(path.dirname(dir)))
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// Assume the error was ENOTEMPTY and ignore it
|
// Assume the error was ENOTEMPTY and ignore it
|
||||||
});
|
});
|
||||||
return rmdir_r(path.dirname(filepath));
|
return rmdir_r(path.dirname(filepath));
|
||||||
|
});
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
}));
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(`Failure converting modules: ${err}`);
|
||||||
|
process.exit(1);
|
||||||
});
|
});
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(`Failure converting modules: ${err}`);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (program.clean) {
|
if (program.clean) {
|
||||||
|
|
|
@ -22,14 +22,14 @@ module.exports = {
|
||||||
appWriter: (base_out_path, script_base_path, out_path) => {
|
appWriter: (base_out_path, script_base_path, out_path) => {
|
||||||
// setup for requirejs
|
// setup for requirejs
|
||||||
const ui_path = path.relative(base_out_path,
|
const ui_path = path.relative(base_out_path,
|
||||||
path.join(script_base_path, 'app', 'ui'));
|
path.join(script_base_path, 'app', 'ui'));
|
||||||
return writeFile(out_path, `requirejs(["${ui_path}"], (ui) => {});`)
|
return writeFile(out_path, `requirejs(["${ui_path}"], (ui) => {});`)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log(`Please place RequireJS in ${path.join(script_base_path, 'require.js')}`);
|
console.log(`Please place RequireJS in ${path.join(script_base_path, 'require.js')}`);
|
||||||
const require_path = path.relative(base_out_path,
|
const require_path = path.relative(base_out_path,
|
||||||
path.join(script_base_path, 'require.js'))
|
path.join(script_base_path, 'require.js'))
|
||||||
return [ require_path ];
|
return [ require_path ];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
noCopyOverride: () => {},
|
noCopyOverride: () => {},
|
||||||
},
|
},
|
||||||
|
@ -42,8 +42,8 @@ module.exports = {
|
||||||
const browserify = require('browserify');
|
const browserify = require('browserify');
|
||||||
const b = browserify(path.join(script_base_path, 'app/ui.js'), {});
|
const b = browserify(path.join(script_base_path, 'app/ui.js'), {});
|
||||||
return promisify(b.bundle).call(b)
|
return promisify(b.bundle).call(b)
|
||||||
.then(buf => writeFile(out_path, buf))
|
.then(buf => writeFile(out_path, buf))
|
||||||
.then(() => []);
|
.then(() => []);
|
||||||
},
|
},
|
||||||
noCopyOverride: () => {},
|
noCopyOverride: () => {},
|
||||||
removeModules: true,
|
removeModules: true,
|
||||||
|
@ -51,17 +51,17 @@ module.exports = {
|
||||||
'systemjs': {
|
'systemjs': {
|
||||||
appWriter: (base_out_path, script_base_path, out_path) => {
|
appWriter: (base_out_path, script_base_path, out_path) => {
|
||||||
const ui_path = path.relative(base_out_path,
|
const ui_path = path.relative(base_out_path,
|
||||||
path.join(script_base_path, 'app', 'ui.js'));
|
path.join(script_base_path, 'app', 'ui.js'));
|
||||||
return writeFile(out_path, `SystemJS.import("${ui_path}");`)
|
return writeFile(out_path, `SystemJS.import("${ui_path}");`)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log(`Please place SystemJS in ${path.join(script_base_path, 'system-production.js')}`);
|
console.log(`Please place SystemJS in ${path.join(script_base_path, 'system-production.js')}`);
|
||||||
// FIXME: Should probably be in the legacy directory
|
// FIXME: Should probably be in the legacy directory
|
||||||
const promise_path = path.relative(base_out_path,
|
const promise_path = path.relative(base_out_path,
|
||||||
path.join(base_out_path, 'vendor', 'promise.js'))
|
path.join(base_out_path, 'vendor', 'promise.js'))
|
||||||
const systemjs_path = path.relative(base_out_path,
|
const systemjs_path = path.relative(base_out_path,
|
||||||
path.join(script_base_path, 'system-production.js'))
|
path.join(script_base_path, 'system-production.js'))
|
||||||
return [ promise_path, systemjs_path ];
|
return [ promise_path, systemjs_path ];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
noCopyOverride: (paths, no_copy_files) => {
|
noCopyOverride: (paths, no_copy_files) => {
|
||||||
no_copy_files.delete(path.join(paths.vendor, 'promise.js'));
|
no_copy_files.delete(path.join(paths.vendor, 'promise.js'));
|
||||||
|
|
Loading…
Reference in New Issue