Commit Graph

98 Commits

Author SHA1 Message Date
Guangcong Luo
8d79bf9725 Rename Dex.deepClone to Utils.deepClone
`this.dex.deepClone` still exists as an alias to `Utils.deepClone` for
use in `data/`. I'll need to spend more time figuring out the correct
solution there.
2020-08-21 04:24:34 -07:00
Guangcong Luo
18948c8c2c Refactor ObjectReadStreams to use for-await
Regular ReadStreams still can't; I now believe they shouldn't have a
"default" read method, and you should explicitly choose whether you
want to read "by chunks as they become available", "by chunks of a
specific line" or "by a delimiter".

So you would specifically use `stream.byLine()` or
`stream.byChunk([size])`, which would return an
`ObjectReadStream<string>`.

Inspired by #7195
2020-08-15 15:11:53 -07:00
Guangcong Luo
001f98b4f2 Fix some Streams weirdness
Pointed out by @urkerab in e91c4c5260

I'm confused it ever worked in the past.

I also added `Symbol.asyncIterator` to make `for await` work correctly.
I'm still very annoyed by `Symbol`. Especially since the spec saw no
reason not to name the other function `next`, but calling it
`asyncIterator` instead of `[Symbol.asyncIterator] was too much of a
risk??? Complete bullshit that does nothing but break backwards
compatibility.
2020-08-15 14:32:21 -07:00
Ben Davies
86c1aca097 Streams: fix ObjectReadStream _destroy method setting 2020-08-11 00:08:27 -03:00
Ben Davies
e91c4c5260 Streams: return buffers from ReadStream#readBuffer, not strings 2020-08-11 00:04:51 -03:00
Ben Davies
5cee3b401f Streams: fix _destroy method setting in ReadStream 2020-08-10 23:06:58 -03:00
Annika
b3771214d5
Fix modlog tests on Windows (#7187) 2020-08-10 09:37:08 -07:00
Mia
deeed6c789
Remove sim/ and data/'s globals (#7091) 2020-08-07 06:44:15 -07:00
Annika
f34ffa9e74
Refactor Modlog into one file (#7127) 2020-08-06 00:39:37 -07:00
Guangcong Luo
8eeec74ce0 Use TypeScript tuples for low splitFirst limits 2020-07-02 15:06:53 -04:00
Guangcong Luo
160efc9898 Fix crash after failed Net request 2020-07-02 11:25:34 -07:00
Guangcong Luo
f6d5e7f5c2 Stop showing REPL error in Windows 2020-07-01 16:37:36 -07:00
Guangcong Luo
db975b2b39
Don't automatically restart REPL server on crash
This leads to a spinlock that causes #6873
2020-06-25 02:28:23 -07:00
Guangcong Luo
9f0d6d03d3 Attempt to fix REPL crash in WSL2
For some reason, my last try failed. The error just wasn't getting
caught. This is an attempt to make it not listen to the `'close'` event
if the `listen` function throws, which might work? I'll reboot to test
in Windows when I have time.

Refs #6873
2020-06-19 22:53:31 -07:00
Guangcong Luo
dffd9dbff8 Fix stream destroying
`SubprocessStream` wasn't getting properly destroyed.
2020-06-18 21:47:03 -07:00
Guangcong Luo
39206a6959 Don't crash if FS doesn't support Unix sockets
Fixes #6873
2020-06-18 18:30:43 -07:00
Guangcong Luo
e0f97dcf6b Replace Chat.uncache* with Utils.clearRequireCache
This replaces the old approach with a new "clear everything except a
whitelist" approach, which should overall involve much less code and
lead to fewer bugs of the "the path changed for a module and I forgot
to update the uncache paths" variety.

I considered a lot of other approaches, but they seem to have more
flaws without any advantages in exchange for them. (We moved away
from `uncacheTree` because it only tracks the first require: there's
no way to get a full list of dependents for a module, only its first
dependent.)
2020-06-12 22:02:32 -07:00
Guangcong Luo
6b0b7c3228 Fix "push after end" crash 2020-06-11 17:07:36 -07:00
Guangcong Luo
713f914d75 Fix Net error behavior
A lot of Net functions returned Promises that would not reliably
resolve/reject if a Net request failed. This fixes it so they should
now all reliably reject on request failure.

(Yes, this fixes the ladder issues and memory leak in Main.)
2020-06-10 16:08:48 -07:00
Guangcong Luo
1e5b5ab465 Update Streams API with pushEnd/writeEnd
Previously, ending a read stream was `stream.push(null)`, and ending a
write stream was `stream.end()`. This was often confusing, and so now,
these are consistently `stream.pushEnd()` and `stream.writeEnd()`.

This refactor already found a bug in which `stream.end()` was used
where `stream.push(null)` should have been.

Also in this refactor: By default, `pushError` ends the stream. You can
pass `true` as the second parameter if the error is recoverable (the
stream shouldn't end).
2020-06-10 16:07:24 -07:00
Mia
6839a1f4db
Add a library for utility functions (#6817) 2020-06-09 22:06:43 -07:00
Guangcong Luo
b53480b364 Fix memory leak in ladders-remote 2020-06-09 18:31:29 -07:00
Guangcong Luo
b99c8db5d2 Fix Net library 2020-06-05 10:38:27 -07:00
Mia
cf42c6269a
Add a library for making HTTP/S requests (#6744) 2020-06-04 11:53:58 -07:00
Guangcong Luo
58b958c6fe Improve TS 3.9 property checks
These were previously fixed in 6e2b475dac, but I prefer an approach
that makes sure e.g. `pipeTo = undefined` doesn't break this check.
2020-06-04 10:23:04 -07:00
Kirk Scheibelhut
6e2b475dac Change property checks to TypeScript 3.9 2020-05-12 20:11:56 -07:00
Guangcong Luo
1dada44a2a Support server/chat-plugins/private as symlink 2020-04-25 15:51:11 -04:00
Mia
1a62036aaf
Typescript Thing of the Day (#6603) 2020-04-23 10:12:56 -07:00
Guangcong Luo
611b186265 Fix port config not being passed to child process
Fixes #6597
2020-04-21 07:26:29 -07:00
Guangcong Luo
776ccf9796
Refactor Sockets to ProcessManager+TypeScript (#6584) 2020-04-17 04:05:45 -07:00
Guangcong Luo
a74fe6e0cc Improve debugging support 2020-03-13 23:57:41 -04:00
Guangcong Luo
125fe31d06 Improve eslintrc
Fixed some more code style, allowing these rules to be enabled:

- `comma-dangle`
- `function-paren-newline`
- `member-delimiter-style`
- `no-eval`
- `no-fallthrough`
- `no-misused-promises`
- `no-unused-vars`
- `operator-linebreak`
2020-03-06 22:35:55 -08:00
Guangcong Luo
2f0e83c14b Categorize eslintrc rules
eslintrc rules are now sorted into categories, in theory making them
easier to maintain.
2020-03-06 22:35:45 -08:00
Waleed Hassan
8aa4f053bb
Use optional chaining and linter improvements (#6422)
This is mostly just a follow up to #6342.

`prefer-optional-chaining` was turned on and fixed in every location it
complained in. The transformed function [0] looks expensive from a
glance but from skimming through the replaced sites it doesn't appear
to be ran in any important place, so it should be OK.

The linter improvements are:
- Increase linter performance
	- Make `full-lint` and `lint` write to different caches so we
	  avoid overwriting their caches since they're different configs
	- Change husky's hook to `npm run lint` so as to write to the
	  same cache
	- Remove `@typescript-eslint/eslint-plugin-tslint` which is
	  essentially a wrapper to TSLint because the rules aren't worth
	  running another linter
- Convert `.eslintrc.json` and `.eslintrc-syntax.json` to two spaces
  rather than four tabs to respect PS' `.editorconfig`
- Rename `fulllint` to `full-lint` to ease spelling it

[0] - https://pastie.io/mmtxpf.js (prettified)
2020-03-06 11:44:32 -08:00
Guangcong Luo
b21c9047e2
Migrate to typescript-eslint (#6342) 2020-03-05 08:33:06 -08:00
Guangcong Luo
b1ea19d5b5 Further improve handling of crashed subprocesses 2020-02-23 01:33:35 -08:00
Guangcong Luo
e36aa987e4 Make ProcessManager more crash-resistant
ProcessManager is now able to automatically respawn subprocesses that
have crashed.
2020-02-21 22:31:16 -08:00
Waleed Hassan
34e215c7a6
Support renaming rooms (#6295) 2020-02-21 00:47:07 -08:00
Spandan Punwatkar
b6b66de896 Update Repo Links (#6102) 2019-11-28 12:47:38 +04:00
Guangcong Luo
10062ece4f Fix Koffing/Weezing Gen 7 Abilities
PS apparently doesn't have gen-accurate Ability data for Pokémon in
Gen 3 that gained Abilities between Gen 3 and Gen 4 (like Pidgeot
still has Tangled Feet in Gen 3), but that will have to be left for
a future commit.
2019-11-16 14:39:14 +13:00
Guangcong Luo
23f9bfa1b7
Split up server/chat-commands/ (#5943)
`server/chat-commands.js` is now a directory. It's been split into
`core`, `moderation`, and `admin`. `info` and `roomsettings` from
`chat-plugins` have also moved to `chat-commands`.

Some cleanup:

- Bot commands for inserting HTML into rooms like `/adduhtml` have been
  moved from `info` into `admin`.

- `/a` has been renamed `/addline`, for clarity (and also moved from
  `info` into `admin`).

- Room management commands like `/createroom` and `/roomintro` were
  moved to `room-settings`

- `chat-commands/admin` has been TypeScripted
2019-11-15 11:12:54 +13:00
asgdf
edebcbc4a9 Support loading plugins from chat-plugins/private/ (#5867) 2019-10-14 11:11:37 +11:00
Waleed Hassan
5607c158e4 Use void in promises to appease TSLint (#5827) 2019-10-03 19:08:30 +10:00
Kirk Scheibelhut
9ab3f5a668
Make /hotpatch fail if git history hasn't changed (#5688)
/forcehotpatch can be used to perform the hotpatch regardless.
2019-08-12 10:23:24 +02:00
Guangcong Luo
af8ed06abf
Fix bug in ProcessManager#destroy
Fixes #5654
2019-07-24 17:41:08 -05:00
Guangcong Luo
f374a13370 Support \u0000 in Dashycode 2019-07-12 23:38:31 -05:00
Guangcong Luo
5f6af9049f
Clarify Dashycode documentation 2019-07-12 02:04:07 -05:00
Guangcong Luo
4653cd6b15 Add documentation for Dashycode 2019-07-11 06:17:14 -05:00
Guangcong Luo
257cb76a90 Fix Dashycode non-ASCII encoding
Dashycode had a bug that made it incorrectly encode non-ASCII
characters. I think this was fixed at some point but never made it
to PS's copy of Dashycode? Anyway, fixed now.
2019-07-11 05:13:25 -05:00
Guangcong Luo
7436c1f0f2 Remove import = and export =
`import =` and `export =` are really only intended for backwards
compatibility with CommonJS. While I really don't like the new module
system TC39 has designed for us, it's what we should be using, and
consistency is important.
2019-05-16 01:27:07 +04:00