From 76275929831848fc89a4991ba815268a0f8ff1ab Mon Sep 17 00:00:00 2001 From: Madana Gopal Date: Mon, 12 Aug 2019 11:17:01 +0530 Subject: [PATCH 1/6] lightning-spark bundling --- dist/spark/DevLauncher.mjs | 6 +++--- js/src/App.js | 4 ++-- js/src/Ui.js | 14 +++++++------- scripts/release-spark.js | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dist/spark/DevLauncher.mjs b/dist/spark/DevLauncher.mjs index d7ac82c3..96465879 100644 --- a/dist/spark/DevLauncher.mjs +++ b/dist/spark/DevLauncher.mjs @@ -1,5 +1,5 @@ import ux from "./src/ux.mjs"; -import lng from 'wpe-lightning-spark'; +import lightning from './lib/lightning-spark.mjs'; import fetch from "node-fetch"; import keyboard from "./src/keyboard.mjs"; @@ -52,7 +52,7 @@ export default class DevLauncher { let options = {stage: {w: 1920, h: 1080}, debug: false, keys: this._getNavigationKeys()}; const config = options.stage; - if (ux.Ui.hasOption("720") || (lng.Utils.isWeb && window.innerHeight === 720)) { + if (ux.Ui.hasOption("720") || (lightning.Utils.isWeb && window.innerHeight === 720)) { config['w'] = 1280; config['h'] = 720; config['precision'] = 0.6666666667; @@ -63,7 +63,7 @@ export default class DevLauncher { config.useImageWorker = true; } - options = lng.tools.ObjMerger.merge(options, customOptions); + options = lightning.tools.ObjMerger.merge(options, customOptions); return options; } diff --git a/js/src/App.js b/js/src/App.js index d992f009..96f6cc12 100644 --- a/js/src/App.js +++ b/js/src/App.js @@ -1,6 +1,6 @@ import Ui from "./Ui.js"; -export default class App extends lng.Component { +export default class App extends lightning.Component { static g(c) { return c.seekAncestorByType(this); @@ -26,4 +26,4 @@ export default class App extends lng.Component { throw new Error("Please supply an identifier in the App definition file."); } -} \ No newline at end of file +} diff --git a/js/src/Ui.js b/js/src/Ui.js index daaab80a..ab8653f4 100644 --- a/js/src/Ui.js +++ b/js/src/Ui.js @@ -2,7 +2,7 @@ import Mediaplayer from "./Mediaplayer.js"; import NoopMediaplayer from "./NoopMediaplayer.js"; import ScaledImageTexture from "./ScaledImageTexture.js"; -export default class Ui extends lng.Application { +export default class Ui extends lightning.Application { constructor(options) { options.defaultFontFace = options.defaultFontFace || "RobotoRegular"; @@ -12,7 +12,7 @@ export default class Ui extends lng.Application { static _template() { return { - Mediaplayer: {type: lng.Utils.isWeb ? Mediaplayer : NoopMediaplayer, textureMode: Ui.hasOption('texture')}, + Mediaplayer: {type: lightning.Utils.isWeb ? Mediaplayer : NoopMediaplayer, textureMode: Ui.hasOption('texture')}, AppWrapper: {} }; } @@ -41,13 +41,13 @@ export default class Ui extends lng.Application { } _handleBack() { - if (lng.Utils.isWeb) { + if (lightning.Utils.isWeb) { window.close(); } } static loadFonts(fonts) { - if (lng.Utils.isNode) { + if (lightning.Utils.isNode) { // Font loading not supported. Fonts should be installed in Linux system and then they can be picked up by cairo. return Promise.resolve(); } @@ -157,11 +157,11 @@ export default class Ui extends lng.Application { } static _getCdnProtocol() { - return lng.Utils.isWeb && location.protocol === "https:" ? "https" : "http"; + return lightning.Utils.isWeb && location.protocol === "https:" ? "https" : "http"; } static hasOption(name) { - if (lng.Utils.isNode) { + if (lightning.Utils.isNode) { return false; } @@ -169,7 +169,7 @@ export default class Ui extends lng.Application { } static getOption(name) { - if (lng.Utils.isNode) { + if (lightning.Utils.isNode) { return undefined; } diff --git a/scripts/release-spark.js b/scripts/release-spark.js index 062c8fc8..6d36d246 100644 --- a/scripts/release-spark.js +++ b/scripts/release-spark.js @@ -78,7 +78,7 @@ function getDependencies() { function bundleApp() { console.log("Generate rollup bundle for app (src/App.js)"); return rollup.rollup({input: "./src/App.js"}).then(bundle => { - return bundle.generate({format: 'esm', banner: 'import ux from "./ux";\nimport lng from "wpe-lightning-spark";\n' + getDependencies()}).then(content => { + return bundle.generate({format: 'esm', banner: 'import ux from "./ux";\nimport lightning from "./lib/lightning-spark.mjs";\n' + getDependencies()}).then(content => { const location = "./dist/" + info.dest + "/src/app.mjs"; fs.writeFileSync(location, content.code); }); @@ -88,7 +88,7 @@ function bundleApp() { function bundleUx() { console.log("Generate rollup bundle for ux"); return rollup.rollup({input: dir + "/js/src/ux.js"}).then(bundle => { - return bundle.generate({format: 'esm', banner: 'import lng from "wpe-lightning-spark";\n' + getDependencies()}).then(content => { + return bundle.generate({format: 'esm', banner: 'import lightning from "./lib/lightning-spark.mjs";\n' + getDependencies()}).then(content => { const location = "./dist/" + info.dest + "/src/ux.mjs"; fs.writeFileSync(location, content.code); }); @@ -114,4 +114,4 @@ function exec(command, opts) { resolve(stdout); }); }); -} \ No newline at end of file +} From 7ea9f66c4e7d89d218507ed890e668f28d4fd915 Mon Sep 17 00:00:00 2001 From: Madana Gopal Date: Mon, 12 Aug 2019 12:48:28 +0530 Subject: [PATCH 2/6] Revert "lightning-spark bundling" This reverts commit 76275929831848fc89a4991ba815268a0f8ff1ab. --- dist/spark/DevLauncher.mjs | 6 +++--- js/src/App.js | 4 ++-- js/src/Ui.js | 14 +++++++------- scripts/release-spark.js | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dist/spark/DevLauncher.mjs b/dist/spark/DevLauncher.mjs index 96465879..d7ac82c3 100644 --- a/dist/spark/DevLauncher.mjs +++ b/dist/spark/DevLauncher.mjs @@ -1,5 +1,5 @@ import ux from "./src/ux.mjs"; -import lightning from './lib/lightning-spark.mjs'; +import lng from 'wpe-lightning-spark'; import fetch from "node-fetch"; import keyboard from "./src/keyboard.mjs"; @@ -52,7 +52,7 @@ export default class DevLauncher { let options = {stage: {w: 1920, h: 1080}, debug: false, keys: this._getNavigationKeys()}; const config = options.stage; - if (ux.Ui.hasOption("720") || (lightning.Utils.isWeb && window.innerHeight === 720)) { + if (ux.Ui.hasOption("720") || (lng.Utils.isWeb && window.innerHeight === 720)) { config['w'] = 1280; config['h'] = 720; config['precision'] = 0.6666666667; @@ -63,7 +63,7 @@ export default class DevLauncher { config.useImageWorker = true; } - options = lightning.tools.ObjMerger.merge(options, customOptions); + options = lng.tools.ObjMerger.merge(options, customOptions); return options; } diff --git a/js/src/App.js b/js/src/App.js index 96f6cc12..d992f009 100644 --- a/js/src/App.js +++ b/js/src/App.js @@ -1,6 +1,6 @@ import Ui from "./Ui.js"; -export default class App extends lightning.Component { +export default class App extends lng.Component { static g(c) { return c.seekAncestorByType(this); @@ -26,4 +26,4 @@ export default class App extends lightning.Component { throw new Error("Please supply an identifier in the App definition file."); } -} +} \ No newline at end of file diff --git a/js/src/Ui.js b/js/src/Ui.js index ab8653f4..daaab80a 100644 --- a/js/src/Ui.js +++ b/js/src/Ui.js @@ -2,7 +2,7 @@ import Mediaplayer from "./Mediaplayer.js"; import NoopMediaplayer from "./NoopMediaplayer.js"; import ScaledImageTexture from "./ScaledImageTexture.js"; -export default class Ui extends lightning.Application { +export default class Ui extends lng.Application { constructor(options) { options.defaultFontFace = options.defaultFontFace || "RobotoRegular"; @@ -12,7 +12,7 @@ export default class Ui extends lightning.Application { static _template() { return { - Mediaplayer: {type: lightning.Utils.isWeb ? Mediaplayer : NoopMediaplayer, textureMode: Ui.hasOption('texture')}, + Mediaplayer: {type: lng.Utils.isWeb ? Mediaplayer : NoopMediaplayer, textureMode: Ui.hasOption('texture')}, AppWrapper: {} }; } @@ -41,13 +41,13 @@ export default class Ui extends lightning.Application { } _handleBack() { - if (lightning.Utils.isWeb) { + if (lng.Utils.isWeb) { window.close(); } } static loadFonts(fonts) { - if (lightning.Utils.isNode) { + if (lng.Utils.isNode) { // Font loading not supported. Fonts should be installed in Linux system and then they can be picked up by cairo. return Promise.resolve(); } @@ -157,11 +157,11 @@ export default class Ui extends lightning.Application { } static _getCdnProtocol() { - return lightning.Utils.isWeb && location.protocol === "https:" ? "https" : "http"; + return lng.Utils.isWeb && location.protocol === "https:" ? "https" : "http"; } static hasOption(name) { - if (lightning.Utils.isNode) { + if (lng.Utils.isNode) { return false; } @@ -169,7 +169,7 @@ export default class Ui extends lightning.Application { } static getOption(name) { - if (lightning.Utils.isNode) { + if (lng.Utils.isNode) { return undefined; } diff --git a/scripts/release-spark.js b/scripts/release-spark.js index 6d36d246..062c8fc8 100644 --- a/scripts/release-spark.js +++ b/scripts/release-spark.js @@ -78,7 +78,7 @@ function getDependencies() { function bundleApp() { console.log("Generate rollup bundle for app (src/App.js)"); return rollup.rollup({input: "./src/App.js"}).then(bundle => { - return bundle.generate({format: 'esm', banner: 'import ux from "./ux";\nimport lightning from "./lib/lightning-spark.mjs";\n' + getDependencies()}).then(content => { + return bundle.generate({format: 'esm', banner: 'import ux from "./ux";\nimport lng from "wpe-lightning-spark";\n' + getDependencies()}).then(content => { const location = "./dist/" + info.dest + "/src/app.mjs"; fs.writeFileSync(location, content.code); }); @@ -88,7 +88,7 @@ function bundleApp() { function bundleUx() { console.log("Generate rollup bundle for ux"); return rollup.rollup({input: dir + "/js/src/ux.js"}).then(bundle => { - return bundle.generate({format: 'esm', banner: 'import lightning from "./lib/lightning-spark.mjs";\n' + getDependencies()}).then(content => { + return bundle.generate({format: 'esm', banner: 'import lng from "wpe-lightning-spark";\n' + getDependencies()}).then(content => { const location = "./dist/" + info.dest + "/src/ux.mjs"; fs.writeFileSync(location, content.code); }); @@ -114,4 +114,4 @@ function exec(command, opts) { resolve(stdout); }); }); -} +} \ No newline at end of file From 9a101dd7a75c10eb6f9ef41e2d3c318b5524a06c Mon Sep 17 00:00:00 2001 From: Madana Gopal Date: Mon, 12 Aug 2019 12:53:13 +0530 Subject: [PATCH 3/6] changes for mjs --- dist/spark/DevLauncher.mjs | 2 +- dist/spark/package.json | 3 ++- dist/spark/rollup.config.js | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dist/spark/DevLauncher.mjs b/dist/spark/DevLauncher.mjs index d7ac82c3..4b784843 100644 --- a/dist/spark/DevLauncher.mjs +++ b/dist/spark/DevLauncher.mjs @@ -1,5 +1,5 @@ import ux from "./src/ux.mjs"; -import lng from 'wpe-lightning-spark'; +import lng from './lib/lightning.mjs'; import fetch from "node-fetch"; import keyboard from "./src/keyboard.mjs"; diff --git a/dist/spark/package.json b/dist/spark/package.json index 21232e61..f384c3de 100644 --- a/dist/spark/package.json +++ b/dist/spark/package.json @@ -11,6 +11,7 @@ "node-fetch": "^1.7.3" }, "devDependencies": { - "rollup-plugin-node-resolve": "^5.0.0" + "rollup-plugin-node-resolve": "^5.0.0", + "rollup-plugin-execute": "^1.1.1" } } diff --git a/dist/spark/rollup.config.js b/dist/spark/rollup.config.js index 61b60a13..2628b12f 100644 --- a/dist/spark/rollup.config.js +++ b/dist/spark/rollup.config.js @@ -1,13 +1,14 @@ const resolve = require('rollup-plugin-node-resolve'); +const execute = require('rollup-plugin-execute'); export default { input: 'start.mjs', plugins: [resolve({ only: [ 'wpe-lightning-spark', 'wpe-lightning' ] - })], + }), execute("mkdir lib; cp node_modules/wpe-lightning-spark/dist/lightning-spark.mjs lib/.")], output: { file: './lightning-demo-spark.js', format: 'cjs', name: 'lng' } -}; \ No newline at end of file +}; From b715674b0d9ae759938c6cfe4e31b2557d113802 Mon Sep 17 00:00:00 2001 From: Madana Gopal Date: Mon, 12 Aug 2019 12:53:13 +0530 Subject: [PATCH 4/6] changes for mjs --- dist/spark/DevLauncher.mjs | 2 +- dist/spark/package.json | 3 ++- dist/spark/rollup.config.js | 5 +++-- scripts/release-spark.js | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dist/spark/DevLauncher.mjs b/dist/spark/DevLauncher.mjs index d7ac82c3..4b784843 100644 --- a/dist/spark/DevLauncher.mjs +++ b/dist/spark/DevLauncher.mjs @@ -1,5 +1,5 @@ import ux from "./src/ux.mjs"; -import lng from 'wpe-lightning-spark'; +import lng from './lib/lightning.mjs'; import fetch from "node-fetch"; import keyboard from "./src/keyboard.mjs"; diff --git a/dist/spark/package.json b/dist/spark/package.json index 21232e61..f384c3de 100644 --- a/dist/spark/package.json +++ b/dist/spark/package.json @@ -11,6 +11,7 @@ "node-fetch": "^1.7.3" }, "devDependencies": { - "rollup-plugin-node-resolve": "^5.0.0" + "rollup-plugin-node-resolve": "^5.0.0", + "rollup-plugin-execute": "^1.1.1" } } diff --git a/dist/spark/rollup.config.js b/dist/spark/rollup.config.js index 61b60a13..2628b12f 100644 --- a/dist/spark/rollup.config.js +++ b/dist/spark/rollup.config.js @@ -1,13 +1,14 @@ const resolve = require('rollup-plugin-node-resolve'); +const execute = require('rollup-plugin-execute'); export default { input: 'start.mjs', plugins: [resolve({ only: [ 'wpe-lightning-spark', 'wpe-lightning' ] - })], + }), execute("mkdir lib; cp node_modules/wpe-lightning-spark/dist/lightning-spark.mjs lib/.")], output: { file: './lightning-demo-spark.js', format: 'cjs', name: 'lng' } -}; \ No newline at end of file +}; diff --git a/scripts/release-spark.js b/scripts/release-spark.js index 062c8fc8..47680254 100644 --- a/scripts/release-spark.js +++ b/scripts/release-spark.js @@ -78,7 +78,7 @@ function getDependencies() { function bundleApp() { console.log("Generate rollup bundle for app (src/App.js)"); return rollup.rollup({input: "./src/App.js"}).then(bundle => { - return bundle.generate({format: 'esm', banner: 'import ux from "./ux";\nimport lng from "wpe-lightning-spark";\n' + getDependencies()}).then(content => { + return bundle.generate({format: 'esm', banner: 'import ux from "./ux";\nimport lng from "../lib/lightning-spark.mjs";\n' + getDependencies()}).then(content => { const location = "./dist/" + info.dest + "/src/app.mjs"; fs.writeFileSync(location, content.code); }); @@ -88,7 +88,7 @@ function bundleApp() { function bundleUx() { console.log("Generate rollup bundle for ux"); return rollup.rollup({input: dir + "/js/src/ux.js"}).then(bundle => { - return bundle.generate({format: 'esm', banner: 'import lng from "wpe-lightning-spark";\n' + getDependencies()}).then(content => { + return bundle.generate({format: 'esm', banner: 'import lng from "../lib/lightning-spark.mjs";\n' + getDependencies()}).then(content => { const location = "./dist/" + info.dest + "/src/ux.mjs"; fs.writeFileSync(location, content.code); }); @@ -114,4 +114,4 @@ function exec(command, opts) { resolve(stdout); }); }); -} \ No newline at end of file +} From c0bb99ad23c4b3e33c10923356df4fada57325ae Mon Sep 17 00:00:00 2001 From: Madana Gopal Date: Mon, 19 Aug 2019 11:08:48 +0530 Subject: [PATCH 5/6] make esm as bundler by default --- dist/spark/rollup.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/spark/rollup.config.js b/dist/spark/rollup.config.js index 2a025074..8bd01360 100644 --- a/dist/spark/rollup.config.js +++ b/dist/spark/rollup.config.js @@ -6,8 +6,8 @@ export default { only: [ 'wpe-lightning' ] })], output: { - file: './lightning-demo-spark.js', - format: 'cjs', + file: './lightning-demo-spark.mjs', + format: 'esm', name: 'lng' } }; From 50e3a6fe23e30107a1eafeacb95308240434b6b2 Mon Sep 17 00:00:00 2001 From: Madana Gopal Date: Mon, 19 Aug 2019 16:26:26 +0530 Subject: [PATCH 6/6] populate lng --- scripts/release-spark.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release-spark.js b/scripts/release-spark.js index 462e1794..34e9677f 100644 --- a/scripts/release-spark.js +++ b/scripts/release-spark.js @@ -78,7 +78,7 @@ function getDependencies() { function bundleApp() { console.log("Generate rollup bundle for app (src/App.js)"); return rollup.rollup({input: "./src/App.js"}).then(bundle => { - return bundle.generate({format: 'esm', banner: 'import ux from "./ux";\nimport lng from "wpe-lightning/src/lightning.mjs";\n' + getDependencies()}).then(content => { + return bundle.generate({format: 'esm', banner: 'import ux from "./ux";\nimport lightning from "wpe-lightning/src/lightning.mjs";\nconst lng = lightning;\n' + getDependencies()}).then(content => { const location = "./dist/" + info.dest + "/src/app.mjs"; fs.writeFileSync(location, content.code); }); @@ -88,7 +88,7 @@ function bundleApp() { function bundleUx() { console.log("Generate rollup bundle for ux"); return rollup.rollup({input: dir + "/js/src/ux.js"}).then(bundle => { - return bundle.generate({format: 'esm', banner: 'import lng from "wpe-lightning/src/lightning.mjs";\n' + getDependencies()}).then(content => { + return bundle.generate({format: 'esm', banner: 'import lightning from "wpe-lightning/src/lightning.mjs";\nconst lng = lightning;\n' + getDependencies()}).then(content => { const location = "./dist/" + info.dest + "/src/ux.mjs"; fs.writeFileSync(location, content.code); });