Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
57 changes: 30 additions & 27 deletions DevLauncher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {} from "./js/lib/lightning-web.js";
import maf from "./js/src/maf.js";
// MODIFICATION: removed this lib reference as it is making http calls to a metrological endpoint
// that is not needed by applications and it also presents potential security concerns
// additionall lib makes api call just by importing is which hamers testability
// import maf from "./js/src/maf.js";
import ux from "./js/src/ux.js";

export default class DevLauncher {
Expand Down Expand Up @@ -28,7 +31,7 @@ export default class DevLauncher {
}, targetTime - currentTime);
};
}

launch(appType, lightningOptions, options = {}) {
this._appType = appType;
this._options = options;
Expand Down Expand Up @@ -68,6 +71,8 @@ export default class DevLauncher {

_addStyles() {
const style = document.createElement('style');
// MODIFICATION - removeds hardcoded black background.
// This should be specified by applications not framework
style.innerText = `
*,body{
margin:0;
Expand All @@ -77,10 +82,6 @@ export default class DevLauncher {
canvas {
position: absolute;
z-index: 2;
}

body {
background: black;
}`;
document.head.appendChild(style);
}
Expand All @@ -100,7 +101,10 @@ body {
}

_getLightningOptions(customOptions = {}) {
let options = {stage: {w: 1920, h: 1080, clearColor: 0x00000000, canvas2d: false}, debug: false, keys: this._getNavigationKeys()};
// MODIFICATION - dont need these default mappings - just need an empty array to make
// sure the web key event handler is registered properly - this should be changed to allow
// application to set the handlers if desired rather than hardcoding
let options = {stage: {w: 1920, h: 1080, clearColor: 0x00000000, canvas2d: false}, debug: false, keys: {}};

const config = options.stage;
if (ux.Ui.hasOption("720") || window.innerHeight === 720) {
Expand All @@ -122,30 +126,29 @@ body {
}
}


options = lng.tools.ObjMerger.merge(options, customOptions);

return options;
}

_getNavigationKeys() {
return {
8: "Back",
13: "Enter",
27: "Menu",
37: "Left",
38: "Up",
39: "Right",
40: "Down",
174: "ChannelDown",
175: "ChannelUp",
178: "Stop",
250: "PlayPause",
191: "Search", // Use "/" for keyboard
409: "Search"
};
}

// MODIFICATION - no longer used.
// _getNavigationKeys() {
// return {
// 8: "Back",
// 13: "Enter",
// 27: "Menu",
// 37: "Left",
// 38: "Up",
// 39: "Right",
// 40: "Down",
// 174: "ChannelDown",
// 175: "ChannelUp",
// 178: "Stop",
// 250: "PlayPause",
// 191: "Search", // Use "/" for keyboard
// // 409: "Search"
// };
// }
}

DevLauncher._uxPath = "./node_modules/wpe-lightning-sdk/";
DevLauncher._uxPath = "./node_modules/wpe-lightning-sdk/";
124 changes: 74 additions & 50 deletions dist/spark/DevLauncher.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import ux from "./src/ux.mjs";
import lng from 'wpe-lightning-spark';
import fetch from "node-fetch";
// MODIFICATION - per direction from spark team - this script dependency is not needed
// import keyboard from "./src/keyboard.mjs";

export default class DevLauncher {

constructor() {
}
// MODIFICATION - per spark team keyboard is not needed by spark runtime
// constructor() {
// keyboard((event) => {
// this._handleKey(event);
// });
// }

launch(appType, lightningOptions, options = {}) {
this._appType = appType;
Expand All @@ -14,11 +20,29 @@ export default class DevLauncher {
}

_handleKey(event) {
this._ui._receiveKeydown(event);
this._ui._receiveKeydown(
// MODIFICATION: normalizes spark key event to the same structure
// as web keyboard event so that we can have "consistent" key handling code
// across platforms
this._normalizeKeyEvent(event));
}

// MODIFICATION: normalize key event to the same structure as web event
// so that we can have consistent key handling across platforms - this is
// as simple implementation for example purposes
_normalizeKeyEvent(keyEvent) {
const f = keyEvent.flags;
return {
keyCode: keyEvent.keyCode,
altKey: f === 48 || f === 56,
ctrlKey: f === 16 || f === 48 || f === 24 || f === 56,
shiftKey: f === 8 || f === 136 || f === 24 || f === 56,
};
}

_start(lightningOptions = {}) {
this._openFirewall();
// MODIFICATION - remove call to metro rest endpoint.
// this._openFirewall();
this._lightningOptions = this._getLightningOptions(lightningOptions);
return this._startApp();
}
Expand All @@ -30,55 +54,55 @@ export default class DevLauncher {
this._ui.startApp(this._appType);
}

_loadInspector() {
if (this._options.useInspector) {
/* Attach the inspector to create a fake DOM that shows where lightning elements can be found. */
return this.loadScript(DevLauncher._uxPath + "../wpe-lightning/devtools/lightning-inspect.js");
} else {
return Promise.resolve();
}
}
// MODIFICATION - remove this code as inspector requires browser to work
// _loadInspector() {
// if (this._options.useInspector) {
// /* Attach the inspector to create a fake DOM that shows where lightning elements can be found. */
// return this.loadScript(DevLauncher._uxPath + "../wpe-lightning/devtools/lightning-inspect.js");
// } else {
// return Promise.resolve();
// }
// }

_openFirewall() {
// Fetch app store to ensure that proxy/image servers firewall is opened.
//fetch(`http://widgets.metrological.com/${encodeURIComponent(ux.Ui.getOption('operator') || 'metrological')}/nl/test`).then(() => {});
}
// MODIFICATION - no longer used
// _openFirewall() {
// Fetch app store to ensure that proxy/image servers firewall is opened.
// fetch(`http://widgets.metrological.com/${encodeURIComponent(ux.Ui.getOption('operator') || 'metrological')}/nl/test`).then(() => {});
// }

_getLightningOptions(customOptions = {}) {
let options = {stage: {w: 1920, h: 1080}, debug: false, keys: this._getNavigationKeys()};

const config = options.stage;
if (customOptions.h === 720) {
config['w'] = 1280;
config['h'] = 720;
config['precision'] = 0.6666666667;
} else {
config['w'] = 1920;
config['h'] = 1080;

config.useImageWorker = true;
}

options = lng.tools.ObjMerger.merge(options, customOptions);

return options;
}

_getNavigationKeys() {
return {
8: "Back",
13: "Enter",
27: "Menu",
37: "Left",
38: "Up",
39: "Right",
40: "Down",
174: "ChannelDown",
175: "ChannelUp",
178: "Stop",
250: "PlayPause",
191: "Search", // Use "/" for keyboard
409: "Search"
// MODIFICATION - this file is spark aware - per spark team
// the resolution will always be 1280x720 - if not this should be externalized
// so applications can set accordingly
let options = {
stage: {
w: 1280, h: 720,
precision: 0.6666666667,
},
debug: false,
// MODIFICATION - dont need these mappings, commenting out the property
// disables the confusing "no key handler registered" console message
// keys: this._getNavigationKeys(),
};
return lng.tools.ObjMerger.merge(options, customOptions);
}

// MODIFICATION - no longer referenced
// _getNavigationKeys() {
// return {
// 8: "Back",
// 13: "Enter",
// 27: "Menu",
// 37: "Left",
// 38: "Up",
// 39: "Right",
// 40: "Down",
// 174: "ChannelDown",
// 175: "ChannelUp",
// 178: "Stop",
// 250: "PlayPause",
// 191: "Search", // Use "/" for keyboard
// 409: "Search"
// };
// }
}
7 changes: 3 additions & 4 deletions dist/web/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<!DOCTYPE html>
<!-- MOD 1: adds referrer meta to prevent url leak when framework call hidden 3rd parties -->
<!-- MOD 2: removes hardcoded background - app should specify-->
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1">
<meta name="description" content="Lightning App"/>
<meta name="referrer" content="no-referrer" />

<title>Lightning App</title>

Expand All @@ -17,10 +20,6 @@
position: absolute;
z-index: 2;
}

body {
background: black;
}
</style>

<script src="js/polyfills/url-polyfill.js"></script>
Expand Down
49 changes: 27 additions & 22 deletions dist/web/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@ function startApp() {
};
}

var navigationKeys = {
8: "Back",
13: "Enter",
27: "Back",
10009: "Back",
37: "Left",
38: "Up",
39: "Right",
40: "Down",
174: "ChannelDown",
175: "ChannelUp",
178: "Stop",
250: "PlayPause",
191: "Search", // Use "/" for keyboard
409: "Search"
};
// MODIFICATION - no longer used.
// var navigationKeys = {
// 8: "Back",
// 13: "Enter",
// 27: "Back",
// 10009: "Back",
// 37: "Left",
// 38: "Up",
// 39: "Right",
// 40: "Down",
// 174: "ChannelDown",
// 175: "ChannelUp",
// 178: "Stop",
// 250: "PlayPause",
// 191: "Search", // Use "/" for keyboard
// 409: "Search"
// };

const memoryPressure = parseInt(ux.Ui.getOption('memoryPressure')) || 16e6;
console.log('GPU memory pressure: ' + memoryPressure);
Expand All @@ -43,10 +44,14 @@ function startApp() {
w: 1920,
h: 1080,
clearColor: ux.Ui.getOption('transparentBg') === "0" ? 0xFF000000 : 0x00000000,
defaultFontFace: 'RobotoRegular',
// MODIFICATION - default font face should be specified by applications
// defaultFontFace: 'RobotoRegular',
memoryPressure: memoryPressure,
canvas2d: ux.Ui.hasOption('c2d')
}, debug: false, keys: navigationKeys
// MODIFICATION - dont need these default mappings - just need an empty array to make
// sure the web key event handler is registered properly - this should be changed to allow
// application to set the handlers if desired rather than hardcoding
}, debug: false, keys: {}
};

const config = options.stage;
Expand Down Expand Up @@ -109,10 +114,10 @@ function loadScript(src) {
});
}


// MODIFICATION - removing call to metrological cause its a potentiual security issue
// Fetch app store to ensure that proxy/image servers firewall is opened.
fetch('http://widgets.metrological.com/metrological/nl/test').then(function(){
});
// fetch('http://widgets.metrological.com/metrological/nl/test').then(function(){
// });

const supportsEs6 = isSupportingES6();
const folder = supportsEs6 ? "src" : "src.es5";
Expand All @@ -134,4 +139,4 @@ loadPolyfill.then(function() {
console.error(e);
}).then(function() {
startApp();
});
});
Loading