2021-05-01 18:47:34 +00:00
|
|
|
/*
|
|
|
|
* Global object.
|
|
|
|
*
|
|
|
|
* This object can't be initialized when common.js is first read since the authorAccess object isn't available yet
|
|
|
|
*
|
|
|
|
*/
|
2021-05-01 21:40:15 +00:00
|
|
|
|
|
|
|
out = Packages.java.lang.System.out;
|
|
|
|
|
|
|
|
out.println('commons.js');
|
|
|
|
|
2021-05-01 18:47:34 +00:00
|
|
|
__required__ = {
|
|
|
|
};
|
|
|
|
|
|
|
|
CommonsOperationsUtil = Packages.ro.sync.ecss.extensions.commons.operations.CommonsOperationsUtil;
|
|
|
|
|
|
|
|
require = function (filepath) {
|
|
|
|
// Check if the object has been initialized
|
|
|
|
if (Object.keys(__required__).length == 0) {
|
|
|
|
var currentPath = CommonsOperationsUtil.expandAndResolvePath(authorAccess, 'commons.js');
|
|
|
|
__required__.baseURIs =[currentPath];
|
|
|
|
__required__.required = {
|
|
|
|
};
|
|
|
|
__required__.required[currentPath] = true;
|
|
|
|
}
|
2021-05-01 21:40:15 +00:00
|
|
|
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);
|
2021-05-01 18:47:34 +00:00
|
|
|
if (__required__.required[filepath] == undefined) {
|
|
|
|
__required__.baseURIs.push(filepath);
|
|
|
|
__required__.required[filepath] = true;
|
2021-05-01 21:40:15 +00:00
|
|
|
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) ));
|
2021-05-01 18:47:34 +00:00
|
|
|
text = String(text);
|
|
|
|
eval(text);
|
|
|
|
__required__.baseURIs.pop();
|
|
|
|
}
|
2021-05-01 16:48:45 +00:00
|
|
|
}
|
2021-05-01 18:47:34 +00:00
|
|
|
|
|
|
|
startDebugger = function () {
|
|
|
|
|
|
|
|
var runnable = {
|
|
|
|
run: function () {
|
|
|
|
main.dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var context = Packages.org.mozilla.javascript.Context.getCurrentContext();
|
|
|
|
// Within the current context...
|
|
|
|
var contextFactory = context.getFactory();
|
|
|
|
var scope = Packages.org.mozilla.javascript.tools.shell.Environment(runnable.__parent__);
|
|
|
|
// and the scope of the runnable variable's parent ...
|
|
|
|
var main = Packages.org.mozilla.javascript.tools. debugger.Main.mainEmbedded(contextFactory, scope, 'Debugger');
|
|
|
|
// start a debugging session ...
|
|
|
|
main.setExitAction(java.lang.Runnable(runnable));
|
|
|
|
// , clean the resources at exit time...
|
|
|
|
main.setVisible(true);
|
|
|
|
// and make it visible/
|
|
|
|
}
|