From b3cb52a8ab61dc46b401ebdbd2cb4a5e7f40a65a Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Sat, 1 May 2021 23:40:15 +0200 Subject: [PATCH] Debugging... --- oxygen/js-require/commons.js | 18 +++++++++++++++--- oxygen/js-require/hello.js | 3 +++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/oxygen/js-require/commons.js b/oxygen/js-require/commons.js index 9164bad..3881b20 100644 --- a/oxygen/js-require/commons.js +++ b/oxygen/js-require/commons.js @@ -4,6 +4,11 @@ * This object can't be initialized when common.js is first read since the authorAccess object isn't available yet * */ + +out = Packages.java.lang.System.out; + +out.println('commons.js'); + __required__ = { }; @@ -18,12 +23,19 @@ require = function (filepath) { }; __required__.required[currentPath] = true; } - var basePathFile = (new java.io.File(__required__.baseURIs[__required__.baseURIs.length - 1])).getParentFile(); - filepath = new java.io.File(basePathFile, filepath).toString(); + var currentFilePath = __required__.baseURIs[__required__.baseURIs.length - 1]; + out.println('filepath: ' + filepath); + out.println('current filepath: ' + currentFilePath); + var currentURI = new java.net.URI(currentFilePath); + var targetURI = currentURI.resolve(filepath); + filepath = targetURI.toString(); + out.println('filepath: ' + filepath); if (__required__.required[filepath] == undefined) { __required__.baseURIs.push(filepath); __required__.required[filepath] = true; - var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths. get (java.net.URI(filepath)))); + var uri = new java.net.URI(filepath); + out.println('New, inclusion needed: ' + uri.toString()); + var text = new java.lang.String(java.nio.file.Files.readAllBytes( java.nio.file.Paths.get(targetURI) )); text = String(text); eval(text); __required__.baseURIs.pop(); diff --git a/oxygen/js-require/hello.js b/oxygen/js-require/hello.js index e083f67..320466e 100644 --- a/oxygen/js-require/hello.js +++ b/oxygen/js-require/hello.js @@ -1,3 +1,6 @@ +require('hello.js'); +require('./commons.js'); + hello = function (){ Packages.java.lang.System.out.println("Hello world."); } \ No newline at end of file