void Awake() { IFileSystem fileSystem; _mConsole = new MiniConsole(scrollRect, text, 100); _rt = ScriptEngine.CreateRuntime(); var fileResolver = new FileResolver(); fileResolver.AddSearchPath("node_modules"); if (fileLoader == FileLoader.Resources) { fileSystem = new ResourcesFileSystem(_mConsole); fileResolver.AddSearchPath("dist"); } else if (fileLoader == FileLoader.HMR) { Debug.LogWarningFormat("功能未完成"); fileSystem = new HttpFileSystem(_mConsole, baseUrl); } else { fileSystem = new DefaultFileSystem(_mConsole); fileResolver.AddSearchPath("Assets/Examples/Scripts/out"); // _rt.AddSearchPath("Assets/Examples/Scripts/dist"); } _rt.withStacktrace = stacktrace; if (sourceMap) { _rt.EnableSourceMap(); } _mConsole.Write(LogLevel.Info, "Init"); _rt.Initialize(fileSystem, fileResolver, this, _mConsole, new ByteBufferPooledAllocator()); }
void Awake() { IFileSystem fileSystem; _mConsole = new MiniConsole(scrollRect, text, 100); _rt = ScriptEngine.CreateRuntime(); var asyncManager = new DefaultAsyncManager(); var pathResolver = new PathResolver(); pathResolver.AddSearchPath("node_modules"); if (fileLoader == FileLoader.Resources) { fileSystem = new ResourcesFileSystem(_mConsole); pathResolver.AddSearchPath("dist"); // 这里的路径相对于 Unity Resources 空间 } else if (fileLoader == FileLoader.HMR) { Debug.LogWarningFormat("功能未完成"); fileSystem = new HttpFileSystem(_mConsole, baseUrl); } else { // 演示了一般文件系统的访问, 实际项目中典型的情况需要自行实现基于 AssetBundle(或 7z/zip) 的文件访问层 fileSystem = new DefaultFileSystem(_mConsole); pathResolver.AddSearchPath("Scripts/out"); // pathResolver.AddSearchPath("../Scripts/out"); // _rt.AddSearchPath("Assets/Examples/Scripts/dist"); } _rt.withStacktrace = stacktrace; if (sourceMap) { _rt.EnableSourceMap(); } _rt.AddModuleResolvers(); _rt.extraBinding = (runtime, register) => { FSWatcher.Bind(register); QuickJS.Extra.WebSocket.Bind(register); QuickJS.Extra.XMLHttpRequest.Bind(register); if (!runtime.isWorker) { var uri = new Uri(baseUrl); QuickJS.Extra.DOMCompatibleLayer.Bind(register, uri); QuickJS.Extra.NodeCompatibleLayer.Bind(register); } }; _rt.Initialize(new ScriptRuntimeArgs { fileSystem = fileSystem, pathResolver = pathResolver, asyncManager = asyncManager, logger = _mConsole, byteBufferAllocator = new ByteBufferPooledAllocator(), binder = DefaultBinder.GetBinder(useReflectBind), }); _rt.EvalMain(entryFileName); }
void Awake() { IFileSystem fileSystem; _mConsole = new MiniConsole(scrollRect, text, 100); _rt = ScriptEngine.CreateRuntime(); var asyncManager = new DefaultAsyncManager(); var pathResolver = new PathResolver(); pathResolver.AddSearchPath("node_modules"); if (fileLoader == FileLoader.Resources) { fileSystem = new ResourcesFileSystem(_mConsole); pathResolver.AddSearchPath("dist"); // 这里的路径相对于 Unity Resources 空间 } else if (fileLoader == FileLoader.HMR) { Debug.LogWarningFormat("功能未完成"); fileSystem = new HttpFileSystem(_mConsole, baseUrl); } else { // 演示了一般文件系统的访问, 实际项目中典型的情况需要自行实现基于 AssetBundle(或 7z/zip) 的文件访问层 fileSystem = new DefaultFileSystem(_mConsole); pathResolver.AddSearchPath("Scripts/out"); // pathResolver.AddSearchPath("../Scripts/out"); // _rt.AddSearchPath("Assets/Examples/Scripts/dist"); } _rt.withStacktrace = stacktrace; if (sourceMap) { _rt.EnableSourceMap(); } _rt.Initialize(new ScriptRuntimeArgs { useReflectBind = useReflectBind, fileSystem = fileSystem, pathResolver = pathResolver, listener = this, asyncManager = asyncManager, logger = _mConsole, byteBufferAllocator = new ByteBufferPooledAllocator() }); }
static void Main(string[] args) { string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); /* Usamos Trim para quitarle los espacios al inicio y Split para * guardar cada uno de los argumentos */ string history = ""; while (true) { Console.Write($"{path}>"); string readcommand = Read.ReadString(); history += readcommand + "\n"; string[] commands = readcommand.Trim().Split(); int no_commands = commands.Length; string directory; switch (commands[0].ToLower()) { case "dir": directory = no_commands > 1 ? commands[1] : path; MiniConsole.show_directories(directory); break; case "cd": directory = no_commands > 1 ? commands[1] : path; string cd = MiniConsole.change_directory(path, directory); path = cd == null?path:cd; break; case "touch": if (no_commands > 1) { MiniConsole.touch_file(path, commands[1]); } else { Print.RedPrint("Argumentos induficientes"); } break; case "move": if (no_commands > 2) { MiniConsole.move_file(path, commands[1], commands[2]); } else { Print.RedPrint("Argumentos Insuficientes"); } break; case "history": Console.WriteLine(history); break; case "cls": Console.Clear(); break; case "exit": goto End; default: Print.RedPrint("Opcion no soportada"); break; } } End :; }