From bfd19b4bb3bebc02abf75ebe08687497fd0741df Mon Sep 17 00:00:00 2001 From: Madana Gopal <madanagopal_thirumalai@comcast.com> Date: Wed, 14 Aug 2019 10:35:38 +0530 Subject: [PATCH 1/4] run spark platform mjs before source --- examples/pxScene2d/src/initGL.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/pxScene2d/src/initGL.js b/examples/pxScene2d/src/initGL.js index 75e77777d8..2c631ebace 100644 --- a/examples/pxScene2d/src/initGL.js +++ b/examples/pxScene2d/src/initGL.js @@ -678,9 +678,11 @@ async function loadMjs(source, url, context) { rpath = filename; } + // define platform + var platformsource = await readFileAsync(rpath.substring(0, rpath.lastIndexOf("/")+1) + "lib/lightning-spark.js", {'encoding' : 'utf-8'}) source = await readFileAsync(rpath, {'encoding' : 'utf-8'}) rpath = "file://" + rpath; - app = await loadMjs(source, rpath, contextifiedSandbox); + app = await loadMjs(platformsource + source, rpath, contextifiedSandbox); app.instantiate(); instantiated = true; succeeded = true From e12596e8c5b34b81aa90ffcd940c7c0242602ec8 Mon Sep 17 00:00:00 2001 From: Madana Gopal <madanagopal_thirumalai@comcast.com> Date: Wed, 14 Aug 2019 10:35:38 +0530 Subject: [PATCH 2/4] run spark platform mjs before source --- examples/pxScene2d/src/initGL.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/examples/pxScene2d/src/initGL.js b/examples/pxScene2d/src/initGL.js index 75e77777d8..1ffda3531d 100644 --- a/examples/pxScene2d/src/initGL.js +++ b/examples/pxScene2d/src/initGL.js @@ -479,17 +479,7 @@ async function getModule(specifier, referencingModule) { { // mjs module var treatAsLocal = false; - if(specifier.indexOf("wpe-lightning-spark") == 0) - { - treatAsLocal = true; - specifier = path.resolve(__dirname ,"node_modules/wpe-lightning-spark/src/lightning.mjs") ; - } - else if(specifier.indexOf("wpe-lightning") == 0) - { - treatAsLocal = true; - specifier = path.resolve(__dirname ,"node_modules/" + specifier); - } - else if (specifier.indexOf(".mjs") != -1) + if (specifier.indexOf(".mjs") != -1) { if (isLocalApp) { specifier = path.resolve(baseString.substring(0, baseString.lastIndexOf("/")+1), specifier); @@ -678,9 +668,14 @@ async function loadMjs(source, url, context) { rpath = filename; } + // define platform + var platformsource = ""; + if (rpath.indexOf(".mjs") != -1) { + platformsource = await readFileAsync(rpath.substring(0, rpath.lastIndexOf("/")+1) + "lib/lightning-spark.js", {'encoding' : 'utf-8'}) + } source = await readFileAsync(rpath, {'encoding' : 'utf-8'}) rpath = "file://" + rpath; - app = await loadMjs(source, rpath, contextifiedSandbox); + app = await loadMjs(platformsource + source, rpath, contextifiedSandbox); app.instantiate(); instantiated = true; succeeded = true From 5a69cc9cd366d650c9b1caa5f9193f9db3fa7bc5 Mon Sep 17 00:00:00 2001 From: madanagopaltcomcast <35588028+madanagopaltcomcast@users.noreply.github.com> Date: Mon, 26 Aug 2019 15:07:28 +0530 Subject: [PATCH 3/4] Update initGL.js --- examples/pxScene2d/src/initGL.js | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/pxScene2d/src/initGL.js b/examples/pxScene2d/src/initGL.js index de5742b997..4b8fa0611a 100644 --- a/examples/pxScene2d/src/initGL.js +++ b/examples/pxScene2d/src/initGL.js @@ -672,6 +672,7 @@ async function loadMjs(source, url, context) let framework = await getFile(_frameworkURL); vm.runInContext(framework.data, contextifiedSandbox, {filename:framework.uri}); } + let file = await getFile(filename); let source = file.data, rpath = file.uri; // define platform From 3505f7fffabe29d29b131755a65246322f4f29bc Mon Sep 17 00:00:00 2001 From: madanagopaltcomcast <35588028+madanagopaltcomcast@users.noreply.github.com> Date: Thu, 12 Sep 2019 08:45:26 +0530 Subject: [PATCH 4/4] Update initGL.js --- examples/pxScene2d/src/initGL.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/pxScene2d/src/initGL.js b/examples/pxScene2d/src/initGL.js index 4b8fa0611a..b4c1c93b48 100644 --- a/examples/pxScene2d/src/initGL.js +++ b/examples/pxScene2d/src/initGL.js @@ -675,10 +675,11 @@ async function loadMjs(source, url, context) let file = await getFile(filename); let source = file.data, rpath = file.uri; + // define platform var platformsource = ""; if (filename.indexOf(".mjs") != -1) { - let platformfile = await getFile(filename.substring(0, filename.lastIndexOf("/")+1) + "lib/lightning-spark.js"); + let platformfile = await getFile(urlmain.resolve(path.dirname(filename) + "/", "lib/lightning-spark.js")); platformsource = platformfile.data; } app = await loadMjs(platformsource + source, rpath, contextifiedSandbox);