Commit Graph

174 Commits

Author SHA1 Message Date
Guangcong Luo
467b545496 Add example code for using the Sim API 2018-04-15 06:10:08 -05:00
Guangcong Luo
724c5ce7bc Fix more bugs in FileReadStream 2018-02-13 12:49:56 -05:00
Guangcong Luo
879d0a0e12 Fix FileReadStream
It hasn't been kept up to date for various stream API changes. This fix
makes it work properly again.
2018-02-14 02:29:20 +09:00
Guangcong Luo
da55a7b443 Fix crash on large modlogs 2018-02-13 23:02:18 +09:00
Guangcong Luo
1531b662c6 Refactor battle stream system
This contains a lot of minor refactors, but the main thing that's going
on here is that battle stream writes have been streamlined to be a lot
easier for others to use.

We even support:

    ./pokemon-showdown simulate-battle

which provides a stdio interface for anyone using any programming
language to simulate a battle.
2018-01-28 21:06:49 -06:00
Guangcong Luo
e6cc393109 Fix unused variable in ProcessManager 2018-01-23 07:45:03 -06:00
Guangcong Luo
0c2d712540 Fix Process Manager releasing
This now makes processWrapper.release() a lot more consistent about
actually releasing a process.
2018-01-21 11:37:30 -06:00
Guangcong Luo
2ea6f39876 Fix Process Manager default respawn
Now calling respawn() without any arguments will respawn the same
number of processes currently running.
2018-01-21 11:37:30 -06:00
Guangcong Luo
1c119bf3fa Fix streams.js doc comment
(Also improve STREAMS documentation a bit)
2018-01-20 12:16:47 -06:00
Guangcong Luo
6c10e3ade4 Fix stream destroying
This should correctly fix the memory leak in subprocess streams.
2018-01-18 20:25:28 -06:00
Guangcong Luo
327b004b74 Better support for destroying streams 2018-01-18 04:14:58 -06:00
Guangcong Luo
43103f98ae Disable ProcessManager in tests 2018-01-18 04:10:19 -06:00
Guangcong Luo
ab1f995daa Rewrite Process Manager
Process Manager is now lib/process-manager.js

It's been entirely rewritten to reflect what I think a process manager
API should look like.

In particular, there are now two Process Managers, QueryProcessManager
and StreamProcessManager.

Pass QueryProcessManager a pure-ish query function (sync or async) that
takes a JSON value and returns a JSON value, and PM.query() will
execute that function in a subprocess, and return a Promise for its
return value.

StreamProcessManager is the same idea: Pass it a function to create an
ObjectReadWriteStream, and PM.createStream() will create a stream in a
subprocess and return a stream connected to it.
2018-01-18 03:34:16 -06:00
Guangcong Luo
8f3bed7e59 Make fsPath.read() return a string by default
This is an update to match how Streams work: .read() returns a string,
and .readBuffer() returns a Buffer.

Being able to statically predict what type .read() will return is
really useful to TypeScript, in addition to being generally useful for
readability.

As a side benefit, readTextIfExists() is renamed readIfExists().
2018-01-18 03:31:13 -06:00
Guangcong Luo
df4aeebcd5 Use new Streams for FS streams 2018-01-13 03:59:09 -06:00
Guangcong Luo
4969fb0790 Add Streams library
I've finally been sufficiently frustrated by Node's Streams API to
straight-up write my own.

This is what a Streams API looks like when you don't try to pretend
Promises don't exist. So much easier to use.
2018-01-12 22:19:05 -06:00
Guangcong Luo
91d112dd98 Fix misc TypeScript bugs
The dev version of TypeScript found a variety of bugs not previously
caught for some reason; these are fixed now.
2017-12-26 14:36:13 -06:00
Guangcong Luo
0310f99f02 Refactor repl.js 2017-12-23 23:04:03 -06:00
Guangcong Luo
193e948592 Move crashlogger.js -> lib/crashlogger.js 2017-12-16 15:40:45 -06:00
Guangcong Luo
738c60ed8b Move repl.js -> lib/repl.js 2017-12-16 15:40:45 -06:00
Guangcong Luo
a9540917f5 Move fs.js -> lib/fs.js 2017-12-16 15:40:45 -06:00
Guangcong Luo
d07113dd35 New library: Dashycode
Dashycode is a library for encoding string data in restricted strings
in the [a-z0-9-] character set (namely, roomids).

...its main use is passing arbitrary string data in roomids, for HTML
rooms.
2017-12-12 03:22:09 -06:00
asgdf
c25d23a7f0 Refactor modlog (#3569) 2017-06-10 12:32:55 -05:00
Freigeist
48bfa02eb0 Some cleanup in /modlog 2014-12-09 00:32:11 +01:00