fix: main now uses new env API
This commit is contained in:
parent
153a1a9a49
commit
3343262e72
@ -18,11 +18,15 @@ import me.topchetoeu.jscript.events.Observer;
|
||||
import me.topchetoeu.jscript.exceptions.EngineException;
|
||||
import me.topchetoeu.jscript.exceptions.InterruptException;
|
||||
import me.topchetoeu.jscript.exceptions.SyntaxException;
|
||||
import me.topchetoeu.jscript.filesystem.Filesystem;
|
||||
import me.topchetoeu.jscript.filesystem.MemoryFilesystem;
|
||||
import me.topchetoeu.jscript.filesystem.Mode;
|
||||
import me.topchetoeu.jscript.filesystem.PhysicalFilesystem;
|
||||
import me.topchetoeu.jscript.filesystem.RootFilesystem;
|
||||
import me.topchetoeu.jscript.lib.Internals;
|
||||
import me.topchetoeu.jscript.modules.ModuleRepo;
|
||||
import me.topchetoeu.jscript.permissions.PermissionsManager;
|
||||
import me.topchetoeu.jscript.permissions.PermissionsProvider;
|
||||
|
||||
public class Main {
|
||||
public static class Printer implements Observer<Object> {
|
||||
@ -43,7 +47,7 @@ public class Main {
|
||||
static Thread engineTask, debugTask;
|
||||
static Engine engine = new Engine(true);
|
||||
static DebugServer debugServer = new DebugServer();
|
||||
static Environment environment = new Environment(null, null, null);
|
||||
static Environment environment = new Environment();
|
||||
|
||||
static int j = 0;
|
||||
static boolean exited = false;
|
||||
@ -119,9 +123,13 @@ public class Main {
|
||||
}
|
||||
}));
|
||||
|
||||
environment.filesystem.protocols.put("temp", new MemoryFilesystem(Mode.READ_WRITE));
|
||||
environment.filesystem.protocols.put("file", new PhysicalFilesystem("."));
|
||||
environment.modules.repos.put("file", ModuleRepo.ofFilesystem(environment.filesystem));
|
||||
var fs = new RootFilesystem(PermissionsProvider.get(environment));
|
||||
fs.protocols.put("temp", new MemoryFilesystem(Mode.READ_WRITE));
|
||||
fs.protocols.put("file", new PhysicalFilesystem("."));
|
||||
|
||||
environment.add(PermissionsProvider.ENV_KEY, PermissionsManager.ALL_PERMS);
|
||||
environment.add(Filesystem.ENV_KEY, fs);
|
||||
environment.add(ModuleRepo.ENV_KEY, ModuleRepo.ofFilesystem(fs));
|
||||
}
|
||||
private static void initEngine() {
|
||||
debugServer.targets.put("target", (ws, req) -> new SimpleDebugger(ws, engine));
|
||||
@ -130,11 +138,11 @@ public class Main {
|
||||
}
|
||||
private static void initTypescript() {
|
||||
try {
|
||||
var tsEnv = Internals.apply(new Environment(null, null, null));
|
||||
tsEnv.stackHidden = false;
|
||||
var tsEnv = Internals.apply(new Environment());
|
||||
tsEnv.add(Environment.HIDE_STACK, true);
|
||||
tsEnv.global.define(null, "module", false, new ObjectValue());
|
||||
var bsEnv = Internals.apply(new Environment(null, null, null));
|
||||
bsEnv.stackHidden = false;
|
||||
var bsEnv = Internals.apply(new Environment());
|
||||
bsEnv.add(Environment.HIDE_STACK, true);
|
||||
|
||||
engine.pushMsg(
|
||||
false, tsEnv,
|
||||
|
Loading…
Reference in New Issue
Block a user