Skip to content

changes for passing command line args #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: spark
Choose a base branch
from
31 changes: 23 additions & 8 deletions dist/web-spark/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ function startApp() {
409: "Search"
};

// pass key maps in command line
if ("navigationKeys" in sparkQueryParams) {
var navigationMap = {}
eval('navigationMap=' + sparkQueryParams.navigationKeys);
for (var key in navigationMap) {
navigationKeys[key] = navigationMap[key]
}
}

const memoryPressure = parseInt(ux.Ui.getOption('memoryPressure')) || 16e6;
console.log('GPU memory pressure: ' + memoryPressure);

Expand Down Expand Up @@ -70,8 +79,19 @@ function startApp() {
}

try {
var bootstrap = new ux.Ui(options);
bootstrap.startApp(appBundle);
var bootstrap;
if ("appParams" in sparkQueryParams) {
var appParams = []
eval('appParams=' + sparkQueryParams.appParams);
bootstrap = appBundle(options, ...appParams);
}
else {
bootstrap = new ux.Ui(options);
bootstrap.startApp(appBundle);
}
sparkview.on('onKeyDown', function(e) {
bootstrap._receiveKeydown(e);
});
} catch (e) {
if (!lng.Utils.isSpark) {
alert("error " + e)
Expand All @@ -85,11 +105,6 @@ function startApp() {
document.body.appendChild(canvas);

window.app = bootstrap;
} else {
sparkview.on('onKeyDown', function(e) {
console.log('webgl onKeyDown keyCode:', e.keyCode);
bootstrap._receiveKeydown(e);
});
}
}

Expand Down Expand Up @@ -159,4 +174,4 @@ loadPolyfill.then(function() {
console.error(e);
}).then(function() {
startApp();
});
});
9 changes: 7 additions & 2 deletions js/src/Ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class Ui extends lng.Application {
};

// Preload fonts.
const fonts = this._currentApp.type.getFonts().concat(Ui.getFonts());
const fonts = ((this._currentApp.type.config && this._currentApp.type.config.fonts) || (this._currentApp.type.getFonts && this._currentApp.type.getFonts()) || []).concat(Ui.getFonts());
let fn = lng.Utils.isWeb ? Ui.loadFonts(fonts): this.loadPlatformFonts(fonts);
fn.then((fontFaces) => {
this._currentApp.fontFaces = fontFaces;
Expand All @@ -120,7 +120,12 @@ export default class Ui extends lng.Application {
},
class Started extends this {
$enter() {
this.tag("AppWrapper").children = [{ref: "App", type: this._currentApp.type}];
if (this._options.appData && this._options.platformSettings) {
// appdata not passed currently
this.tag("AppWrapper").children = [{ref: "App", type: this._currentApp.type, forceZIndexContext: !!this._options.platformSettings.showVersion}];
} else {
this.tag("AppWrapper").children = [{ref: "App", type: this._currentApp.type}];
}
}
$exit() {
this.tag("AppWrapper").children = [];
Expand Down