Compare commits

..

409 Commits

Author SHA1 Message Date
9fa13f49cd v0.16.0 2021-07-10 18:28:43 +08:00
64a698089b chore: update depends 2021-07-10 18:28:22 +08:00
53843b65d2 feat: backup plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-07-10 18:15:54 +08:00
5f00431e8b feat: 优化XHR相关功能
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-07-10 18:14:55 +08:00
c947ff7a14 v0.15.0 2021-06-22 15:58:29 +08:00
be2988fc58 backup: plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-06-22 15:52:27 +08:00
3beed64319 feat: remove some debug output
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-06-22 15:51:50 +08:00
23c7cb955a feat: add openjdk nashorn shim
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-06-22 15:51:28 +08:00
3be1f78a14 refactor: optimize config & plugin load
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-06-22 15:51:13 +08:00
d919fa07fc feat: bukkit chat support 1.17
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-06-22 15:24:08 +08:00
d8fd7b0a7d feat: update depends
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-06-22 15:23:47 +08:00
907f9ed03f feat: add push script
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-03-27 15:29:22 +08:00
e28d881976 v0.14.1 2021-03-27 11:38:56 +08:00
1bdb324fc4 fix: new ts version build error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-03-27 11:35:54 +08:00
5c90ac3b1f v0.14.0 2021-03-26 17:20:41 +08:00
653d7268cf chorn: update depends version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-03-26 17:20:22 +08:00
efa5e6d110 backup: plugins & docs
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-03-26 16:43:45 +08:00
ceb354f11e feat: update client
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-03-26 16:43:14 +08:00
d97af356fd fix: config value update error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-03-26 16:42:45 +08:00
6fd7174ca5 refactor: optimize websocket server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-03-26 16:42:02 +08:00
784ea2d65a refactor: rename ployfill to polyfill
Signed-off-by: MiaoWoo <admin@yumc.pw>
2021-03-26 16:18:11 +08:00
3ccc9b3d06 v0.13.0 2020-12-17 17:04:30 +08:00
beef57d85d feat: backup plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-12-17 17:02:46 +08:00
166b17b527 feat: export server & client
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-12-17 17:01:09 +08:00
d6ca19a56f feat: add netty WebSocket client
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-12-17 17:00:27 +08:00
c61f87a449 feat: js task limit exec time default 3s
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-12-17 17:00:00 +08:00
ede3f83dd5 fix: java file lineNumer lose
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-12-17 16:59:06 +08:00
69ef3b3979 feat: add compile plugin info
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-12-17 16:58:37 +08:00
BuildTools
0a8574621d v0.12.0 2020-12-07 11:19:12 +08:00
5426ec1eed fix: java thread need direct callback socket
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-12-07 11:13:30 +08:00
831f6d0916 feat: 新增Native插件管理
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-12-07 11:12:49 +08:00
1a5175f466 feat: 新增粒子相关API(未完成)
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-12-07 11:11:13 +08:00
BuildTools
2ad290bd48 v0.11.0 2020-11-20 14:26:15 +08:00
611d4e5425 fix: sponge task & command error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-11-20 14:22:28 +08:00
894d5d43e6 perf: optimize websocket logic
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-11-20 14:21:57 +08:00
cd57944cb8 feat: support full nodejs event loop
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-11-20 10:28:30 +08:00
75b34bfc48 refactor(core): core task function
move event loop task to @ccms/micro-task thread

BREAKING CHANGE: setTimeout & setInterval no longer run on main thread

Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-11-18 16:32:09 +08:00
47478e13aa refactor(websocket): upgrade socket.io
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-11-18 16:21:56 +08:00
BuildTools
17af1fd49b v0.10.1 2020-11-13 10:02:21 +08:00
b5423cd26c upgrade: dependencies version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-11-13 09:52:32 +08:00
aca864500f feat: backup plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-11-13 09:41:15 +08:00
f86e1a8c94 feat: optimize websocket
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-11-13 09:40:47 +08:00
a76f9e8b50 fix: task disable error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-11-13 09:40:34 +08:00
6dcc56b0e5 v0.10.0 2020-10-31 11:41:26 +08:00
6f8ea8290b feat: optimize config save logic
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-31 11:40:38 +08:00
1f574695a1 feat: add protocol package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-31 10:20:41 +08:00
090c0b2668 feat: backup plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-31 10:16:08 +08:00
db8f2d9bc2 feat: backup document
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-31 09:51:31 +08:00
e02f673c82 feat: optimize framework & support depends check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-13 09:24:58 +08:00
47c85f70eb v0.9.9 2020-10-02 20:00:31 +08:00
da9e2063ca fix: continer Autowired error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-02 19:57:10 +08:00
0568a7abbe v0.9.8 2020-10-02 18:59:52 +08:00
7375e8e2e9 feat: add .editorconfig
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-02 18:54:28 +08:00
41d3923d94 feat: backup plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-02 18:54:10 +08:00
f111b9891c feat: define config save & load
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-02 18:53:31 +08:00
2e4fdcb798 fix: Autowired Java class error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-02 18:48:37 +08:00
ab7ca932a3 fix: server method error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-02 16:43:18 +08:00
e8b3d43cdf feat: hide internal function
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-02 16:21:09 +08:00
eaaa0ef139 refactor: update type define
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-10-02 16:20:33 +08:00
94840ae59d feat: add papi hook
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-27 19:39:10 +08:00
c31eaeb8f6 feat: backup plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-26 22:03:49 +08:00
469a66a277 feat: update javatypes version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-26 14:50:04 +08:00
cd6a2023dc v0.9.7 2020-09-25 10:13:59 +08:00
498b0ee017 fix: config inject error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-25 10:12:28 +08:00
9bfaf984c1 v0.9.6 2020-09-24 19:26:04 +08:00
3c33ebf4e6 feat: add sender check & add prun subcommand
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-24 18:36:53 +08:00
8af69c98f3 refactor: plugin system & config manager
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-24 18:36:10 +08:00
72277f4d1a v0.9.5 2020-09-24 15:36:45 +08:00
d85f75ba1f fix: plugin bug
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-24 15:32:05 +08:00
ed14d317f4 fix: command tab complate error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-24 15:27:34 +08:00
fb8a11ea05 v0.9.4 2020-09-24 13:51:39 +08:00
eae80fa30b backup: plugins 2020-09-24
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-24 13:51:18 +08:00
3e69fc42d9 feat: compatible 1.8.8 chat
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-24 13:48:14 +08:00
c5595a65fb fix: sponge command dispatch error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-24 10:51:31 +08:00
df266905f2 feat: update client support mcsso
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-24 10:33:38 +08:00
f8046e38be fix: command registry error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-24 10:33:16 +08:00
51fb5aece3 refactor: extract proxy & fix bungee chaneel
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-24 10:31:20 +08:00
7a1dd3e7b3 feat: update dependencies version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-23 17:52:15 +08:00
8f3c799531 v0.9.3 2020-09-23 11:26:09 +08:00
3389dbd566 fix: bungee task error 2020-09-23 11:25:53 +08:00
54604e10b8 backup: plugins 2020-09-22
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-22 18:43:02 +08:00
d7247bae19 feat: optimize task impl
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-22 18:42:39 +08:00
3ee2dcad0b feat: add bungee proxy
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-22 17:36:32 +08:00
bc19021c63 feat: update Autowired & support command alias
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-22 17:36:04 +08:00
e9a4f2f351 refactor: chat & command tabComplete
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-22 15:29:12 +08:00
9be9c400ad v0.9.2 2020-09-17 17:45:04 +08:00
8eaf789bce feat: update ms system 2020-09-17 17:44:48 +08:00
7d6f6124b1 v0.9.1 2020-08-14 16:09:46 +08:00
e06fcc29e9 feat: backup plugins 2020-08-14 16:07:17 +08:00
79ece8db63 fix: bukkit chat init error & config save error 2020-08-14 16:05:44 +08:00
66c1d25888 v0.9.0 2020-07-28 09:51:56 +08:00
ca8d4778bb feat: optimize plugin event registry
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-28 09:41:10 +08:00
7dcc5ed45a feat: impl bukkit chat api
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-28 09:39:52 +08:00
91d2d836fc feat: add chat api
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-28 09:39:15 +08:00
e5e1bb70a1 revent: qrcode.ts
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-27 01:08:45 +08:00
e93a53aa9f backup: new qrcodeSigned-off-by: MiaoWoo <admin@yumc.pw>
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-27 01:07:35 +08:00
e3bceda06b fix: readSourceMap split error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-26 21:33:58 +08:00
9367e8c2c9 feat: update plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-25 15:24:02 +08:00
31c7ea2a29 feat: add keyvalue package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-24 18:45:56 +08:00
2589633069 v0.8.4 2020-07-23 14:22:30 +08:00
bc17e2f376 feat: opitmize plugin manager
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-23 13:44:55 +08:00
20749d3381 feat: add qrcode lib
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-23 13:44:39 +08:00
6261b85413 fix: reflect method error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-11 15:08:02 +08:00
da9d590374 fix: unregistry controller error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-06 17:41:50 +08:00
0af3ca8c79 feat: debug print error stack
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-06 17:41:15 +08:00
561d5b60e8 feat: backup plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-06 16:13:18 +08:00
878a5368af feat: add plugin web stage
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-06 16:10:33 +08:00
018b972aea feat: add ServerChecker
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-06 16:07:16 +08:00
4138cf9448 fix: spring tab complate error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-06 16:07:00 +08:00
646176b43c feat: split plugin ext stage exec
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-06 16:06:47 +08:00
506184a104 fix: reload plugin not effect
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-02 18:30:56 +08:00
392f01d509 v0.8.3 2020-07-02 17:08:20 +08:00
75b892e1c0 feat: enable compilerOptions importHelpers
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-02 16:57:16 +08:00
c2d825eed0 feat: update typescript version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-02 11:23:14 +08:00
393e63c017 v0.8.2 2020-07-01 14:41:21 +08:00
46d6748f31 feat: update dep version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-07-01 14:33:16 +08:00
b6803ed01c feat: update plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-30 16:02:51 +08:00
bbfc70fdd6 feat: complate @ccms/web package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-30 16:02:39 +08:00
e28af3fbbc feat: optimize process & plugin loader and scanner
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-30 15:58:51 +08:00
14eef46e67 fix: boardcast error when socket send packet
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-30 14:02:18 +08:00
1c4f512c89 v0.8.1 2020-06-23 16:15:17 +08:00
a8ae60625b feat: update config & package.json
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-23 16:07:55 +08:00
e7bc14294e feat: update script
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-23 15:53:24 +08:00
4750f31b6e feat: optimize plugin scan & load
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-23 15:51:55 +08:00
18df821049 v0.8.0 2020-06-22 18:58:05 +08:00
ef98c49e1d feat: use @javatypes defiend java type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-22 10:44:17 +08:00
5f0c3bbdd4 feat: backup plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-20 16:40:34 +08:00
bf3638dda0 feat: complate database & web
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-20 16:39:03 +08:00
842335edbe feat: add amqp & web interface
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-20 16:38:14 +08:00
f573d0c758 feat: support loader & scanner
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-17 18:39:24 +08:00
13b04a904e feat: add exit hook
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-17 18:36:25 +08:00
2c1eea5bc1 feat: add web package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-17 18:34:20 +08:00
8a07e85fda feat: support Autowired and JSClass inject
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-17 18:34:01 +08:00
32db0bba56 feat: add thread pool factory
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-17 18:28:12 +08:00
b417d8ff08 feat: add amqp package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-17 18:27:36 +08:00
6fd7038ffe feat: backup miao spring plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-17 16:11:47 +08:00
321b21a947 feat: add spring-beans type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-17 14:37:04 +08:00
0ae7346678 feat: add rabbitmq type & move spring-amqp type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-03 18:51:07 +08:00
7114876046 feat: add spring amqp & spring rabbit type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-03 18:04:46 +08:00
01fcc1337a feat: add MiaoSpring
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 18:12:37 +08:00
476f7acc39 feat: update import type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 18:12:05 +08:00
5b11be11da feat: add log history
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 18:11:45 +08:00
80c6b123c1 feat: optimize type file generate
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 18:06:15 +08:00
a7a40b374b feat: add scope login script
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 18:03:22 +08:00
9888f908e9 feat: add nocolor stack
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 18:02:49 +08:00
73ada5fd17 feat: add node-shim & move plugin interface
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 18:01:56 +08:00
79f151de5c feat: add @ccms/database
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 18:00:26 +08:00
16fcbfa69c feat: complate server & update spring
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 17:50:47 +08:00
7e1111470c feat: update console
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 17:15:54 +08:00
d407631072 feat: add spring java and ts type compatible
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 14:50:36 +08:00
4d7b27188a feat: add bungee java and ts type compatible
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 14:31:32 +08:00
7bd8302b24 feat: add jdk java and ts type compatible
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 13:11:26 +08:00
b065bcd843 feat: update bungee type file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 12:27:03 +08:00
c8a31b6d5a feat: update sponge type file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 12:06:44 +08:00
75492c77e8 feat: update jdk type file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 11:49:27 +08:00
8dbbb369b2 feat: add spring-context file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 11:46:44 +08:00
24ba6bd353 feat: update exists spring type file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-02 11:46:08 +08:00
a02bd6dc95 fix: nukkit type error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-01 15:37:23 +08:00
21cf867f43 feat: fix sponge type error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-01 15:36:07 +08:00
4290d1132e fix: error bukkit type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-01 15:34:21 +08:00
1ed5dd1d24 fix: array Type error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-06-01 14:52:10 +08:00
d751dc8614 feat: add spring type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-31 18:34:51 +08:00
c45bbb9821 feat: compatible brower behavior
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-30 10:43:33 +08:00
c9ca4ffd39 fix: websocket session send synchronized
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-30 10:18:01 +08:00
5943d6882f feat: add timcat ts type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-30 10:16:50 +08:00
d24d0d39a1 feat: update jdk ts type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-30 10:16:20 +08:00
95cd8c4889 feat: modify ws on Message params
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-26 18:48:46 +08:00
78fcbbe9a5 feat: add javax.sql type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-26 16:35:51 +08:00
baa6e95222 v0.7.0 2020-05-26 16:04:34 +08:00
3a045bd335 feat: support spring
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-26 15:55:40 +08:00
dd28d9fae5 feat: update docs
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-26 15:54:56 +08:00
72bd6b4c9c feat: add spring support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-26 15:53:41 +08:00
58478116c6 feat: support tomcat websocket
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-26 15:45:40 +08:00
d29efb2332 fix: typings can't ignore 2020-05-26 15:38:13 +08:00
0899276530 v0.6.7 2020-05-15 18:24:24 +08:00
5c3ed4e36d feat: add npm publish script 2020-05-15 16:50:12 +08:00
b926951656 feat: link .npmignore file 2020-05-15 16:46:47 +08:00
b47acf69ea v0.6.6 2020-05-15 16:20:21 +08:00
63aef1fe60 feat: support nukkit getRootLogger
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-15 16:10:55 +08:00
541a3bb96b feat: support bungee log forward
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-15 15:49:23 +08:00
873964575b feat: support get root Logger
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-15 15:48:38 +08:00
54af491399 feat: add token check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-15 14:29:13 +08:00
43d9b97347 feat: support config auto save
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-15 14:28:40 +08:00
25aef3ed62 feat: support token check & compatible more server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-14 19:05:07 +08:00
c622abecda feat: optimize import
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-14 19:04:19 +08:00
f527c225fe feat: support handshark & boardcast
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-14 19:03:41 +08:00
26eceac330 feat: update dep version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-14 09:56:13 +08:00
f5702c5080 feat: support log forward to client
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-13 18:42:41 +08:00
101f152da7 feat: complate upgrade
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-13 18:42:05 +08:00
97db272041 feat: add global eventCenter & static console source map
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-13 18:41:05 +08:00
a5ca0c2346 v0.6.5 2020-05-12 14:35:26 +08:00
aab94fe5ea feat: optimize framework
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-12 14:22:31 +08:00
d3d7a9cdbf feat: complate deploy access check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-12 00:07:05 +08:00
9dee4b3a60 feat: ignore if trace.fileName is empty
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 22:13:31 +08:00
f1863c3b39 feat: add node shim
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 22:13:03 +08:00
0120e84f3f v0.6.4 2020-05-11 17:52:13 +08:00
00130f549c feat: add npmignore
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:46:57 +08:00
fafcd09cc1 v0.6.3 2020-05-11 17:32:02 +08:00
2bd8f0c5ff feat: support address arg
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:24:26 +08:00
695a490296 feat: support online load plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:22:45 +08:00
1a546470a5 feat: support blockly online debug
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:22:15 +08:00
e68c17576a feat: compatible blockly plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:20:50 +08:00
eaee2f9c91 feat: add i18n load tip
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:19:44 +08:00
3596fc0804 feat: ignore jar:file stack info
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-10 16:25:04 +08:00
5e89872477 feat: add incremental compiler config
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-10 16:24:19 +08:00
c12670bd9e remove: plugins public file 2020-05-08 18:42:17 +08:00
b9ef3f2e33 feat: support basic plugin... 2020-05-08 18:41:56 +08:00
4b3176e98e feat: update init command... 2020-05-08 10:11:30 +08:00
4922f6a39d feat: update gitpod init command... 2020-05-08 10:05:47 +08:00
195c84e1ae feat: add gitpod config... 2020-05-08 09:53:18 +08:00
7d63a57991 feat: complate deploy feature 2020-05-08 00:50:30 +08:00
1931391cba v0.6.2 2020-05-07 18:38:28 +08:00
2dda9bd0fc fix: reload & download error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-07 18:33:10 +08:00
937b24ecda v0.6.1 2020-05-07 17:18:38 +08:00
c9eff3dae4 feat: update docs & MSPM
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-07 17:13:48 +08:00
098a4f8557 feat: support source map & reload
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-07 17:12:15 +08:00
8566c6a883 v0.6.0 2020-05-03 00:15:06 +08:00
0584ec9d85 refactor: rename scope to @ccms
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-03 00:14:47 +08:00
87f197fe06 v0.5.0 2020-04-26 10:24:49 +08:00
860946a44b feat: merge stage exec & catch error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-26 10:19:44 +08:00
f40eddd5e3 feat: update plugin & websocket
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 16:42:36 +08:00
b67474f7ff feat: support stage decorators and remove space plugin floder
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 15:38:00 +08:00
8e5588ca23 fix: netty inject error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 13:05:46 +08:00
acbeda9659 feat: support base64 source map
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 13:04:45 +08:00
a4c549d446 feat: update MiaoConsole
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-07 13:39:35 +08:00
c311d3fdb1 v0.4.2 2020-04-07 13:39:50 +08:00
1c29a059d9 feat: add 1.8.8 reflect & export io namespace
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-07 13:31:20 +08:00
d22b72f10a feat: console执行异常只打印一次
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-03 13:32:54 +08:00
e74cfda86b feat: cancel all task when disable engine
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-03 11:36:06 +08:00
24fe3b9026 feat: use module export
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 17:53:12 +08:00
ee9ae408ec feat: add internal node moudle punycode
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 14:39:00 +08:00
d679915062 feat: merge decorators meta interface
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 11:08:57 +08:00
eaa11ac89e feat: add pipeline reflect
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 11:08:15 +08:00
5ddfb1c40f upgrade: js-yaml version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-31 16:16:13 +08:00
da68821a1f v0.4.1 2020-03-31 16:16:40 +08:00
ec65d00f28 fix: disable server error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-31 14:53:23 +08:00
a2c3eff622 feat: add new nodejs modules
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-31 14:51:44 +08:00
8d2422fd64 feat: update plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-30 18:49:19 +08:00
9bc6cc1ff2 feat: instance i18n object
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-30 18:49:08 +08:00
6fc3592536 v0.4.0 2020-03-25 13:54:45 +08:00
49b96b3ac4 feat: export error handle & merge config
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 18:30:50 +08:00
73b9c2f163 feat: add api doc
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 17:59:18 +08:00
f5a7a269e4 fix: sourceMap sometime error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 15:02:20 +08:00
662e70b72c fix: ack callback call twice
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 14:52:50 +08:00
b71ce1b24d feat: optimize framework add error catch(only log)
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 13:27:11 +08:00
1ea8966f26 style: change error color
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 13:26:15 +08:00
0ed3f1fbd5 feat: complate sockt.io server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-23 18:33:12 +08:00
f4b461409b feat: add adapter and socket
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-23 00:58:53 +08:00
ace2c48ae2 feat: tracatch plugin build
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-21 15:48:45 +08:00
39861b2c46 feat: add nodejs package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-21 15:47:59 +08:00
6c9ea9fb74 feat: complate socket.io base framework
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-21 15:47:42 +08:00
15f09abce0 v0.3.2 2020-03-18 11:19:08 +08:00
eb832a0830 fix: source map print error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-18 11:15:49 +08:00
1d35c836fc refactor: move docs to MiaoDocs
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-10 13:19:48 +08:00
e53f2cea76 update: README
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:23:37 +08:00
1395865d8a feat: modify stage order
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:11:55 +08:00
bae5355c1b feat: update readme and fix container package error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:04:35 +08:00
41d2edc719 feat: add docs package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:04:02 +08:00
d608e2c066 v0.3.1 2020-03-03 01:14:22 +08:00
e7c22b5961 feat: public types package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-03 01:11:49 +08:00
18b46cdcc7 feat: complate spiget and forgesvc api
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:40:18 +08:00
d057fd5464 feat: update readme
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:38:34 +08:00
247c566219 feat: update MCBBS.MD
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:37:08 +08:00
ed9fec281c feat: add error handle
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:28:27 +08:00
15197355c5 feat: merge type defiend
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:29:29 +08:00
988bb3b914 remove: manager package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 21:00:54 +08:00
47048a5b1b feat: add complate function
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 00:32:07 +08:00
b3539d419e feat: optimize types ref
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 20:28:16 +08:00
c10247e241 fix: Dependency cycles
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 19:37:34 +08:00
553632e6ba feat: add i18n to ployfill
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 17:01:27 +08:00
6b7a729e65 feat: add NativePluginManager
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 15:19:43 +08:00
488eecba07 feat: add download and getPluginsFolder
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-29 22:28:43 +08:00
ce431aded4 feat: upgrade typescript
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-29 18:21:02 +08:00
525fde9f51 feat: add command error i18n
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-29 00:44:11 +08:00
ca11db68a6 feat: add normal env task
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 18:20:45 +08:00
3f475a7dc1 feat: MiaoConsole exclude nukkit
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 18:15:33 +08:00
e7d44af48c feat: channel add ext data
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 18:14:17 +08:00
0b416adfd2 feat: add nukkit example
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 17:59:06 +08:00
429cece606 fix: servers check error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 17:57:29 +08:00
c34b744994 v0.3.0 2020-02-27 12:27:19 +08:00
4d64a5d264 feat: optimize code
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 12:26:04 +08:00
13c0584749 feat: improve i18n scope
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 12:11:18 +08:00
f5f50d0dd6 feat: support i18n translate
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 01:58:23 +08:00
0176cabd41 feat: add package i18n
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 01:57:44 +08:00
a3f8451842 feat: remove async check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-26 10:43:47 +08:00
9ea4a067f1 feat: unmanaged baseEventDir
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-26 10:36:30 +08:00
3143851969 feat: use inversify autoProvide inject
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-26 10:15:33 +08:00
7e4c44eadd feat: exclude async event monitor
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-25 23:32:12 +08:00
e323467ed8 fix: event execute class type error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-25 23:15:39 +08:00
eba21c08dc fix: nukkit unregister event error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-25 18:25:16 +08:00
a872172fff feat: use new channel service
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 18:36:32 +08:00
c996fa6873 feat: add channel support for bungee bukkit sponge
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 18:36:08 +08:00
8616c3fe22 feat: update ignore file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:35:19 +08:00
407de98468 v0.2.1 2020-02-24 16:27:49 +08:00
c13668dbe2 feat: add nukkit support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:25:54 +08:00
a0b334b151 feat: add config support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:25:38 +08:00
d7e8b05573 feat: inject config folder
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:25:16 +08:00
9fd4b51d98 feat: add config support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:24:36 +08:00
246867b999 feat: update typescript version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 15:28:47 +08:00
381ea25b46 feat: add nukkit support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 04:02:29 +08:00
6d81a72106 feat: add nukkit package 2020-02-24 04:01:39 +08:00
f20171f898 feat: add nukkit type defiend 2020-02-24 02:54:05 +08:00
eaf491f74d v0.2.0 2020-02-24 00:21:48 +08:00
49f886c5ba feat: set manager and client to private
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:19:13 +08:00
3cf83023eb feat: update plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:13:19 +08:00
9f64f89222 feat: add config decorator bate
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:12:32 +08:00
bdecc96fcf feat: update mcbbs file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:11:46 +08:00
f660b4a4f8 feat: add auto respawn support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-23 22:35:05 +08:00
e8d41e8a43 fix: some bug at xhr and console
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-23 22:33:51 +08:00
d9e2b50953 feat: channelRead0 处理逻辑移动到业务线程
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 19:46:50 +08:00
93c83cac94 feat: update main script
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 19:03:09 +08:00
b506d06173 feat: add source map support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 19:00:26 +08:00
8d81d6938e feat: add mc console client package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 18:59:02 +08:00
d90264194c feat: remove script npx
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 18:56:02 +08:00
cc96519e80 feat: update example plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 19:40:25 +08:00
982e14953c feat: add source map support(only local)
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 19:39:45 +08:00
b0409c46ba feat: enable sourceMap
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 18:49:18 +08:00
fb3eb9704f feat: update dependencies version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 18:48:46 +08:00
effa43d42f fix: bungee servers forEach error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-14 04:03:25 +08:00
06684939bc fix: bungee unregister error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-14 04:02:37 +08:00
9eb052addb feat: chat compatible catserver
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-14 04:02:18 +08:00
9acd824656 feat: add bungee tab complate
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-09 22:07:00 +08:00
61195accc9 feat: add core-js
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-09 22:06:45 +08:00
568f723c06 feat: rename plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-08 17:07:56 +08:00
bca12d6f02 fix: compile error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-02 01:58:07 +08:00
9b3d76b6dd feat: use dom types and set Proxy global
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-02 01:56:45 +08:00
84d9eb8881 feat: update Proxy handle and optimize core index
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 03:37:56 +08:00
6b4d0cc64c feat: update Readme
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:54:03 +08:00
1d783ebd1f feat: add websocket package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:47:39 +08:00
87ac658a22 feat: add plugin stage log
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:46:55 +08:00
b793ec192f feat: move type bind and export impl function
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:46:06 +08:00
606bbb3991 feat: move global declare to @ms/ployfill
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:44:23 +08:00
cacde0627b feat: complete cross server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:48:23 +08:00
6f5254497f feat: optimize code
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:47:38 +08:00
2639fbd818 fix: sponge task callSyncMethod
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:45:39 +08:00
93997cd695 feat: optimiz plugin system
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:45:13 +08:00
268f5d2837 feat: add tellraw string
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:44:08 +08:00
5642a93974 feat: update server filter
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:43:45 +08:00
85fe0cf87a feat: plugin & cmd add server check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:11:20 +08:00
f4ea32862f feat: use inject container
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:10:30 +08:00
eaf1456771 fix: bungee event error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:09:16 +08:00
9546881691 feat: add callSyncMethod
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:08:51 +08:00
94ebbf3cba fix: with error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:08:10 +08:00
9e650aa203 feat: add plugin controller
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:28:10 +08:00
7ce0705d41 feat: update plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:27:24 +08:00
106e429a3f feat: add bungee support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:26:31 +08:00
05d12b347a feat: complete event and dispatch command
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:19:10 +08:00
7bf5f53afd feat: add tellraw & Proxy utils
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 18:38:22 +08:00
e4bb878648 feat: formatting code & remove chinese
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:48:18 +08:00
d724feaec0 feat: completion base func
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:44:14 +08:00
9cb614bebd feat: add bungee package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:43:00 +08:00
7d6269b2d3 feat: delombok and regenerate d.ts
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:42:15 +08:00
eae0ff2c1e feat: update bungee type file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 01:02:08 +08:00
093a3dda00 feat: add server module
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-14 17:44:20 +08:00
93ec202894 feat: add bungee typings
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-14 17:40:28 +08:00
a780467d87 feat: support multi code page
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-13 15:28:25 +08:00
0102b172f3 feat: upgrade version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-08 09:48:37 +08:00
64111732fb feat: update websocket server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-11-10 10:11:13 +08:00
ffa62ee243 feat: update gitignore 2019-11-09 18:35:26 +08:00
bd9af562f2 feat: add jdk support 2019-11-09 18:34:54 +08:00
59108bab27 feat: update type defiend 2019-11-07 16:40:27 +08:00
6258ae83d0 feat: add bukkit sponge jdk type 2019-11-07 15:13:28 +08:00
9fa3ed704a feat: move type def to other package 2019-11-07 15:02:05 +08:00
a76858d626 feat: add illegal plugin check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-11-05 17:03:49 +08:00
55a6b33110 feat: support async task
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-11-05 17:02:58 +08:00
b87b94aade feat: update plugin register
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-11-04 20:28:52 +08:00
4110ed2c20 feat: update config and add XHR
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-11-04 20:26:22 +08:00
3cbc101eff fix: command remove error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-11-04 20:21:31 +08:00
221b821085 feat: add xhr
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-11-04 20:20:08 +08:00
7331cfaa55 refactor: update http use XHR
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-11-04 20:19:50 +08:00
40d020ef67 feat: add server interface
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-11-04 20:18:30 +08:00
eea2a225e8 feat: complate websocket plugin 2019-10-30 20:45:59 +08:00
48f7f0fdbb feat: update ignore file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-10-29 15:38:55 +08:00
99ed76f9bb style: format file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-27 18:40:35 +08:00
7f21fa67ee feat: share decorators container
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-27 18:39:40 +08:00
8584709828 feat: add XMLHttpRequest
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-27 18:39:03 +08:00
d1f58e7482 feat: supoort mod server scan event
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-27 09:49:45 +08:00
1bd35aef6d fix: type instance error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-25 10:10:35 +08:00
fdf1088564 fix: not exist type mapping
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-25 10:10:22 +08:00
7bb4d1f6a3 feat: add sponge typings
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-25 09:55:00 +08:00
b8c3d0d19d feat: add type extend and interface
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-24 17:20:18 +08:00
a616a07553 feat: update type defiend
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-24 15:02:03 +08:00
781524f83e v0.1.1 2019-09-24 10:15:06 +08:00
c7a812c003 feat: split test plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-24 10:12:57 +08:00
325f2c8cf9 feat: modify import to reference type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-24 10:12:40 +08:00
562e2d0017 v0.1.0 2019-09-23 00:41:04 +08:00
b7871e8d33 feat: update registry in every package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-23 00:39:13 +08:00
060cffd8e7 feat: add cli sh and add hosted url in package.json
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-23 00:34:38 +08:00
4b1fb07cc9 feat: update deps
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-23 00:19:43 +08:00
0931d69188 feat: add example plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-22 23:31:52 +08:00
7d33368ebd feat: add hello world plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-22 18:02:59 +08:00
c95fc5fcff doc: add jsdoc
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-22 18:02:28 +08:00
a7479f60c8 fix: bukkit task error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-22 18:01:50 +08:00
ac75356778 feat: add start time
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-22 18:01:35 +08:00
7f32382dbc feat: modify sponge event mapping handle
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-22 18:01:13 +08:00
b3c2def36d feat: add remove plugin on disable
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-22 18:00:18 +08:00
1ea93dfb9f feat: add build:plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-22 17:59:25 +08:00
e5ffa70ed9 feat: add readme and update ts config
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-21 15:06:17 +08:00
2a60b36e23 feat: support multi stage load
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-21 15:05:37 +08:00
c4c2c0ab0f feat: complate command event and task
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-21 15:04:47 +08:00
bf5628a646 feat: add task and optimize command
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-21 15:04:25 +08:00
13e9f0a5af feat: update command and complate task
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-21 14:58:00 +08:00
cdd5f2d250 fix: command registry error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-20 09:09:29 +08:00
dfd7182008 feat: add build script
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-19 19:00:35 +08:00
533859808f feat: complate event and command module
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-19 18:59:32 +08:00
15cea1dfc8 feat: optimize api
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-19 18:59:00 +08:00
dfa43d58f0 feat: complete event module fix tab completer 2019-09-19 18:58:01 +08:00
2bf239d8ea feat: add bukkit class type
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-12 17:54:17 +08:00
cbe87cc378 feat: add plugins packages and add Test Plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-09-10 17:22:56 +08:00
256 changed files with 8399 additions and 12567 deletions

View File

@@ -1,5 +1,5 @@
{
"version": "0.19.6",
"version": "0.16.0",
"useWorkspaces": true,
"npmClient": "yarn",
"packages": [

View File

@@ -9,7 +9,8 @@
"bs": "lerna bootstrap",
"clean": "lerna run clean",
"watch": "lerna run watch --parallel",
"build": "lerna run build",
"build": "lerna run build --scope=\"@ccms/!(plugins)\"",
"build:plugins": "lerna run build --scope=\"@ccms/plugins\"",
"ug": "yarn upgrade-interactive --latest",
"np": "./script/push.sh",
"lsp": "npm login --registry=https://registry.npmjs.org --scope=@ccms",

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/amqp",
"version": "0.19.6",
"version": "0.16.0",
"description": "MiaoScript amqp package",
"keywords": [
"miaoscript",
@@ -19,17 +19,17 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@ccms/api": "^0.19.6",
"@ccms/common": "^0.19.0",
"@ccms/container": "^0.19.0"
"@ccms/api": "^0.16.0",
"@ccms/common": "^0.16.0",
"@ccms/container": "^0.16.0"
},
"devDependencies": {
"@ccms/nashorn": "^0.19.0",
"@ccms/nashorn": "^0.16.0",
"@javatypes/amqp-client": "^0.0.3",
"@javatypes/spring-amqp": "^0.0.3",
"@javatypes/spring-rabbit": "^0.0.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
}
}

View File

@@ -15,7 +15,7 @@ export abstract class ChannelAwareMessageListenerAdapter<T = any> {
if (message.getMessageProperties().getContentType() == MessageProperties.CONTENT_TYPE_JSON) {
content = JSON.parse(content)
}
} catch (error: any) {
} catch (error) {
if (manual) {
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true)
} else {
@@ -42,7 +42,7 @@ export abstract class ChannelAwareMessageListenerAdapter<T = any> {
} else {
channel.basicNack(deliveryTag, false, true)
}
} catch (error: any) {
} catch (error) {
channel.basicReject(deliveryTag, this.onError(error, message, channel))
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/api",
"version": "0.19.6",
"version": "0.16.0",
"description": "MiaoScript api package",
"keywords": [
"miaoscript",
@@ -19,9 +19,9 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@ccms/common": "^0.19.0",
"@ccms/container": "^0.19.0",
"@ccms/polyfill": "^0.19.0",
"@ccms/common": "^0.16.0",
"@ccms/container": "^0.16.0",
"@ccms/polyfill": "^0.16.0",
"base64-js": "^1.5.1",
"source-map-builder": "^0.0.7"
},
@@ -29,6 +29,6 @@
"@types/base64-js": "^1.3.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
}
}

View File

@@ -44,37 +44,12 @@ export namespace command {
protected setExecutor(plugin: plugin.Plugin, command: any, executor: Function) {
return (sender: any, _: any, command: string, args: string[]) => {
try {
let time = Date.now()
let result = executor(sender, command, Java.from(args))
let cost = Date.now() - time
if (cost > global.ScriptSlowExecuteTime) {
console.i18n("ms.api.command.execute.slow", {
player: sender.name,
plugin: plugin.description.name,
command,
args: Java.from(args).join(' '),
cost
})
}
return result
} catch (ex: any) {
console.i18n("ms.api.command.execute.error", {
player: sender.name,
plugin: plugin.description.name,
command,
args: Java.from(args).join(' '),
ex
})
return executor(sender, command, Java.from(args))
} catch (ex) {
console.i18n("ms.api.command.execute.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex })
console.ex(ex)
if (sender.name != 'CONSOLE') {
console.sender(sender, [i18n.translate("ms.api.command.execute.error", {
player: sender.name,
plugin: plugin.description.name,
command,
args: Java.from(args).join(' '),
ex
}),
...console.stack(ex)])
console.sender(sender, [i18n.translate("ms.api.command.execute.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)])
}
return true
}
@@ -83,42 +58,13 @@ export namespace command {
protected setTabCompleter(plugin: plugin.Plugin, command: any, tabCompleter: Function) {
return (sender: any, _: any, command: string, args: string[]) => {
try {
let time = Date.now()
var token = args[args.length - 1]
var complete = tabCompleter(sender, command, Java.from(args)) || []
let result = this.copyPartialMatches(complete, token)
let cost = Date.now() - time
if (cost > global.ScriptSlowExecuteTime) {
console.i18n("ms.api.command.tab.completer.slow", {
player: sender.name,
plugin: plugin.description.name,
command,
args: Java.from(args).join(' '),
cost
})
}
return result
} catch (ex: any) {
console.i18n("ms.api.command.tab.completer.error", {
player: sender.name,
plugin: plugin.description.name,
command,
args: Java.from(args).join(' '),
ex
})
return this.copyPartialMatches(complete, token)
} catch (ex) {
console.i18n("ms.api.command.tab.completer.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex })
console.ex(ex)
if (sender.name != 'CONSOLE') {
console.sender(sender, [
i18n.translate("ms.api.command.tab.completer.error", {
player: sender.name,
plugin: plugin.description.name,
command,
args: Java.from(args).join(' '),
ex
}),
...console.stack(ex)
])
}
console.sender(sender, [i18n.translate("ms.api.command.tab.completer.error", { player: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)])
return []
}
}

View File

@@ -19,7 +19,7 @@ enum LogLevel {
}
export class MiaoScriptConsole implements Console {
Console: any
Console: NodeJS.ConsoleConstructor
memory: any
private static sourceMaps: { [key: string]: SourceMapBuilder } = {}
@@ -105,7 +105,7 @@ export class MiaoScriptConsole implements Console {
let sourceMappingURL = lastLine.split('sourceMappingURL=', 2)[1]
if (sourceMappingURL.startsWith('data:application/json;base64,')) {
sourceContent = String.fromCharCode(...Array.from(base64.toByteArray(sourceMappingURL.split(',', 2)[1])))
} else if (sourceMappingURL.startsWith('http://') || sourceMappingURL.startsWith('https://')) {
} else if (sourceMappingURL.startsWith('http')) {
// TODO
} else {
let file = Paths.get(Paths.get(fileName, '..', sourceMappingURL).toFile().getCanonicalPath()).toFile()
@@ -123,7 +123,7 @@ export class MiaoScriptConsole implements Console {
if (sourceMapping && lineNumber != sourceMapping.mapping.sourceLine) { lineNumber = sourceMapping.mapping.sourceLine }
}
}
} catch (error: any) {
} catch (error) {
console.debug('search source map', fileName, 'line', lineNumber, 'error:', error)
if (global.debug) {
console.ex(error)
@@ -190,7 +190,7 @@ export class MiaoScriptConsole implements Console {
countReset(label?: string): void {
throw new Error("Method not implemented.")
}
dir(obj: any, options?: any): void {
dir(obj: any, options?: NodeJS.InspectOptions): void {
throw new Error("Method not implemented.")
}
dirxml(...data: any[]): void {

View File

@@ -57,7 +57,7 @@ export namespace event {
this.mapEvent[simpleName] = clazz
count++
}
} catch (ex: any) {
} catch (ex) {
//ignore already loaded class
}
}
@@ -82,9 +82,9 @@ export namespace event {
let eventCls = this.mapEvent[event.toLowerCase()] || this.mapEvent[event.toLowerCase() + 'event']
if (!eventCls) {
try {
eventCls = base.getClass(event)
eventCls = base.getClass(eventCls)
this.mapEvent[event] = eventCls
} catch (ex: any) {
} catch (ex) {
console.i18n("ms.api.event.not.found", { name, event })
return
}
@@ -100,11 +100,11 @@ export namespace event {
let time = Date.now()
exec(event)
let cost = Date.now() - time
if (cost > global.ScriptSlowExecuteTime) {
if (cost > 20) {
console.i18n("ms.api.event.execute.slow", { name, event: this.class2Name(eventCls), cost })
}
}
} catch (ex: any) {
} catch (ex) {
console.i18n("ms.api.event.execute.error", { name, event: this.class2Name(eventCls), ex })
console.ex(ex)
}

View File

@@ -467,7 +467,7 @@ export namespace particle {
console.warn(`ParticleTask ${this.taskId} particle ${this.particle.getUUID()} cancel because entity and location both undefined!`)
this.task.cancel()
}
} catch (error: any) {
} catch (error) {
console.error(`§6插件 §a${this.owner.description.name} §c播放粒子发送异常 §4粒子播放任务已终止!`)
console.ex(error)
this.cancel()

View File

@@ -20,7 +20,7 @@ export namespace plugin {
export abstract class PluginManager {
abstract scan(folder: string): void
abstract build(): void
abstract loadFromFile(file: string, ext?: any): Plugin
abstract loadFromFile(file: string, scanner?: plugin.PluginScanner): Plugin
abstract load(...args: any[]): void
abstract enable(...args: any[]): void
abstract disable(...args: any[]): void

View File

@@ -16,37 +16,24 @@ export namespace server {
* Runtime Server Instance
*/
export const ServerInstance = Symbol("ServerInstance")
export interface NativePlugin {
name: string
version: string
authors?: string | string[]
enable: boolean
depends?: string[]
softDepends?: string[]
/**
* 插件本体
*/
origin: any
[key: string]: any
}
@injectable()
export abstract class NativePluginManager {
list(): NativePlugin[] {
list(): any[] {
throw new Error("Method not implemented.")
}
has(name: string): boolean {
return true
}
get(name: string): NativePlugin {
get(name: string): any {
throw new Error("Method not implemented.")
}
enable(name: string): NativePlugin {
load(name: string): boolean {
throw new Error("Method not implemented.")
}
disable(name: string): NativePlugin {
unload(name: string): boolean {
throw new Error("Method not implemented.")
}
reload(name: string): NativePlugin {
reload(name: string): boolean {
throw new Error("Method not implemented.")
}
delete(name: string): boolean {
@@ -73,12 +60,6 @@ export namespace server {
getService(service: string): any {
throw new Error("Method not implemented.")
}
broadcast(message: string, permission: string) {
throw new Error("Method not implemented.")
}
broadcastMessage(message: string) {
throw new Error("Method not implemented.")
}
dispatchCommand(sender: string | any, command: string): boolean {
throw new Error("Method not implemented.")
}
@@ -134,7 +115,7 @@ export namespace server {
let consoleServer = this.getDedicatedServer()
this.reflectPipeline(consoleServer)
this.reflectRootLogger(consoleServer)
} catch (error: any) {
} catch (error) {
console.error('Error When Reflect MinecraftServer!', error)
console.ex(error)
}
@@ -148,7 +129,7 @@ export namespace server {
if (connection.class.name.indexOf('ServerConnection') !== -1
|| connection.class.name.indexOf('NetworkSystem') !== -1) { break }
connection = undefined
} catch (error: any) {
} catch (error) {
if (global.debug) {
console.ex(error)
}
@@ -160,7 +141,7 @@ export namespace server {
promise = reflect.on(connection).get(field).get().get(0)
if (promise.class.name.indexOf('Promise') !== -1) { break }
promise = undefined
} catch (error: any) {
} catch (error) {
if (global.debug) {
console.ex(error)
}
@@ -173,13 +154,13 @@ export namespace server {
protected reflectRootLogger(consoleServer: any) {
try {
this.rootLogger = reflect.on(consoleServer).get('LOGGER').get().parent
} catch (error: any) {
} catch (error) {
if (global.debug) {
console.ex(error)
}
try {
this.rootLogger = reflect.on(consoleServer).get(0).get().parent
} catch (error: any) {
} catch (error) {
if (global.debug) {
console.ex(error)
}

View File

@@ -17,7 +17,7 @@ export namespace task {
this.cacheTasks.delete(taskId)
let ownerName = task.getOwner()?.description.name
if (ownerName && this.pluginCacheTasks.has(ownerName)) {
this.pluginCacheTasks.get(ownerName)?.delete(taskId)
this.pluginCacheTasks.get(ownerName).delete(taskId)
}
})
}
@@ -142,7 +142,7 @@ export namespace task {
try {
this.func(...args)
!this.interval && process.emit('task.finish', this)
} catch (ex: any) {
} catch (ex) {
console.console('§4插件执行任务时发生错误', ex)
console.ex(ex)
}

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/bukkit",
"version": "0.19.6",
"version": "0.16.0",
"description": "MiaoScript bukkit package",
"keywords": [
"miaoscript",
@@ -22,11 +22,11 @@
"@javatypes/spigot-api": "^0.0.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
},
"dependencies": {
"@ccms/api": "^0.19.6",
"@ccms/common": "^0.19.0",
"@ccms/container": "^0.19.0"
"@ccms/api": "^0.16.0",
"@ccms/common": "^0.16.0",
"@ccms/container": "^0.16.0"
}
}

View File

@@ -1,7 +1,7 @@
import { channel, plugin } from '@ccms/api'
import { inject, provideSingleton } from '@ccms/container'
const Bukkit: typeof org.bukkit.Bukkit = Java.type('org.bukkit.Bukkit')
const Bukkit = org.bukkit.Bukkit
const PluginMessageListener = Java.type("org.bukkit.plugin.messaging.PluginMessageListener")
const Messenger = Bukkit.getMessenger()
@@ -32,7 +32,7 @@ export class BukkitChannel extends channel.Channel {
onPluginMessageReceived: (/**String */ channel, /**Player */ player, /**byte[] */data) => {
try {
listener(data, { channel, player, data })
} catch (error: any) {
} catch (error) {
console.ex(error)
}
}

View File

@@ -1,12 +1,9 @@
import { chat } from '@ccms/api'
import { provideSingleton } from '@ccms/container'
import bukkitChat from './internal/chat'
import bukkitChat from './enhance/chat'
@provideSingleton(chat.Chat)
export class BukkitChat extends chat.Chat {
get handle(): any {
return bukkitChat
}
sendJson(sender: any, json: string | object, type = 0) {
bukkitChat.send(sender, typeof json === "string" ? json : JSON.stringify(json), type)
}
@@ -19,7 +16,7 @@ export class BukkitChat extends chat.Chat {
sendTitle(sender: any, title: string, subtitle: string = '', fadeIn: number = 20, time: number = 100, fadeOut: number = 20) {
try {
sender.sendTitle(title, subtitle, fadeIn, time, fadeOut)
} catch (error: any) {
} catch (error) {
sender.sendTitle(title, subtitle)
}
}

View File

@@ -1,38 +1,35 @@
import '@ccms/nashorn'
import { command, plugin } from '@ccms/api'
import { provideSingleton, postConstruct, inject } from '@ccms/container'
import * as reflect from '@ccms/common/dist/reflect'
import { provideSingleton, postConstruct, inject } from '@ccms/container'
const Bukkit: typeof org.bukkit.Bukkit = Java.type('org.bukkit.Bukkit')
const TabCompleter = Java.type('org.bukkit.command.TabCompleter')
const PluginCommand = Java.type('org.bukkit.command.PluginCommand')
const CommandExecutor = Java.type('org.bukkit.command.CommandExecutor')
let Bukkit = org.bukkit.Bukkit
let TabCompleter = Java.type('org.bukkit.command.TabCompleter')
let PluginCommand = Java.type('org.bukkit.command.PluginCommand')
let CommandExecutor = Java.type('org.bukkit.command.CommandExecutor')
@provideSingleton(command.Command)
export class BukkitCommand extends command.Command {
@inject(plugin.PluginInstance)
private pluginInstance: any
private commandMap: any
private knownCommands: any
@postConstruct()
init() {
this.commandMap = reflect.on(Bukkit.getPluginManager()).get('commandMap').get()
this.knownCommands = reflect.on(this.commandMap).get('knownCommands').get()
}
create(plugin: any, command: string) {
var cmd = this.commandMap.getCommand(command)
if (cmd instanceof PluginCommand) { return cmd };
if (cmd && cmd instanceof PluginCommand) { return cmd };
cmd = reflect.on(PluginCommand).create(command, this.pluginInstance).get()
this.commandMap.register(plugin.description.name, cmd)
return cmd
}
remove(plugin: any, command: string) {
var cmd = this.commandMap.getCommand(command)
if (cmd instanceof PluginCommand) {
if (cmd && cmd instanceof PluginCommand) {
cmd.unregister(this.commandMap)
this.knownCommands.remove(command)
}
}
tabComplete(sender: any, input: string, index?: number): string[] {

View File

@@ -1,20 +1,20 @@
import { MiaoScriptConsole } from '@ccms/api'
const Bukkit: typeof org.bukkit.Bukkit = Java.type('org.bukkit.Bukkit')
let Bukkit = org.bukkit.Bukkit;
export class BukkitConsole extends MiaoScriptConsole {
sender(sender, ...args) {
if (!(sender instanceof Java.type('org.bukkit.command.CommandSender'))) {
this.error(`First parameter ${sender} not instanceof org.bukkit.command.CommandSender can't send message!`)
return
return;
}
if (Object.prototype.toString.call(args[0]) === "[object Array]") {
args[0].forEach(line => sender.sendMessage(this.prefix + line))
} else {
sender.sendMessage(this.prefix + args.join(' '))
sender.sendMessage(this.prefix + args.join(' '));
}
}
console(...args: string[]): void {
this.sender(Bukkit.getConsoleSender(), args.join(' '))
this.sender(Bukkit.getConsoleSender(), args.join(' '));
}
}

View File

@@ -0,0 +1,132 @@
/*global Java, base, module, exports, require*/
let ChatSerializer: any
let nmsChatSerializerMethodName: string
let PacketPlayOutChat: any
let chatMessageTypes: any
let RemapUtils: any
let playerConnectionFieldName: string
let sendPacketMethodName: string
let above_1_16 = false
let downgrade = false
/**
* 获取NMS版本
*/
let nmsVersion = undefined
let nmsSubVersion = undefined
/**
* 获取NMS类
*/
function nmsCls(name: string) {
return base.getClass(['net.minecraft.server', nmsVersion, name].join('.'))
}
function remapMethod(clazz: any, origin: string, test: string, params: any) {
try {
return clazz.getMethod(origin, params)
} catch (ex) {
if (RemapUtils) {
return clazz.getMethod(RemapUtils.mapMethod(clazz, origin, params), params)
} else {
return clazz.getMethod(test, params)
}
}
}
function remapFieldName(clazz: any, origin: string, test: string) {
try {
return clazz.getField(origin)
} catch (ex) {
if (RemapUtils) {
return clazz.getField(RemapUtils.mapFieldName(clazz, origin))
} else {
return clazz.getField(test)
}
}
}
function init() {
//@ts-ignore
nmsVersion = org.bukkit.Bukkit.server.class.name.split('.')[3]
nmsSubVersion = nmsVersion.split("_")[1]
try {
RemapUtils = Java.type('catserver.server.remapper.RemapUtils')
} catch (ex) {
}
let nmsChatSerializerClass = undefined
if (nmsSubVersion < 8) {
nmsChatSerializerClass = nmsCls("ChatSerializer")
} else if (nmsSubVersion < 17) {
nmsChatSerializerClass = nmsCls("IChatBaseComponent$ChatSerializer")
} else {
nmsChatSerializerClass = base.getClass('net.minecraft.network.chat.IChatBaseComponent$ChatSerializer')
}
let nmsChatSerializerMethod = remapMethod(nmsChatSerializerClass, 'a', 'func_150699_a', base.getClass('java.lang.String'))
nmsChatSerializerMethodName = nmsChatSerializerMethod.getName()
ChatSerializer = Java.type(nmsChatSerializerClass.getName())
let packetTypeClass = nmsSubVersion < 17 ? nmsCls("PacketPlayOutChat") : base.getClass('net.minecraft.network.protocol.game.PacketPlayOutChat')
PacketPlayOutChat = Java.type(packetTypeClass.getName())
let packetTypeConstructor: { parameterTypes: any[] }
let constructors = packetTypeClass.constructors
Java.from(constructors).forEach(function (c) {
if (c.parameterTypes.length === 2) {
packetTypeConstructor = c
}
if (c.parameterTypes.length === 3) {
packetTypeConstructor = c
above_1_16 = true
}
})
let parameterTypes = packetTypeConstructor.parameterTypes
let nmsChatMessageTypeClass = parameterTypes[1]
if (nmsChatMessageTypeClass.isEnum()) {
chatMessageTypes = nmsChatMessageTypeClass.getEnumConstants()
}
let playerConnectionField = undefined
if (nmsSubVersion < 17) {
playerConnectionField = remapFieldName(nmsCls('EntityPlayer'), 'playerConnection', 'field_71135_a')
} else {
playerConnectionField = base.getClass('net.minecraft.server.level.EntityPlayer').getField('b')
}
playerConnectionFieldName = playerConnectionField.getName()
sendPacketMethodName = remapMethod(playerConnectionField.getType(), 'sendPacket', 'func_179290_a', nmsSubVersion < 17 ? nmsCls('Packet') : base.getClass('net.minecraft.network.protocol.Packet')).getName()
}
function json(sender: { name: string }, json: string) {
if (downgrade) {
return '/tellraw ' + sender.name + ' ' + json
} else {
send(sender, json, 0)
return false
}
}
function send(sender: any, json: any, type: number) {
let packet
if (above_1_16) {
packet = new PacketPlayOutChat(ChatSerializer[nmsChatSerializerMethodName](json), chatMessageTypes == null ? type : chatMessageTypes[type], sender.getUniqueId())
} else {
packet = new PacketPlayOutChat(ChatSerializer[nmsChatSerializerMethodName](json), chatMessageTypes == null ? type : chatMessageTypes[type])
}
sendPacket(sender, packet)
}
function sendPacket(player: { handle: { [x: string]: { [x: string]: (arg0: any) => void } } }, p: any) {
player.handle[playerConnectionFieldName][sendPacketMethodName](p)
}
try {
init()
} catch (ex) {
org.bukkit.Bukkit.getConsoleSender().sendMessage(`§6[§cMS§6][§bbukkit§6][§achat§6] §cNMS Inject Error §4${ex} §cDowngrade to Command Mode...`)
downgrade = true
}
let chat = {
json,
send
}
export default chat

View File

@@ -1,13 +1,13 @@
import { event, plugin } from '@ccms/api'
import { inject, provideSingleton } from '@ccms/container'
import { inject, provideSingleton } from '@ccms/container';
import * as reflect from '@ccms/common/dist/reflect'
const Bukkit = Java.type("org.bukkit.Bukkit")
const Event = Java.type("org.bukkit.event.Event")
const Modifier = Java.type("java.lang.reflect.Modifier")
const Listener = Java.type("org.bukkit.event.Listener")
const EventPriority = Java.type("org.bukkit.event.EventPriority")
const EventExecutor = Java.type("org.bukkit.plugin.EventExecutor")
const Bukkit = Java.type("org.bukkit.Bukkit");
const Event = Java.type("org.bukkit.event.Event");
const Modifier = Java.type("java.lang.reflect.Modifier");
const Listener = Java.type("org.bukkit.event.Listener");
const EventPriority = Java.type("org.bukkit.event.EventPriority");
const EventExecutor = Java.type("org.bukkit.plugin.EventExecutor");
@provideSingleton(event.Event)
export class BukkitEvent extends event.Event {
@@ -15,7 +15,7 @@ export class BukkitEvent extends event.Event {
private pluginInstance: any
constructor() {
super('org/bukkit/event')
super('org/bukkit/event');
}
getJarFile(resource: string) {
@@ -27,10 +27,10 @@ export class BukkitEvent extends event.Event {
// 访问符为Public
Modifier.isPublic(clazz.getModifiers()) &&
// 不是抽象类
!Modifier.isAbstract(clazz.getModifiers())
!Modifier.isAbstract(clazz.getModifiers());
}
register(eventCls: any, exec: Function, priority: event.EventPriority, ignoreCancel: boolean) {
let listener = new Listener({})
let listener = new Listener({});
Bukkit.pluginManager.registerEvent(
eventCls,
listener,
@@ -39,10 +39,10 @@ export class BukkitEvent extends event.Event {
execute: exec
}),
this.pluginInstance,
ignoreCancel)
return listener
ignoreCancel);
return listener;
}
unregister(event: any, listener: any): void {
reflect.on(event).call('getHandlerList').get().unregister(listener)
reflect.on(event).call('getHandlerList').get().unregister(listener);
}
}

View File

@@ -1,176 +0,0 @@
/*global Java, base, module, exports, require*/
let bukkitChatInvoke: BukkitChatInvoke
/**
* 获取NMS类
*/
abstract class BukkitChatInvoke {
private downgrade: boolean = false
protected RemapUtils: any
protected ChatSerializer: any
protected nmsChatSerializerMethodName: string
protected PacketPlayOutChat: any
protected chatMessageTypes: any
protected playerConnectionFieldName: string
protected sendPacketMethodName: string
constructor(private nmsVersion) {
}
init() {
try {
try {
this.RemapUtils = Java.type('catserver.server.remapper.RemapUtils')
} catch (ex: any) {
}
let nmsChatSerializerClass = this.getNmsChatSerializerClass()
let nmsChatSerializerMethod = this.remapMethod(nmsChatSerializerClass, 'a', 'func_150699_a', base.getClass('java.lang.String'))
this.nmsChatSerializerMethodName = nmsChatSerializerMethod.getName()
this.ChatSerializer = Java.type(nmsChatSerializerClass.getName())
let packetTypeClass = this.getPacketPlayOutChatClass()
this.PacketPlayOutChat = Java.type(packetTypeClass.getName())
let constructors = packetTypeClass.constructors
for (const constructor of Java.from(constructors)) {
let parameterTypes = constructor.parameterTypes
if (parameterTypes.length === 2 || parameterTypes.length === 3) {
let nmsChatMessageTypeClass = parameterTypes[1]
if (nmsChatMessageTypeClass.isEnum()) {
this.chatMessageTypes = nmsChatMessageTypeClass.getEnumConstants()
break
}
}
}
let playerConnectionField = this.getPlayerConnectionField()
this.playerConnectionFieldName = playerConnectionField.getName()
this.sendPacketMethodName = this.remapMethod(playerConnectionField.getType(), 'sendPacket', 'func_179290_a', this.getPacketClass()).getName()
} catch (ex: any) {
org.bukkit.Bukkit.getConsoleSender().sendMessage(`§6[§cMS§6][§bbukkit§6][§achat§6] §cNMS Inject Error §4${ex} §cDowngrade to Command Mode...`)
this.downgrade = true
}
}
abstract getNmsChatSerializerClass()
abstract getPacketPlayOutChatClass()
abstract getPacketPlayOutChat(sender: any, json: any, type: number)
abstract getPlayerConnectionField()
abstract getPacketClass()
nmsCls(name: string) {
return base.getClass(['net.minecraft.server', this.nmsVersion, name].join('.'))
}
remapMethod(clazz: any, origin: string, test: string, params: any) {
try {
return clazz.getMethod(origin, params)
} catch (ex: any) {
if (this.RemapUtils) {
return clazz.getMethod(this.RemapUtils.mapMethod(clazz, origin, params), params)
} else {
return clazz.getMethod(test, params)
}
}
}
remapFieldName(clazz: any, origin: string, test: string) {
try {
return clazz.getField(origin)
} catch (ex: any) {
if (this.RemapUtils) {
return clazz.getField(this.RemapUtils.mapFieldName(clazz, origin))
} else {
return clazz.getField(test)
}
}
}
json(sender: { name: string }, json: string) {
if (this.downgrade) {
return '/tellraw ' + sender.name + ' ' + json
} else {
this.send(sender, json, 0)
return false
}
}
send(sender: any, json: any, type: number) {
this.sendPacket(sender, this.getPacketPlayOutChat(sender, json, type))
}
sendPacket(player: { handle: { [x: string]: { [x: string]: (arg0: any) => void } } }, p: any) {
player.handle[this.playerConnectionFieldName][this.sendPacketMethodName](p)
}
}
class BukkitChatInvokeBase extends BukkitChatInvoke {
getPacketPlayOutChat(sender: any, json: any, type: number) {
return new this.PacketPlayOutChat(this.ChatSerializer[this.nmsChatSerializerMethodName](json), type)
}
getNmsChatSerializerClass() {
return this.nmsCls("ChatSerializer")
}
getPacketPlayOutChatClass() {
return this.nmsCls("PacketPlayOutChat")
}
getPlayerConnectionField() {
return this.remapFieldName(this.nmsCls('EntityPlayer'), 'playerConnection', 'field_71135_a')
}
getPacketClass() {
return this.nmsCls('Packet')
}
}
class BukkitChatInvoke_1_7_10 extends BukkitChatInvokeBase {
}
class BukkitChatInvoke_1_8 extends BukkitChatInvoke_1_7_10 {
getPacketPlayOutChat(sender: any, json: any, type: number) {
return new this.PacketPlayOutChat(this.ChatSerializer[this.nmsChatSerializerMethodName](json), this.chatMessageTypes[type])
}
getNmsChatSerializerClass() {
return this.nmsCls("IChatBaseComponent$ChatSerializer")
}
}
class BukkitChatInvoke_1_16_5 extends BukkitChatInvoke_1_8 {
getPacketPlayOutChat(sender: any, json: any, type: number) {
return new this.PacketPlayOutChat(this.ChatSerializer[this.nmsChatSerializerMethodName](json), this.chatMessageTypes[type], sender.getUniqueId())
}
}
class BukkitChatInvoke_1_17_1 extends BukkitChatInvoke_1_16_5 {
getPacketPlayOutChatClass() {
return base.getClass('net.minecraft.network.protocol.game.PacketPlayOutChat')
}
getNmsChatSerializerClass() {
return base.getClass('net.minecraft.network.chat.IChatBaseComponent$ChatSerializer')
}
getPlayerConnectionField() {
return base.getClass('net.minecraft.server.level.EntityPlayer').getField('b')
}
getPacketClass() {
return base.getClass('net.minecraft.network.protocol.Packet')
}
}
try {
let Bukkit: typeof org.bukkit.Bukkit = Java.type('org.bukkit.Bukkit')
// @ts-ignore
let nmsVersion = Bukkit.getServer().class.name.split('.')[3]
let nmsSubVersion = nmsVersion.split("_")[1]
if (nmsSubVersion >= 8) {
bukkitChatInvoke = new BukkitChatInvoke_1_8(nmsVersion)
} else if (nmsSubVersion >= 16) {
bukkitChatInvoke = new BukkitChatInvoke_1_16_5(nmsVersion)
} else if (nmsSubVersion >= 17) {
bukkitChatInvoke = new BukkitChatInvoke_1_17_1(nmsVersion)
} else {
bukkitChatInvoke = new BukkitChatInvoke_1_7_10(nmsVersion)
}
bukkitChatInvoke.init()
} catch (ex: any) {
}
let chat = {
invoke: bukkitChatInvoke,
json: bukkitChatInvoke.json.bind(bukkitChatInvoke),
send: bukkitChatInvoke.send.bind(bukkitChatInvoke)
}
export default chat

View File

@@ -1,5 +1,5 @@
import { provideSingleton } from '@ccms/container'
import { particle } from '@ccms/api'
import { particle, plugin } from '@ccms/api'
@provideSingleton(particle.ParticleManager)
export class BukkitParticleManager extends particle.ParticleManager {

View File

@@ -1,52 +1,12 @@
import { server } from '@ccms/api'
const Bukkit: typeof org.bukkit.Bukkit = Java.type('org.bukkit.Bukkit')
const Bukkit = org.bukkit.Bukkit
export class BukkitNativePluginManager extends server.NativePluginManager {
private bukkitPluginManager: org.bukkit.plugin.PluginManager
constructor() {
super()
this.bukkitPluginManager = Bukkit.getPluginManager()
has(name: string) {
return !!this.get(name)
}
list(): server.NativePlugin[] {
return Java.from(this.bukkitPluginManager.getPlugins()).map(plugin => this.convert(plugin))
}
has(name: string): boolean {
return !!this.bukkitPluginManager.getPlugin(name)
}
get(name: string): server.NativePlugin {
return this.convert(this.bukkitPluginManager.getPlugin(name))
}
enable(name: string): server.NativePlugin {
let origin = this.bukkitPluginManager.getPlugin(name)
if (!origin) { throw new Error(`Native Plugin ${name} not found.`) }
if (!origin.isEnabled()) {
this.bukkitPluginManager.enablePlugin(origin)
}
return this.convert(origin)
}
disable(name: string): server.NativePlugin {
let origin = this.bukkitPluginManager.getPlugin(name)
if (!origin) { throw new Error(`Native Plugin ${name} not found.`) }
if (origin.isEnabled()) {
this.bukkitPluginManager.disablePlugin(origin)
}
return this.convert(origin)
}
private convert(plugin: org.bukkit.plugin.Plugin): server.NativePlugin {
if (!plugin) return plugin as any
let desc = plugin.getDescription()
return {
name: plugin.getName(),
version: desc.getVersion(),
authors: Java.from(desc.getAuthors()),
depends: Java.from(desc.getDepend()),
softDepends: Java.from(desc.getSoftDepend()),
enable: plugin.isEnabled(),
origin: plugin
}
get(name: string) {
return Bukkit.getPluginManager().getPlugin(name)
}
}

View File

@@ -1,9 +1,10 @@
import { server } from '@ccms/api'
import { server, constants } from '@ccms/api'
import { provideSingleton } from '@ccms/container'
import * as reflect from '@ccms/common/dist/reflect'
import chat from './enhance/chat'
const Bukkit: typeof org.bukkit.Bukkit = Java.type('org.bukkit.Bukkit')
let Bukkit = org.bukkit.Bukkit
@provideSingleton(server.Server)
export class BukkitServer extends server.ReflectServer {
@@ -29,12 +30,6 @@ export class BukkitServer extends server.ReflectServer {
getService(service: string) {
return Bukkit.getServicesManager().getRegistration(base.getClass(service))?.getProvider()
}
broadcast(message: string, permission: string) {
return Bukkit.broadcast(message, permission)
}
broadcastMessage(message: string) {
return Bukkit.broadcastMessage(message)
}
dispatchCommand(sender: string | any, command: string): boolean {
if (typeof sender === 'string') {
sender = this.getPlayer(sender)

View File

@@ -1,5 +1,5 @@
import { task, plugin } from '@ccms/api'
import { provideSingleton } from '@ccms/container'
import { inject, provideSingleton } from '@ccms/container'
const Bukkit = Java.type('org.bukkit.Bukkit')
const BukkitRunnable = Java.type('org.bukkit.scheduler.BukkitRunnable')
@@ -21,11 +21,11 @@ export class BukkitTaskManager extends task.TaskManager {
export class BukkitTask extends task.Task {
submit0(...args: any[]): task.Cancelable {
let run = new BukkitRunnable({ run: () => this.run(...args) })
let suffix = this.isAsync ? 'Asynchronously' : ''
let funcName = `runTask${this.interval ? 'Timer' : 'Later'}${this.isAsync ? 'Asynchronously' : ''}`
if (this.interval) {
return run[`runTaskTimer${suffix}`](base.getInstance(), this.laterTime, this.interval)
return run[funcName](base.getInstance(), this.laterTime, this.interval)
} else {
return run[`runTaskLater${suffix}`](base.getInstance(), this.laterTime)
return run[funcName](base.getInstance(), this.laterTime)
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/bungee",
"version": "0.19.6",
"version": "0.16.0",
"description": "MiaoScript bungee package",
"keywords": [
"miaoscript",
@@ -22,11 +22,11 @@
"@javatypes/bungee-api": "^0.0.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
},
"dependencies": {
"@ccms/api": "^0.19.6",
"@ccms/common": "^0.19.0",
"@ccms/container": "^0.19.0"
"@ccms/api": "^0.16.0",
"@ccms/common": "^0.16.0",
"@ccms/container": "^0.16.0"
}
}

View File

@@ -79,7 +79,7 @@ export class BungeeEvent extends event.Event {
currentPriorityMap.put(listener, methods);
this.bakeHandlers.invoke(this.eventBus, eventCls);
return listener;
} catch (ex: any) {
} catch (ex) {
console.ex(ex)
} finally {
this.lock.unlock()
@@ -108,7 +108,7 @@ export class BungeeEvent extends event.Event {
}
this.bakeHandlers.invoke(this.eventBus, eventCls);
}
} catch (ex: any) {
} catch (ex) {
console.ex(ex)
} finally {
this.lock.unlock()

View File

@@ -3,34 +3,10 @@ import { server } from '@ccms/api'
let Bungee: net.md_5.bungee.api.ProxyServer = base.getInstance().getProxy()
export class BungeeNativePluginManager extends server.NativePluginManager {
private bungeePluginManager: net.md_5.bungee.api.plugin.PluginManager
constructor() {
super()
this.bungeePluginManager = Bungee.getPluginManager()
has(name: string) {
return !!this.get(name)
}
list(): server.NativePlugin[] {
return Java.from(this.bungeePluginManager.getPlugins()).map(plugin => this.convert(plugin))
}
has(name: string): boolean {
return !!this.bungeePluginManager.getPlugin(name)
}
get(name: string): server.NativePlugin {
return this.convert(this.bungeePluginManager.getPlugin(name))
}
private convert(plugin: net.md_5.bungee.api.plugin.Plugin): server.NativePlugin {
if (!plugin) return plugin as any
let desc = plugin.getDescription()
return {
name: desc.getName(),
version: desc.getVersion(),
authors: [desc.getAuthor()],
depends: Java.from(desc.getDepends()) as any,
softDepends: Java.from(desc.getSoftDepends()) as any,
enable: true,
origin: plugin
}
get(name: string) {
return Bungee.getPluginManager().getPlugin(name)
}
}

View File

@@ -26,7 +26,7 @@ export class BungeeServer implements server.Server {
// @ts-ignore
this.pipeline = reflect.on(base.getInstance().getProxy()).get('listeners').get().toArray()[0].pipeline()
wait.cancel()
} catch (ex: any) {
} catch (ex) {
count++
if (count > 50) {
console.error('Reflect BungeeCord netty channel pipeline error time > 50times. Err: ' + ex)
@@ -38,7 +38,7 @@ export class BungeeServer implements server.Server {
}).later(10).timer(20).submit()
try {
this.rootLogger = Bungee.getLogger()
} catch (error: any) {
} catch (error) {
console.error("Can't found rootLogger!")
}
}
@@ -58,12 +58,6 @@ export class BungeeServer implements server.Server {
getService(service: string) {
throw new Error("Method not implemented.")
}
broadcast(message: string, permission: string) {
return Bungee.broadcast(message)
}
broadcastMessage(message: string) {
return Bungee.broadcast(message)
}
dispatchCommand(sender: string | any, command: string): boolean {
if (typeof sender === 'string') {
sender = this.getPlayer(sender)

View File

@@ -1 +0,0 @@
src/emp.ts

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "@ccms/client",
"version": "0.19.0",
"version": "0.16.0",
"description": "MiaoScript client package",
"keywords": [
"miaoscript",
@@ -19,19 +19,14 @@
"watch": "tsc --watch",
"build": "yarn clean && tsc",
"start": "node dist/index.js",
"debug": "DEBUG=minecraft-protocol node dist/index.js",
"emp": "node dist/emp.js",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"axios": "^0.25.0",
"minecraft-protocol": "^1.30.0",
"minecraft-protocol-forge": "^1.0.0",
"proxy-agent": "^5.0.0"
"minecraft-protocol": "^1.25.0"
},
"devDependencies": {
"@types/node": "^17.0.17",
"@types/node": "^16.3.1",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
}
}

View File

@@ -1,5 +1,5 @@
import { createInterface } from 'readline'
import { Client, createClient } from 'minecraft-protocol'
import { createClient } from 'minecraft-protocol'
import { attachForge } from './forge'
import { attachEvents } from './event'
@@ -44,24 +44,7 @@ function createConnection(host: string, port: number, username: string, password
return client
}
function attachCommon(client: Client) {
client.on('login', () => {
// client.registerChannel('updater', ['string', []])
// client.registerChannel('updater-enabled', ['string', []])
// client.registerChannel('dragoncore', ['string', []])
// client.registerChannel('dragoncore:main', ['string', []])
client.on('REGISTER', (array) => {
for (const channel of array) {
client.on('channel', console.log)
}
})
// client.on('dragoncore:main', (data) => {
// console.log(data)
// })
})
client.on('custom_payload', (data) => {
console.log('custom_payload' + JSON.stringify(data))
})
function attachCommon(client) {
client.on('error', (error) => {
console.log("Client Error", error)
})

View File

@@ -1,5 +0,0 @@
while :; do
yarn emp
echo 进程退出 休眠120秒!
sleep 120
done

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/common",
"version": "0.19.0",
"version": "0.16.0",
"description": "MiaoScript api package",
"keywords": [
"miaoscript",
@@ -19,11 +19,11 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"@ccms/nashorn": "^0.19.0",
"@ccms/nashorn": "^0.16.0",
"@javatypes/jdk": "^0.0.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
},
"gitHead": "562e2d00175c9d3a99c8b672aa07e6d92706a027"
}

View File

@@ -48,7 +48,7 @@ class Reflect {
try {
// Try getting a public field
field = this.class.getField(nameOrIndex)
} catch (ex: any) {
} catch (ex) {
// Try again, getting a non-public field
field = declaredField(this.class, nameOrIndex)
}
@@ -113,10 +113,10 @@ function declaredConstructor(clazz, param) {
let constructor
try {
constructor = clazz.getDeclaredConstructor(types(param))
} catch (ex: any) {
} catch (ex) {
try {
constructor = clazz.getDeclaredConstructor(types(param, true))
} catch (ex: any) {
} catch (ex) {
constructor = clazz.getDeclaredConstructors()[0]
}
}
@@ -132,7 +132,7 @@ function declaredField(clazz: java.lang.Class<any>, name: string | java.lang.Str
try {
field = target.getDeclaredField(name)
if (field !== null) { break }
} catch (error: any) {
} catch (e) {
if (target === undefined) { break }
target = target.getSuperclass()
}
@@ -151,10 +151,10 @@ function declaredMethod(clazz: java.lang.Class<any>, nameOrIndex: string | numbe
} else {
try {
methodCache.set(key, clazz.getMethod(nameOrIndex, clazzs as any))
} catch (ex: any) {
} catch (ex) {
try {
methodCache.set(key, clazz.getDeclaredMethod(nameOrIndex, clazzs as any))
} catch (ex: any) {
} catch (ex) {
for (const m of Java.from(declaredMethods(clazz))) {
if (m.getName() == nameOrIndex) {
methodCache.set(key, m)

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/compile",
"version": "0.19.0",
"version": "0.16.0",
"description": "MiaoScript compile package",
"keywords": [
"miaoscript",
@@ -21,6 +21,6 @@
"devDependencies": {
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/container",
"version": "0.19.0",
"version": "0.16.0",
"description": "MiaoScript container package",
"keywords": [
"miaoscript",
@@ -19,13 +19,13 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"@ccms/nashorn": "^0.19.0",
"@ccms/nashorn": "^0.16.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
},
"dependencies": {
"inversify": "^6.0.1",
"inversify": "^5.1.1",
"inversify-binding-decorators": "^4.0.0"
}
}

View File

@@ -37,8 +37,8 @@ export const provideSingletonNamed = (identifier: interfaces.ServiceIdentifier<a
*/
export const JavaClass = (className: string) => {
return function (target: object, propertyKey: string, index?: number) {
try { target[propertyKey] = Java.type(className).class; return } catch (error: any) { }
try { target[propertyKey] = base.getClass(className); return } catch (error: any) { }
try { target[propertyKey] = Java.type(className).class; return } catch (error) { }
try { target[propertyKey] = base.getClass(className); return } catch (error) { }
console.warn('JavaClass', className, 'Inject target', target.constructor.name, 'propertyKey', propertyKey, 'failed!')
}
}
@@ -49,8 +49,8 @@ export const JavaClass = (className: string) => {
*/
export const JSClass = (className: string) => {
return function (target: object, propertyKey: string, index?: number) {
try { target[propertyKey] = Java.type(className); return } catch (error: any) { }
try { target[propertyKey] = base.getClass(className).static; return } catch (error: any) { }
try { target[propertyKey] = Java.type(className); return } catch (error) { }
try { target[propertyKey] = base.getClass(className).static; return } catch (error) { }
console.warn('JSClass', className, 'Inject target', target.constructor.name, 'propertyKey', propertyKey, 'failed!')
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/core",
"version": "0.19.6",
"version": "0.16.0",
"description": "MiaoScript api package",
"keywords": [
"miaoscript",
@@ -21,11 +21,11 @@
"devDependencies": {
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
},
"dependencies": {
"@ccms/api": "^0.19.6",
"@ccms/container": "^0.19.0"
"@ccms/api": "^0.16.0",
"@ccms/container": "^0.16.0"
},
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
}

View File

@@ -1,14 +0,0 @@
function upgradeModules(core) {
if (base.version && global.ScriptEngineVersion != core['dist-tags']['latest']) {
var Paths = Java.type('java.nio.file.Paths')
base.save(Paths.get(root, "upgrade"), core['dist-tags']['latest'])
console.info('@ccms/core found new version ' + core['dist-tags']['latest'] + ' will upgrade after reboot!')
}
}
function exit() {
var http = require('@ccms/common/dist/http').default
upgradeModules(http.get('https://registry.npmmirror.com/@ccms/core'))
console.debug('exit finish!')
}
exit()

View File

@@ -17,22 +17,17 @@ class MiaoScriptCore {
private pluginManager: plugin.PluginManager
enable() {
process.emit('core.before.enable')
this.loadServerConsole()
this.loadPlugins()
process.emit('core.after.enable')
return () => this.disable()
}
loadServerConsole() {
process.emit('core.before.load.console')
//@ts-ignore
global.setGlobal('console', new this.Console(), { writable: false, configurable: false })
process.emit('core.after.load.console')
}
loadPlugins() {
process.emit('core.before.load.plugins')
let loadPluginStartTime = new Date().getTime()
console.i18n("ms.core.plugin.initialize")
this.pluginManager.scan(this.pluginFolder)
@@ -40,32 +35,15 @@ class MiaoScriptCore {
this.pluginManager.load(this.pluginManager.getPlugins())
this.pluginManager.enable(this.pluginManager.getPlugins())
console.i18n("ms.core.plugin.completed", { time: (new Date().getTime() - loadPluginStartTime) / 1000 })
process.emit('core.after.load.plugins')
}
disable() {
process.emit('core.before.disable')
let disableStartTime = Date.now()
console.i18n("ms.core.engine.disable")
this.pluginManager.disable(this.pluginManager.getPlugins())
this.taskManager.disable()
process.emit('core.after.disable')
try {
engineLoad({
script: http.get("https://ms.yumc.pw/api/plugin/download/name/exit"),
name: 'core/exit.js'
})
} catch (error: any) {
console.debug(error)
}
process.emit('core.before.exit')
process.exit(0)
console.i18n("ms.core.engine.disable.finish", {
loader: base.version,
version: 'v' + global.ScriptEngineVersion,
time: (new Date().getTime() - disableStartTime) / 1000
})
process.emit('core.after.exit')
console.i18n("ms.core.engine.disable.finish", { version: 'v' + global.ScriptEngineVersion, time: (new Date().getTime() - disableStartTime) / 1000 })
}
}
@@ -73,74 +51,53 @@ function detectServer(): constants.ServerType {
try {
Java.type("org.bukkit.Bukkit")
return constants.ServerType.Bukkit
} catch (ex: any) {
} catch (ex) {
}
try {
Java.type("org.spongepowered.api.Sponge")
return constants.ServerType.Sponge
} catch (ex: any) {
} catch (ex) {
}
try {
Java.type("cn.nukkit.Nukkit")
return constants.ServerType.Nukkit
} catch (ex: any) {
} catch (ex) {
}
try {
Java.type("net.md_5.bungee.api.ProxyServer")
return constants.ServerType.Bungee
} catch (ex: any) {
} catch (ex) {
}
try {
Java.type("org.springframework.boot.SpringApplication")
return constants.ServerType.Spring
} catch (ex: any) {
} catch (ex) {
}
throw Error('Unknow Server Type...')
}
function initialize() {
process.emit('core.before.initialize')
global.ScriptSlowExecuteTime = 30
global.ScriptEngineVersion = require('../package.json').version
try {
engineLoad({
script: http.get("https://ms.yumc.pw/api/plugin/download/name/initialize"),
name: 'core/initialize.js'
})
} catch (error: any) {
console.debug(error)
}
try { engineLoad({ script: http.get("http://ms.yumc.pw/api/plugin/download/name/initialize"), name: 'core/initialize.js' }) } catch (error) { console.debug(error) }
try {
let corePackageStartTime = new Date().getTime()
container.bind(ContainerInstance).toConstantValue(container)
container.bind(plugin.PluginInstance).toConstantValue(base.getInstance())
container.bind(plugin.PluginFolder).toConstantValue('plugins')
let type = detectServer()
process.emit('core.before.initialize.detect')
console.i18n("ms.core.initialize.detect", { scope: global.scope, type })
container.bind(server.ServerType).toConstantValue(type)
container.bind(server.ServerChecker).toSelf().inSingletonScope()
container.bind(server.NativePluginManager).toSelf().inSingletonScope()
process.emit('core.after.initialize.detect')
process.emit('core.before.package.initialize')
console.i18n("ms.core.package.initialize", { scope: global.scope, type })
require(`${global.scope}/${type}`).default(container)
require(`${global.scope}/plugin`)
container.load(buildProviderModule())
console.i18n("ms.core.package.completed", { scope: global.scope, type, time: (Date.now() - corePackageStartTime) / 1000 })
process.emit('core.after.package.initialize')
let disable = container.get<MiaoScriptCore>(MiaoScriptCore).enable()
console.i18n("ms.core.engine.completed", {
loader: base.version,
version: 'v' + global.ScriptEngineVersion,
time: (Date.now() - global.ScriptEngineStartTime) / 1000
})
process.emit('core.after.initialize')
console.i18n("ms.core.engine.completed", { version: 'v' + global.ScriptEngineVersion, time: (Date.now() - global.ScriptEngineStartTime) / 1000 })
return disable
} catch (error: any) {
} catch (error) {
console.i18n("ms.core.initialize.error", { error })
console.ex(error)
return () => console.i18n('ms.core.engine.disable.abnormal')

View File

@@ -1,51 +0,0 @@
var fs = require('@ccms/common/dist/fs')
function updateJar() {
if (!base.version) {
var pluginFolder = fs.file(fs.concat(root, '..'))
var updateFolder = fs.concat(pluginFolder, 'update')
}
}
function upgradeModules(core) {
if (base.version && global.ScriptEngineVersion != core['dist-tags']['latest']) {
var Paths = Java.type('java.nio.file.Paths')
base.save(Paths.get(root, "upgrade"), core['dist-tags']['latest'])
console.info('@ccms/core found new version ' + core['dist-tags']['latest'] + ' will upgrade after reboot!')
}
}
function initialize() {
var mspmc = 'https://ms.yumc.pw/api/plugin/download/name/'
var http = require('@ccms/common/dist/http').default
var pluginFolder = fs.concat(root, 'plugins')
var updateFolder = fs.concat(pluginFolder, 'update')
var pluginFile = fs.concat(pluginFolder, 'MiaoScriptPackageManager.js')
if (!fs.exists(pluginFile)) {
fs.mkdirs(pluginFile)
base.save(fs.concat(updateFolder, 'MiaoScriptPackageManager.auto.install'), '.')
}
fs.list(updateFolder).forEach(function (path) {
var file = path.toFile()
if (file.exists()) {
var filename = file.getName()
if (filename.endsWith(".auto.install")) {
var pluginName = filename.replace('.auto.install', '')
var pluginFile = fs.concat(pluginFolder, pluginName + '.js')
if (!fs.exists(pluginFile)) {
var pluginTemp = pluginFile + '.tmp'
http.download(mspmc + pluginName, pluginTemp)
fs.move(pluginTemp, pluginFile, true)
}
base.delete(file)
}
}
})
try {
Java.type("org.bukkit.Bukkit")
updateJar()
} catch (ignore) {
}
upgradeModules(http.get('https://registry.npmmirror.com/@ccms/core'))
console.debug('initialize finish!')
}
initialize()

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/database",
"version": "0.19.6",
"version": "0.16.0",
"description": "MiaoScript database package",
"keywords": [
"miaoscript",
@@ -22,10 +22,10 @@
"@javatypes/spring-jdbc": "^0.0.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
},
"dependencies": {
"@ccms/api": "^0.19.6",
"@ccms/container": "^0.19.0"
"@ccms/api": "^0.16.0",
"@ccms/container": "^0.16.0"
}
}

View File

@@ -17,7 +17,7 @@ export class DataBaseManager {
this.beanFactory = this.instance.getAutowireCapableBeanFactory()
let mainDatasource = this.beanFactory.getBean(Packages.javax.sql.DataSource.class)
this.mainDatabase = new DataBase({ url: mainDatasource })
} catch (error: any) {
} catch (error) {
console.ex(error)
}
}

View File

@@ -10,9 +10,9 @@ ms.core.package.initialize: "初始化 MiaoScript 扩展 {scope}/core {scope}/{t
ms.core.package.completed: "MiaoScript 扩展 {scope}/core {scope}/{type} {scope}/plugin 加载完成 耗时({time}s)"
ms.core.plugin.initialize: "MiaoScript 开始引导插件系统. 请稍候..."
ms.core.plugin.completed: "MiaoScript 插件加载完毕 耗时({time}s)!"
ms.core.engine.completed: "MiaoScript 框架 {loader} 引擎 {version} 加载完毕... 耗时({time}s)!"
ms.core.engine.completed: "MiaoScript 脚本引擎 {version} 加载完毕... 耗时({time}s)!"
ms.core.engine.disable: "MiaoScript 关闭脚本引擎 请稍候..."
ms.core.engine.disable.finish: "MiaoScript 框架 {loader} 引擎 {version} 关闭完成... 耗时({time}s)!"
ms.core.engine.disable.finish: "MiaoScript 脚本引擎 {version} 关闭完成... 耗时({time}s)!"
ms.core.engine.disable.abnormal: "引擎异常启动或初始化未完成 跳过关闭流程..."
ms.api.event.resource.not.found: "无法映射事件 未找到资源文件 {resource}!"
@@ -27,9 +27,7 @@ ms.api.event.unregister: "[{name}] 注销事件 {event} => 执行器 {exec}"
ms.api.command.register.input.error: "CommandExec 必须为一个函数... 输入: {exec}"
ms.api.command.register: "[{plugin}] 注册命令 {name}({cmd})..."
ms.api.command.unregister: "[{plugin}] 注销命令 {name}..."
ms.api.command.execute.slow: "§c注意! §6玩家 §a{player} §6执行 §b{plugin} §6插件 §d{command} {args} §6命令 §c耗时 §4{cost}ms !"
ms.api.command.execute.error: "§6玩家 §a{player} §6执行 §b{plugin} §6插件 §d{command} {args} §6命令时发生异常 §4{ex}"
ms.api.command.tab.completer.slow: "§c注意! §6玩家 §a{player} §6执行 §b{plugin} §6插件 §d{command} {args} §6补全 §c耗时 §4{cost}ms !"
ms.api.command.tab.completer.error: "§6玩家 §a{player} §6执行 §b{plugin} §6插件 §d{command} {args} §6补全时发生异常 §4{ex}"
ms.plugin.initialize: "初始化 MiaoScript 插件系统: 实例: {plugin} 加载器: {loader}..."

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/i18n",
"version": "0.19.0",
"version": "0.16.0",
"description": "MiaoScript i18n package",
"keywords": [
"miaoscript",
@@ -19,11 +19,11 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"@ccms/nashorn": "^0.19.0",
"@types/js-yaml": "^4.0.5",
"@ccms/nashorn": "^0.16.0",
"@types/js-yaml": "^4.0.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
},
"dependencies": {
"js-yaml": "^4.1.0"

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/keyvalue",
"version": "0.19.6",
"version": "0.16.0",
"description": "MiaoScript keyvalue package",
"keywords": [
"miaoscript",
@@ -19,18 +19,18 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@ccms/api": "^0.19.6",
"@ccms/common": "^0.19.0",
"@ccms/container": "^0.19.0"
"@ccms/api": "^0.16.0",
"@ccms/common": "^0.16.0",
"@ccms/container": "^0.16.0"
},
"devDependencies": {
"@ccms/nashorn": "^0.19.0",
"@ccms/nashorn": "^0.16.0",
"@javatypes/amqp-client": "^0.0.3",
"@javatypes/spring-amqp": "^0.0.3",
"@javatypes/spring-rabbit": "^0.0.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^4.5.5"
"typescript": "^4.3.5"
},
"gitHead": "2589633069d24f646ac09261b1b2304c21d4ea75"
}

View File

@@ -1,6 +0,0 @@
node_modules
perf/*
tsconfig.tsbuildinfo
.DS_STORE

View File

@@ -1,29 +0,0 @@
{
"name": "@ccms/molang",
"version": "0.19.0",
"description": "A fast parser for Minecraft's MoLang",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"clean": "rimraf dist",
"watch": "tsc --watch",
"build": "yarn clean && tsc",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/solvedDev/MoLang.git"
},
"author": "solvedDev",
"license": "MIT",
"bugs": {
"url": "https://github.com/solvedDev/MoLang/issues"
},
"homepage": "https://github.com/solvedDev/MoLang#readme",
"devDependencies": {
"@types/node": "^17.0.17",
"rimraf": "^3.0.2",
"tslib": "^2.3.1",
"typescript": "^4.5.5"
}
}

View File

@@ -1,129 +0,0 @@
import { ExecutionEnvironment } from './env/env'
import { IExpression, IParserConfig } from './main'
import { StaticExpression } from './parser/expressions/static'
import { StringExpression } from './parser/expressions/string'
import { MoLangParser } from './parser/molang'
export class MoLang {
protected expressionCache: Record<string, IExpression> = {}
protected totalCacheEntries = 0
protected executionEnvironment!: ExecutionEnvironment
protected parser: MoLangParser
constructor(
env: Record<string, unknown> = {},
protected config: Partial<IParserConfig> = {}
) {
if (config.useOptimizer === undefined) this.config.useOptimizer = true
if (config.useCache === undefined) this.config.useCache = true
if (config.earlyReturnsSkipParsing === undefined)
this.config.earlyReturnsSkipParsing = true
if (config.earlyReturnsSkipTokenization === undefined)
this.config.earlyReturnsSkipTokenization = true
if (config.convertUndefined === undefined)
this.config.convertUndefined = false
this.parser = new MoLangParser({
...this.config,
tokenizer: undefined,
})
this.updateExecutionEnv(env)
}
updateConfig(newConfig: Partial<IParserConfig>) {
newConfig = Object.assign(this.config, newConfig)
if (newConfig.tokenizer) this.parser.setTokenizer(newConfig.tokenizer)
this.parser.updateConfig({ ...this.config, tokenizer: undefined })
this.executionEnvironment.updateConfig(newConfig)
}
updateExecutionEnv(env: Record<string, unknown>, isFlat = false) {
this.executionEnvironment = new ExecutionEnvironment(env, {
useRadians: this.config.useRadians,
convertUndefined: this.config.convertUndefined,
isFlat,
variableHandler: this.config.variableHandler,
})
this.parser.setExecutionEnvironment(this.executionEnvironment)
}
/**
* Clears the MoLang expression cache
*/
clearCache() {
this.expressionCache = {}
this.totalCacheEntries = 0
}
/**
* Execute the given MoLang string `expression`
* @param expression The MoLang string to execute
*
* @returns The value the MoLang expression corresponds to
*/
execute(expression: string) {
this.parser.setExecutionEnvironment(this.executionEnvironment)
const abstractSyntaxTree = this.parse(expression)
const result = abstractSyntaxTree.eval()
if (result === undefined) return 0
if (typeof result === 'boolean') return Number(result)
return result
}
/**
* Execute the given MoLang string `expression`
* In case of errors, return 0
* @param expression The MoLang string to execute
*
* @returns The value the MoLang expression corresponds to and 0 if the statement is invalid
*/
executeAndCatch(expression: string) {
try {
return this.execute(expression)
} catch {
return 0
}
}
/**
* Parse the given MoLang string `expression`
* @param expression The MoLang string to parse
*
* @returns An AST that corresponds to the MoLang expression
*/
parse(expression: string): IExpression {
if (this.config.useCache ?? true) {
const abstractSyntaxTree = this.expressionCache[expression]
if (abstractSyntaxTree) return abstractSyntaxTree
}
this.parser.init(expression)
let abstractSyntaxTree = this.parser.parseExpression()
if ((this.config.useOptimizer ?? true) && abstractSyntaxTree.isStatic())
abstractSyntaxTree = new StaticExpression(abstractSyntaxTree.eval())
// console.log(JSON.stringify(abstractSyntaxTree, null, ' '))
if (this.config.useCache ?? true) {
if (this.totalCacheEntries > (this.config.maxCacheSize || 256))
this.clearCache()
this.expressionCache[expression] = abstractSyntaxTree
this.totalCacheEntries++
}
return abstractSyntaxTree
}
resolveStatic(ast: IExpression) {
ast.walk((expr) => {
if (expr instanceof StringExpression) return
if (expr.isStatic()) return new StaticExpression(expr.eval())
})
}
getParser() {
return this.parser
}
}

View File

@@ -1,93 +0,0 @@
import { Parser } from '../parser/parse'
import { Token } from '../parser/../tokenizer/token'
import { IPrefixParselet } from '../parser/parselets/prefix'
import { Expression, IExpression } from '../parser/expression'
import { StringExpression } from '../parser/expressions/string'
import { StatementExpression } from '../parser/expressions/statement'
import { CustomMoLangParser } from './main'
import { GroupExpression } from '../parser/expressions/group'
export class CustomFunctionParselet implements IPrefixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, token: Token) {
parser.consume('LEFT_PARENT')
if (parser.match('RIGHT_PARENT'))
throw new Error(`function() called without arguments`)
let args: string[] = []
let functionBody: IExpression | undefined
let functionName: string | undefined
do {
const expr = parser.parseExpression()
if (expr instanceof StringExpression) {
if (!functionName) functionName = <string>expr.eval()
else args.push(<string>expr.eval())
} else if (
expr instanceof StatementExpression ||
expr instanceof GroupExpression
) {
functionBody = expr
} else {
throw new Error(
`Unexpected expresion: found "${expr.constructor.name}"`
)
}
} while (parser.match('COMMA'))
parser.consume('RIGHT_PARENT')
if (!functionName)
throw new Error(
`Missing function() name (argument 1); found "${functionName}"`
)
if (!functionBody)
throw new Error(
`Missing function() body (argument ${args.length + 2})`
)
return new CustomFunctionExpression(
(<CustomMoLangParser>parser).functions,
functionName,
args,
functionBody
)
}
}
class CustomFunctionExpression extends Expression {
type = 'CustomFunctionExpression'
constructor(
functions: Map<string, [string[], string]>,
functionName: string,
args: string[],
protected functionBody: IExpression
) {
super()
functions.set(functionName, [
args,
functionBody instanceof GroupExpression
? functionBody.allExpressions[0].toString()
: functionBody.toString(),
])
}
get allExpressions() {
return [this.functionBody]
}
setExpressionAt(_: number, expr: IExpression) {
this.functionBody = expr
}
get isReturn() {
// Scopes inside of functions may use return statements
return false
}
isStatic() {
return true
}
eval() {
return 0
}
}

View File

@@ -1,229 +0,0 @@
import { ExecutionEnvironment } from '../env/env'
import { IParserConfig } from '../main'
import { MoLangParser } from '../parser/molang'
import { Tokenizer } from '../tokenizer/Tokenizer'
import { CustomFunctionParselet } from './function'
import { MoLang } from '../MoLang'
import { StatementExpression } from '../parser/expressions/statement'
import { transformStatement } from './transformStatement'
import { NameExpression } from '../parser/expressions/name'
import { ReturnExpression } from '../parser/expressions/return'
import { GenericOperatorExpression } from '../parser/expressions/genericOperator'
import { TernaryExpression } from '../parser/expressions/ternary'
import { IExpression } from '../parser/expression'
import { VoidExpression } from '../parser/expressions/void'
import { GroupExpression } from '../parser/expressions/group'
export class CustomMoLangParser extends MoLangParser {
public readonly functions = new Map<string, [string[], string]>()
constructor(config: Partial<IParserConfig>) {
super(config)
this.registerPrefix('FUNCTION', new CustomFunctionParselet())
}
reset() {
this.functions.clear()
}
}
export class CustomMoLang {
protected parser: CustomMoLangParser
constructor(env: any) {
this.parser = new CustomMoLangParser({
useCache: false,
useOptimizer: true,
useAgressiveStaticOptimizer: true,
keepGroups: true,
earlyReturnsSkipParsing: false,
earlyReturnsSkipTokenization: false,
})
this.parser.setExecutionEnvironment(
new ExecutionEnvironment(this.parser, env)
)
this.parser.setTokenizer(new Tokenizer(new Set(['function'])))
}
get functions() {
return this.parser.functions
}
parse(expression: string) {
this.parser.init(expression)
const abstractSyntaxTree = this.parser.parseExpression()
return abstractSyntaxTree
}
transform(source: string) {
const molang = new MoLang(
{},
{
useCache: false,
keepGroups: true,
useOptimizer: true,
useAgressiveStaticOptimizer: true,
earlyReturnsSkipParsing: true,
earlyReturnsSkipTokenization: false,
}
)
let totalScoped = 0
let ast = molang.parse(source)
let isComplexExpression = false
if (ast instanceof StatementExpression) {
isComplexExpression = true
}
let containsComplexExpressions = false
ast = ast.walk((expr: any) => {
// Only run code on function expressions which start with "f." or "function."
if (
expr.type !== 'FunctionExpression' ||
(!expr.name.name.startsWith?.('f.') &&
!expr.name.name.startsWith?.('function.'))
)
return
const nameExpr = expr.name
const functionName = nameExpr.name.replace(/(f|function)\./g, '')
const argValues = expr.args
let [args, functionBody] = this.functions.get(functionName) ?? []
if (!functionBody || !args) return
// Insert argument values
functionBody = functionBody.replace(
/(a|arg)\.(\w+)/g,
(match, prefix, argName) => {
const val =
argValues[args!.indexOf(argName)]?.toString() ?? '0'
return val.replace(/(t|temp)\./, 'outer_temp.')
}
)
let funcAst = transformStatement(molang.parse(functionBody))
if (funcAst instanceof StatementExpression) {
funcAst = molang.parse(`({${functionBody}}+t.return_value)`)
containsComplexExpressions = true
}
const varNameMap = new Map<string, string>()
funcAst = funcAst.walk((expr) => {
if (expr instanceof NameExpression) {
const fullName = expr.toString()
// Remove "a."/"t."/etc. from var name
let tmp = fullName.split('.')
const varType = tmp.shift()
const varName = tmp.join('.')
if (varType === 't' || varType === 'temp') {
// Scope temp./t. variables to functions
let newName = varNameMap.get(fullName)
if (!newName) {
newName = `t.__scvar${totalScoped++}`
varNameMap.set(fullName, newName)
}
expr.setName(newName)
} else if (varType === 'outer_temp') {
expr.setName(`t.${varName}`)
}
return undefined
} else if (expr instanceof ReturnExpression) {
const nameExpr = new NameExpression(
molang.getParser().executionEnv,
't.return_value'
)
const returnValExpr = expr.allExpressions[0]
return new GenericOperatorExpression(
nameExpr,
returnValExpr,
'=',
() => {
nameExpr.setPointer(returnValExpr.eval())
}
)
} else if (expr instanceof StatementExpression) {
// Make early returns work correctly by adjusting ternary statements which contain return statements
const expressions: IExpression[] = []
for (let i = 0; i < expr.allExpressions.length; i++) {
const currExpr = expr.allExpressions[i]
if (
currExpr instanceof TernaryExpression &&
currExpr.hasReturn
) {
handleTernary(
currExpr,
expr.allExpressions.slice(i + 1)
)
expressions.push(currExpr)
break
} else if (currExpr.isReturn) {
expressions.push(currExpr)
break
}
expressions.push(currExpr)
}
return new StatementExpression(expressions)
}
})
return funcAst
})
const finalAst = molang.parse(ast.toString())
molang.resolveStatic(finalAst)
return !isComplexExpression && containsComplexExpressions
? `return ${finalAst.toString()};`
: finalAst.toString()
}
reset() {
this.functions.clear()
}
}
function handleTernary(
returnTernary: TernaryExpression,
currentExpressions: IExpression[]
) {
// If & else branch end with return statements -> we can omit everything after the ternary
if (returnTernary.isReturn) return
const notReturningBranchIndex = returnTernary.allExpressions[2].isReturn
? 1
: 2
const notReturningBranch =
returnTernary.allExpressions[notReturningBranchIndex]
if (!(notReturningBranch instanceof VoidExpression)) {
if (
notReturningBranch instanceof GroupExpression &&
notReturningBranch.allExpressions[0] instanceof StatementExpression
) {
currentExpressions.unshift(...notReturningBranch.allExpressions)
} else {
currentExpressions.unshift(notReturningBranch)
}
}
if (currentExpressions.length > 0)
returnTernary.setExpressionAt(
notReturningBranchIndex,
new GroupExpression(
new StatementExpression(currentExpressions),
'{}'
)
)
}

View File

@@ -1,19 +0,0 @@
import { IExpression } from '../parser/expression'
import { GroupExpression } from '../parser/expressions/group'
import { ReturnExpression } from '../parser/expressions/return'
import { StatementExpression } from '../parser/expressions/statement'
export function transformStatement(expression: IExpression) {
if (expression instanceof ReturnExpression)
return new GroupExpression(expression.allExpressions[0], '()')
if (!(expression instanceof StatementExpression)) return expression
if (expression.allExpressions.length > 1) return expression
// Only one statement, test whether it is a return statement
const expr = expression.allExpressions[0]
if (expr instanceof ReturnExpression) {
return new GroupExpression(expr.allExpressions[0], '()')
} else {
return expression
}
}

View File

@@ -1,143 +0,0 @@
import { standardEnv } from './standardEnv'
export type TVariableHandler = (
variableName: string,
variables: Record<string, unknown>
) => unknown
export interface IEnvConfig {
useRadians?: boolean
convertUndefined?: boolean
variableHandler?: TVariableHandler
isFlat?: boolean
}
export class ExecutionEnvironment {
protected env: Record<string, any>
constructor(env: Record<string, any>, public readonly config: IEnvConfig) {
if (!env) throw new Error(`Provided environment must be an object`)
if (config.isFlat)
this.env = Object.assign(
env,
standardEnv(config.useRadians ?? false)
)
else
this.env = {
...standardEnv(config.useRadians ?? false),
...this.flattenEnv(env),
}
}
updateConfig({
variableHandler,
convertUndefined,
useRadians,
}: IEnvConfig) {
if (convertUndefined !== undefined)
this.config.convertUndefined = convertUndefined
if (typeof variableHandler === 'function')
this.config.variableHandler = variableHandler
if (!!this.config.useRadians !== !!useRadians) {
this.env = Object.assign(this.env, standardEnv(!!useRadians))
}
}
protected flattenEnv(
newEnv: Record<string, any>,
addKey = '',
current: any = {}
) {
for (let key in newEnv) {
if (key[1] === '.') {
switch (key[0]) {
case 'q':
key = 'query' + key.substring(1, key.length)
break
case 't':
key = 'temp' + key.substring(1, key.length)
break
case 'v':
key = 'variable' + key.substring(1, key.length)
break
case 'c':
key = 'context' + key.substring(1, key.length)
break
case 'f':
key = 'function' + key.substring(1, key.length)
break
}
}
if (newEnv[key].__isContext) {
current[`${addKey}${key}`] = newEnv[key].env
} else if (
typeof newEnv[key] === 'object' &&
!Array.isArray(newEnv[key])
) {
this.flattenEnv(newEnv[key], `${addKey}${key}.`, current)
} else {
current[`${addKey}${key}`] = newEnv[key]
}
}
return current
}
setAt(lookup: string, value: unknown) {
if (lookup[1] === '.') {
switch (lookup[0]) {
case 'q':
lookup = 'query' + lookup.substring(1, lookup.length)
break
case 't':
lookup = 'temp' + lookup.substring(1, lookup.length)
break
case 'v':
lookup = 'variable' + lookup.substring(1, lookup.length)
break
case 'c':
lookup = 'context' + lookup.substring(1, lookup.length)
break
case 'f':
lookup = 'function' + lookup.substring(1, lookup.length)
break
}
}
return (this.env[lookup] = value)
}
getFrom(lookup: string) {
if (lookup[1] === '.') {
switch (lookup[0]) {
case 'q':
lookup = 'query' + lookup.substring(1, lookup.length)
break
case 't':
lookup = 'temp' + lookup.substring(1, lookup.length)
break
case 'v':
lookup = 'variable' + lookup.substring(1, lookup.length)
break
case 'c':
lookup = 'context' + lookup.substring(1, lookup.length)
break
case 'f':
lookup = 'function' + lookup.substring(1, lookup.length)
break
}
}
const res =
this.env[lookup] ?? this.config.variableHandler?.(lookup, this.env)
return res === undefined && this.config.convertUndefined ? 0 : res
}
}
export class Context {
public readonly __isContext = true
constructor(public readonly env: any) {}
}

View File

@@ -1,86 +0,0 @@
const clamp = (value: number, min: number, max: number) => {
if (typeof value !== 'number' || Number.isNaN(value)) return min
else if (value > max) return max
else if (value < min) return min
return value
}
const dieRoll = (sum: number, low: number, high: number) => {
let i = 0
let total = 0
while (i < sum) total += random(low, high)
return total
}
const dieRollInt = (sum: number, low: number, high: number) => {
let i = 0
let total = 0
while (i < sum) total += randomInt(low, high)
return total
}
const hermiteBlend = (value: number) => 3 * value ** 2 - 2 * value ** 3
const lerp = (start: number, end: number, amount: number) => {
if (amount < 0) amount = 0
else if (amount > 1) amount = 1
return start + (end - start) * amount
}
// Written by @JannisX11 (https://github.com/JannisX11/MolangJS/blob/master/molang.js#L383); modified for usage inside of this MoLang parser
const lerprotate = (start: number, end: number, amount: number) => {
const radify = (n: number) => (((n + 180) % 360) + 180) % 360
start = radify(start)
end = radify(end)
if (start > end) {
let tmp = start
start = end
end = tmp
}
if (end - start > 180) return radify(end + amount * (360 - (end - start)))
else return start + amount * (end - start)
}
const mod = (value: number, denominator: number) => value % denominator
const random = (low: number, high: number) => low + Math.random() * (high - low)
const randomInt = (low: number, high: number) =>
Math.round(low + Math.random() * (high - low))
const minAngle = (value: number) => {
value = value % 360
value = (value + 360) % 360
if (value > 179) value -= 360
return value
}
export const MoLangMathLib = (useRadians: boolean) => {
const degRadFactor = useRadians ? 1 : Math.PI / 180
return {
'math.abs': Math.abs,
'math.acos': (x: number) => Math.acos(x) / degRadFactor,
'math.asin': (x: number) => Math.asin(x) / degRadFactor,
'math.atan': (x: number) => Math.atan(x) / degRadFactor,
'math.atan2': (y: number, x: number) => Math.atan2(y, x) / degRadFactor,
'math.ceil': Math.ceil,
'math.clamp': clamp,
'math.cos': (x: number) => Math.cos(x * degRadFactor),
'math.die_roll': dieRoll,
'math.die_roll_integer': dieRollInt,
'math.exp': Math.exp,
'math.floor': Math.floor,
'math.hermite_blend': hermiteBlend,
'math.lerp': lerp,
'math.lerp_rotate': lerprotate,
'math.ln': Math.log,
'math.max': Math.max,
'math.min': Math.min,
'math.min_angle': minAngle,
'math.mod': mod,
'math.pi': Math.PI,
'math.pow': Math.pow,
'math.random': random,
'math.random_integer': randomInt,
'math.round': Math.round,
'math.sin': (x: number) => Math.sin(x * degRadFactor),
'math.sqrt': Math.sqrt,
'math.trunc': Math.trunc,
}
}

View File

@@ -1,25 +0,0 @@
const inRange = (value: number, min: number, max: number) => {
// Check that value, min and max are numbers
if (
typeof value !== 'number' ||
typeof min !== 'number' ||
typeof max !== 'number'
) {
console.error('"query.in_range": value, min and max must be numbers')
return false
}
return value >= min && value <= max
}
const all = (mustMatch: unknown, ...values: unknown[]) =>
values.every((v) => v === mustMatch)
const any = (mustMatch: unknown, ...values: unknown[]) =>
values.some((v) => v === mustMatch)
export const standardQueries = {
'query.in_range': inRange,
'query.all': all,
'query.any': any,
}

View File

@@ -1,7 +0,0 @@
import { MoLangMathLib } from './math'
import { standardQueries } from './queries'
export const standardEnv = (useRadians: boolean) => ({
...MoLangMathLib(useRadians),
...standardQueries,
})

View File

@@ -1 +0,0 @@
export * from './main'

View File

@@ -1,91 +0,0 @@
import { TVariableHandler } from './env/env'
import { Tokenizer } from './tokenizer/Tokenizer'
/**
* How the parser and interpreter should handle your MoLang expression
*/
export interface IParserConfig {
/**
* Whether a cache should be used to speed up executing MoLang.
* The cache saves an AST for every parsed expression.
* This allows us to skip the tokenization & parsing step before executing known MoLang expressions
*
* Default: true
*/
useCache: boolean
/**
* How many expressions can be cached. After reaching `maxCacheSize`, the whole cache is cleared automatically.
* Can be set to `Infinity` to remove the limit completely
*
* Default: 256
*/
maxCacheSize: number
/**
* The optimizer can drastically speed up parsing & executing MoLang.
* It enables skipping of unreachable statements, pre-evaluating static expressions and skipping of statements with no effect
* when used together with the `useAgressiveStaticOptimizer` option
*
* Default: true
*/
useOptimizer: boolean
/**
* Skip execution of statements with no effect
* when used together with the `useOptimizer` option
*
* Default: true
*/
useAgressiveStaticOptimizer: boolean
/**
* This options makes early return statements skip all parsing work completely
*
* Default: true
*/
earlyReturnsSkipParsing: boolean
/**
* This options makes early return statements skip all tokenization work completely if earlyReturnsSkipParsing is set to true
*
* Default: true
*/
earlyReturnsSkipTokenization: boolean
/**
* Tokenizer to use for tokenizing the expression
*/
tokenizer: Tokenizer
/**
* Create expression instances for brackets ("()", "{}")
*
* This should only be set to true if you want to use the .toString() method of an expression
* or you want to iterate over the whole AST
*
* Default: false
*/
keepGroups: boolean
/**
* Whether to convert undefined variables to "0"
*
* Default: false
*/
convertUndefined: boolean
/**
* Use radians instead of degrees for trigonometric functions
*
* Default: false
*/
useRadians: boolean
/**
* Resolve undefined variables
*/
variableHandler: TVariableHandler
}
export { Tokenizer } from './tokenizer/Tokenizer'
export { IExpression } from './parser/expression'
export { CustomMoLang } from './custom/main'
export { MoLang } from './MoLang'
export * as expressions from './parser/expressions/index'
export { Context } from './env/env'

View File

@@ -1,57 +0,0 @@
/**
* Interface that describes an AST Expression
*/
export interface IExpression {
readonly type: string
readonly isReturn?: boolean
readonly isBreak?: boolean
readonly isContinue?: boolean
readonly allExpressions: IExpression[]
setFunctionCall?: (value: boolean) => void
setPointer?: (value: unknown) => void
setExpressionAt(index: number, expr: IExpression): void
eval(): unknown
isStatic(): boolean
walk(cb: TIterateCallback): IExpression
iterate(cb: TIterateCallback, visited: Set<IExpression>): void
}
export abstract class Expression implements IExpression {
public abstract readonly type: string
abstract eval(): unknown
abstract isStatic(): boolean
toString() {
return `${this.eval()}`
}
abstract allExpressions: IExpression[]
abstract setExpressionAt(index: number, expr: IExpression): void
walk(cb: TIterateCallback, visited = new Set<IExpression>()): IExpression {
let expr = cb(this) ?? this
expr.iterate(cb, visited)
return expr
}
iterate(cb: TIterateCallback, visited: Set<IExpression>) {
for (let i = 0; i < this.allExpressions.length; i++) {
const originalExpr = this.allExpressions[i]
if (visited.has(originalExpr)) continue
else visited.add(originalExpr)
const expr = cb(originalExpr) ?? originalExpr
if (expr !== originalExpr && visited.has(expr)) continue
else visited.add(expr)
this.setExpressionAt(i, expr)
expr.iterate(cb, visited)
}
}
}
export type TIterateCallback = (expr: IExpression) => IExpression | undefined

View File

@@ -1,32 +0,0 @@
import { Expression, IExpression } from '../expression'
export class ArrayAccessExpression extends Expression {
type = 'ArrayAccessExpression'
constructor(protected name: IExpression, protected lookup: IExpression) {
super()
}
get allExpressions() {
return [this.name, this.lookup]
}
setExpressionAt(index: number, expr: IExpression) {
if (index === 0) this.name = expr
else if (index === 1) this.lookup = expr
}
isStatic() {
return false
}
setPointer(value: unknown) {
;(<any>this.name.eval())[<number>this.lookup.eval()] = value
}
eval() {
return (<any>this.name.eval())[<number>this.lookup.eval()]
}
toString() {
return `${this.name.toString()}[${this.lookup.toString()}]`
}
}

View File

@@ -1,21 +0,0 @@
import { Expression } from '../expression'
export class BooleanExpression extends Expression {
type = 'BooleanExpression'
constructor(protected value: boolean) {
super()
}
get allExpressions() {
return []
}
setExpressionAt() {}
isStatic() {
return true
}
eval() {
return this.value
}
}

View File

@@ -1,26 +0,0 @@
import { Expression } from '../expression'
export class BreakExpression extends Expression {
type = 'BreakExpression'
isBreak = true
constructor() {
super()
}
get allExpressions() {
return []
}
setExpressionAt() {}
isStatic() {
return false
}
eval() {
return 0
}
isString() {
return 'break'
}
}

View File

@@ -1,48 +0,0 @@
import { ExecutionEnvironment } from '../../env/env'
import { Expression, IExpression } from '../expression'
import { NameExpression } from './name'
export class ContextSwitchExpression extends Expression {
type = 'NameExpression'
constructor(
protected leftExpr: NameExpression,
protected rightExpr: NameExpression
) {
super()
}
get allExpressions() {
return [this.leftExpr, this.rightExpr]
}
setExpressionAt(index: number, expr: IExpression) {
if (!(expr instanceof NameExpression))
throw new Error(
`Cannot use context switch operator "->" on ${expr.type}`
)
if (index === 0) this.leftExpr = expr
else if (index === 1) this.rightExpr = expr
}
isStatic() {
return false
}
eval() {
const context = this.leftExpr.eval()
if (typeof context !== 'object') return 0
this.rightExpr.setExecutionEnv(
new ExecutionEnvironment(
context,
this.rightExpr.executionEnv.config
)
)
return this.rightExpr.eval()
}
toString() {
return `${this.leftExpr.toString()}->${this.rightExpr.toString()}`
}
}

View File

@@ -1,26 +0,0 @@
import { Expression } from '../expression'
export class ContinueExpression extends Expression {
type = 'ContinueExpression'
isContinue = true
constructor() {
super()
}
get allExpressions() {
return []
}
setExpressionAt() {}
isStatic() {
return false
}
eval() {
return 0
}
toString() {
return 'continue'
}
}

View File

@@ -1,63 +0,0 @@
import { Expression, IExpression } from '../expression'
export class ForEachExpression extends Expression {
type = 'ForEachExpression'
constructor(
protected variable: IExpression,
protected arrayExpression: IExpression,
protected expression: IExpression
) {
super()
if (!this.variable.setPointer)
throw new Error(
`First for_each() argument must be a variable, received "${typeof this.variable.eval()}"`
)
}
get isReturn() {
return this.expression.isReturn
}
get allExpressions() {
return [this.variable, this.arrayExpression, this.expression]
}
setExpressionAt(index: number, expr: IExpression) {
if (index === 0) this.variable = expr
else if (index === 1) this.arrayExpression = expr
else if (index === 2) this.expression = expr
}
isStatic() {
return (
this.variable.isStatic() &&
this.arrayExpression.isStatic() &&
this.expression.isStatic()
)
}
eval() {
const array = this.arrayExpression.eval()
if (!Array.isArray(array))
throw new Error(
`Second for_each() argument must be an array, received "${typeof array}"`
)
let i = 0
while (i < array.length) {
// Error detection for this.variable is part of the constructor
this.variable.setPointer?.(array[i++])
const res = this.expression.eval()
if (this.expression.isBreak) break
else if (this.expression.isContinue) continue
else if (this.expression.isReturn) return res
}
return 0
}
toString() {
return `loop(${this.variable.toString()},${this.arrayExpression.toString()},${this.expression.toString()})`
}
}

View File

@@ -1,46 +0,0 @@
import { NameExpression } from './name'
import { Expression, IExpression } from '../expression'
export class FunctionExpression extends Expression {
type = 'FunctionExpression'
constructor(protected name: IExpression, protected args: IExpression[]) {
super()
}
get allExpressions() {
return [this.name, ...this.args]
}
setExpressionAt(index: number, expr: Expression) {
if (index === 0) this.name = expr
else if (index > 0) this.args[index - 1] = expr
}
isStatic() {
return false
}
eval() {
const args: unknown[] = []
let i = 0
while (i < this.args.length) args.push(this.args[i++].eval())
const func = <(...args: unknown[]) => unknown>this.name.eval()
if (typeof func !== 'function')
throw new Error(
`${(<NameExpression>this.name).toString()} is not callable!`
)
return func(...args)
}
toString() {
let str = `${this.name.toString()}(`
for (let i = 0; i < this.args.length; i++) {
str += `${this.args[i].toString()}${
i + 1 < this.args.length ? ',' : ''
}`
}
return `${str})`
}
}

View File

@@ -1,37 +0,0 @@
import { Expression, IExpression } from '../expression'
export class GenericOperatorExpression extends Expression {
type = 'GenericOperatorExpression'
constructor(
protected left: IExpression,
protected right: IExpression,
protected operator: string,
protected evalHelper: (
leftExpression: IExpression,
rightExpression: IExpression
) => unknown
) {
super()
}
get allExpressions() {
return [this.left, this.right]
}
setExpressionAt(index: number, expr: IExpression) {
if (index === 0) this.left = expr
else if (index === 1) this.right = expr
}
isStatic() {
return this.left.isStatic() && this.right.isStatic()
}
eval() {
return this.evalHelper(this.left, this.right)
}
toString() {
return `${this.left.toString()}${this.operator}${this.right.toString()}`
}
}

View File

@@ -1,38 +0,0 @@
import { Expression, IExpression } from '../expression'
export class GroupExpression extends Expression {
type = 'GroupExpression'
constructor(protected expression: IExpression, protected brackets: string) {
super()
}
get allExpressions() {
return [this.expression]
}
setExpressionAt(_: number, expr: IExpression) {
this.expression = expr
}
isStatic() {
return this.expression.isStatic()
}
get isReturn() {
return this.expression.isReturn
}
get isBreak() {
return this.expression.isBreak
}
get isContinue() {
return this.expression.isContinue
}
eval() {
return this.expression.eval()
}
toString() {
return `${this.brackets[0]}${this.expression.toString()}${
this.brackets[1]
}`
}
}

View File

@@ -1,19 +0,0 @@
export { ArrayAccessExpression } from './arrayAccess'
export { BooleanExpression } from './boolean'
export { BreakExpression } from './break'
export { ContinueExpression } from './continue'
export { ForEachExpression } from './forEach'
export { FunctionExpression } from './function'
export { GenericOperatorExpression } from './genericOperator'
export { GroupExpression } from './group'
export { LoopExpression } from './loop'
export { NameExpression } from './name'
export { NumberExpression } from './number'
export { PostfixExpression } from './postfix'
export { PrefixExpression } from './prefix'
export { ReturnExpression } from './return'
export { StatementExpression } from './statement'
export { StaticExpression } from './static'
export { StringExpression } from './string'
export { TernaryExpression } from './ternary'
export { VoidExpression } from './void'

View File

@@ -1,56 +0,0 @@
import { Expression, IExpression } from '../expression'
export class LoopExpression extends Expression {
type = 'LoopExpression'
constructor(
protected count: IExpression,
protected expression: IExpression
) {
super()
}
get allExpressions() {
return [this.count, this.expression]
}
setExpressionAt(index: number, expr: IExpression) {
if (index === 0) this.count = expr
else if (index === 1) this.expression = expr
}
get isReturn() {
return this.expression.isReturn
}
isStatic() {
return this.count.isStatic() && this.expression.isStatic()
}
eval() {
const repeatCount = Number(this.count.eval())
if (Number.isNaN(repeatCount))
throw new Error(
`First loop() argument must be of type number, received "${typeof this.count.eval()}"`
)
if (repeatCount > 1024)
throw new Error(
`Cannot loop more than 1024x times, received "${repeatCount}"`
)
let i = 0
while (i < repeatCount) {
i++
const res = this.expression.eval()
if (this.expression.isBreak) break
else if (this.expression.isContinue) continue
else if (this.expression.isReturn) return res
}
return 0
}
toString() {
return `loop(${this.count.toString()},${this.expression.toString()})`
}
}

View File

@@ -1,47 +0,0 @@
import { ExecutionEnvironment } from '../../env/env'
import { Expression } from '../expression'
export class NameExpression extends Expression {
type = 'NameExpression'
constructor(
public executionEnv: ExecutionEnvironment,
protected name: string,
protected isFunctionCall = false
) {
super()
}
get allExpressions() {
return []
}
setExpressionAt() {}
isStatic() {
return false
}
setPointer(value: unknown) {
this.executionEnv.setAt(this.name, value)
}
setFunctionCall(value = true) {
this.isFunctionCall = value
}
setName(name: string) {
this.name = name
}
setExecutionEnv(executionEnv: ExecutionEnvironment) {
this.executionEnv = executionEnv
}
eval() {
const value = this.executionEnv.getFrom(this.name)
if (!this.isFunctionCall && typeof value === 'function') return value()
return value
}
toString() {
return this.name
}
}

View File

@@ -1,25 +0,0 @@
import { Expression } from '../expression'
export class NumberExpression extends Expression {
type = 'NumberExpression'
constructor(protected value: number) {
super()
}
get allExpressions() {
return []
}
setExpressionAt() {}
isStatic() {
return true
}
eval() {
return this.value
}
toString() {
return '' + this.value
}
}

View File

@@ -1,32 +0,0 @@
import { TTokenType } from '../../tokenizer/token'
import { Expression, IExpression } from '../expression'
export class PostfixExpression extends Expression {
type = 'PostfixExpression'
constructor(
protected expression: IExpression,
protected tokenType: TTokenType
) {
super()
}
get allExpressions() {
return [this.expression]
}
setExpressionAt(_: number, expr: IExpression) {
this.expression = expr
}
isStatic() {
return this.expression.isStatic()
}
eval() {
switch (this.tokenType) {
case 'X': {
// DO SOMETHING
}
}
}
}

View File

@@ -1,57 +0,0 @@
import { TTokenType } from '../../tokenizer/token'
import { Expression, IExpression } from '../expression'
export class PrefixExpression extends Expression {
type = 'PrefixExpression'
constructor(
protected tokenType: TTokenType,
protected expression: IExpression
) {
super()
}
get allExpressions() {
return [this.expression]
}
setExpressionAt(_: number, expr: IExpression) {
this.expression = expr
}
isStatic() {
return this.expression.isStatic()
}
eval() {
const value = this.expression.eval()
if (typeof value !== 'number')
throw new Error(
`Cannot use "${
this.tokenType
}" operator in front of ${typeof value} "${value}"`
)
switch (this.tokenType) {
case 'MINUS': {
return -value
}
case 'BANG': {
return !value
}
}
}
toString() {
switch (this.tokenType) {
case 'MINUS': {
return `-${this.expression.toString()}`
}
case 'BANG': {
return `!${this.expression.toString()}`
}
}
throw new Error(`Unknown prefix operator: "${this.tokenType}"`)
}
}

View File

@@ -1,29 +0,0 @@
import { Expression, IExpression } from '../expression'
export class ReturnExpression extends Expression {
type = 'ReturnExpression'
isReturn = true
constructor(protected expression: IExpression) {
super()
}
get allExpressions() {
return [this.expression]
}
setExpressionAt(_: number, expr: IExpression) {
this.expression = expr
}
isStatic() {
return false
}
eval() {
return this.expression.eval()
}
toString() {
return `return ${this.expression.toString()}`
}
}

View File

@@ -1,102 +0,0 @@
import { Expression, IExpression } from '../expression'
import { StaticExpression } from './static'
import { VoidExpression } from './void'
export class StatementExpression extends Expression {
type = 'StatementExpression'
protected didReturn?: boolean = undefined
protected wasLoopBroken = false
protected wasLoopContinued = false
constructor(protected expressions: IExpression[]) {
super()
}
get allExpressions() {
return this.expressions
}
setExpressionAt(index: number, expr: IExpression) {
this.expressions[index] = expr
}
get isReturn() {
if (this.didReturn !== undefined) return this.didReturn
// This breaks scope vs. statement parsing for some reason
let i = 0
while (i < this.expressions.length) {
const expr = this.expressions[i]
if (expr.isBreak) return false
if (expr.isContinue) return false
if (expr.isReturn) {
this.didReturn = true
return true
}
i++
}
this.didReturn = false
return false
}
get isBreak() {
if (this.wasLoopBroken) {
this.wasLoopBroken = false
return true
}
return false
}
get isContinue() {
if (this.wasLoopContinued) {
this.wasLoopContinued = false
return true
}
return false
}
isStatic() {
let i = 0
while (i < this.expressions.length) {
if (!this.expressions[i].isStatic()) return false
i++
}
return true
}
eval() {
this.didReturn = false
this.wasLoopBroken = false
this.wasLoopContinued = false
let i = 0
while (i < this.expressions.length) {
let res = this.expressions[i].eval()
if (this.expressions[i].isReturn) {
this.didReturn = true
return res
} else if (this.expressions[i].isContinue) {
this.wasLoopContinued = true
return
} else if (this.expressions[i].isBreak) {
this.wasLoopBroken = true
return
}
i++
}
return 0
}
toString() {
let str = ''
for (const expr of this.expressions) {
if (
expr instanceof VoidExpression ||
(expr instanceof StaticExpression && !expr.isReturn)
)
continue
str += `${expr.toString()};`
}
return str
}
}

View File

@@ -1,28 +0,0 @@
import { Expression } from '../expression'
export class StaticExpression extends Expression {
type = 'StaticExpression'
constructor(protected value: unknown, public readonly isReturn = false) {
super()
}
get allExpressions() {
return []
}
setExpressionAt() {}
isStatic() {
return true
}
eval() {
return this.value
}
toString() {
let val = this.value
if (typeof val === 'string') val = `'${val}'`
if (this.isReturn) return `return ${val}`
return '' + val
}
}

View File

@@ -1,26 +0,0 @@
import { Expression } from '../expression'
export class StringExpression extends Expression {
type = 'StringExpression'
constructor(protected name: string) {
super()
}
get allExpressions() {
return []
}
setExpressionAt() {}
isStatic() {
return true
}
eval() {
return this.name.substring(1, this.name.length - 1)
}
toString() {
return this.name
}
}

View File

@@ -1,79 +0,0 @@
import { Expression, IExpression } from '../expression'
import { VoidExpression } from './void'
export class TernaryExpression extends Expression {
type = 'TernaryExpression'
protected leftResult: unknown
constructor(
protected leftExpression: IExpression,
protected thenExpression: IExpression,
protected elseExpression: IExpression
) {
super()
}
get allExpressions() {
if (this.leftExpression.isStatic())
return [
this.leftExpression,
this.leftExpression.eval()
? this.thenExpression
: this.elseExpression,
]
return [this.leftExpression, this.thenExpression, this.elseExpression]
}
setExpressionAt(index: number, expr: IExpression) {
if (index === 0) this.leftExpression = expr
else if (index === 1) this.thenExpression = expr
else if (index === 2) this.elseExpression = expr
}
get isReturn() {
if (this.leftResult === undefined)
return this.thenExpression.isReturn && this.elseExpression.isReturn
return this.leftResult
? this.thenExpression.isReturn
: this.elseExpression.isReturn
}
get hasReturn() {
return this.thenExpression.isReturn || this.elseExpression.isReturn
}
get isContinue() {
if (this.leftResult === undefined)
return (
this.thenExpression.isContinue && this.elseExpression.isContinue
)
return this.leftResult
? this.thenExpression.isContinue
: this.elseExpression.isContinue
}
get isBreak() {
if (this.leftResult === undefined)
return this.thenExpression.isBreak && this.elseExpression.isBreak
return this.leftResult
? this.thenExpression.isBreak
: this.elseExpression.isBreak
}
isStatic() {
return (
this.leftExpression.isStatic() &&
this.thenExpression.isStatic() &&
this.elseExpression.isStatic()
)
}
eval() {
this.leftResult = this.leftExpression.eval()
return this.leftResult
? this.thenExpression.eval()
: this.elseExpression.eval()
}
toString() {
if (this.elseExpression instanceof VoidExpression)
return `${this.leftExpression.toString()}?${this.thenExpression.toString()}`
return `${this.leftExpression.toString()}?${this.thenExpression.toString()}:${this.elseExpression.toString()}`
}
}

View File

@@ -1,21 +0,0 @@
import { Expression } from '../expression'
export class VoidExpression extends Expression {
type = 'VoidExpression'
get allExpressions() {
return []
}
setExpressionAt() {}
isStatic() {
return true
}
eval() {
return 0
}
toString() {
return ''
}
}

View File

@@ -1,88 +0,0 @@
import { Parser } from './parse'
import { BinaryOperator } from './parselets/binaryOperator'
import { EPrecedence } from './precedence'
import { PrefixOperator } from './parselets/prefix'
import { NumberParselet } from './parselets/number'
import { NameParselet } from './parselets/name'
import { GroupParselet } from './parselets/groupParselet'
import { ReturnParselet } from './parselets/return'
import { StatementParselet } from './parselets/statement'
import { StringParselet } from './parselets/string'
import { FunctionParselet } from './parselets/function'
import { ArrayAccessParselet } from './parselets/arrayAccess'
import { ScopeParselet } from './parselets/scope'
import { LoopParselet } from './parselets/loop'
import { ForEachParselet } from './parselets/forEach'
import { ContinueParselet } from './parselets/continue'
import { BreakParselet } from './parselets/break'
import { BooleanParselet } from './parselets/boolean'
import { IParserConfig } from '../main'
import { EqualsOperator } from './parselets/equals'
import { NotEqualsOperator } from './parselets/notEquals'
import { AndOperator } from './parselets/andOperator'
import { OrOperator } from './parselets/orOperator'
import { SmallerOperator } from './parselets/smallerOperator'
import { GreaterOperator } from './parselets/greaterOperator'
import { QuestionOperator } from './parselets/questionOperator'
export class MoLangParser extends Parser {
constructor(config: Partial<IParserConfig>) {
super(config)
//Special parselets
this.registerPrefix('NAME', new NameParselet())
this.registerPrefix('STRING', new StringParselet())
this.registerPrefix('NUMBER', new NumberParselet())
this.registerPrefix('TRUE', new BooleanParselet(EPrecedence.PREFIX))
this.registerPrefix('FALSE', new BooleanParselet(EPrecedence.PREFIX))
this.registerPrefix('RETURN', new ReturnParselet())
this.registerPrefix('CONTINUE', new ContinueParselet())
this.registerPrefix('BREAK', new BreakParselet())
this.registerPrefix('LOOP', new LoopParselet())
this.registerPrefix('FOR_EACH', new ForEachParselet())
this.registerInfix(
'QUESTION',
new QuestionOperator(EPrecedence.CONDITIONAL)
)
this.registerPrefix('LEFT_PARENT', new GroupParselet())
this.registerInfix(
'LEFT_PARENT',
new FunctionParselet(EPrecedence.FUNCTION)
)
this.registerInfix(
'ARRAY_LEFT',
new ArrayAccessParselet(EPrecedence.ARRAY_ACCESS)
)
this.registerPrefix('CURLY_LEFT', new ScopeParselet(EPrecedence.SCOPE))
this.registerInfix(
'SEMICOLON',
new StatementParselet(EPrecedence.STATEMENT)
)
//Prefix parselets
this.registerPrefix('MINUS', new PrefixOperator(EPrecedence.PREFIX))
this.registerPrefix('BANG', new PrefixOperator(EPrecedence.PREFIX))
//Postfix parselets
//Nothing here yet
//Infix parselets
this.registerInfix('PLUS', new BinaryOperator(EPrecedence.SUM))
this.registerInfix('MINUS', new BinaryOperator(EPrecedence.SUM))
this.registerInfix('ASTERISK', new BinaryOperator(EPrecedence.PRODUCT))
this.registerInfix('SLASH', new BinaryOperator(EPrecedence.PRODUCT))
this.registerInfix(
'EQUALS',
new EqualsOperator(EPrecedence.EQUALS_COMPARE)
)
this.registerInfix(
'BANG',
new NotEqualsOperator(EPrecedence.EQUALS_COMPARE)
)
this.registerInfix('GREATER', new GreaterOperator(EPrecedence.COMPARE))
this.registerInfix('SMALLER', new SmallerOperator(EPrecedence.COMPARE))
this.registerInfix('AND', new AndOperator(EPrecedence.AND))
this.registerInfix('OR', new OrOperator(EPrecedence.OR))
this.registerInfix('ASSIGN', new BinaryOperator(EPrecedence.ASSIGNMENT))
}
}

View File

@@ -1,118 +0,0 @@
import { Tokenizer } from '../tokenizer/Tokenizer'
import { TTokenType, Token } from '../tokenizer/token'
import { IPrefixParselet } from './parselets/prefix'
import { IInfixParselet } from './parselets/infix'
import { IExpression } from './expression'
import { ExecutionEnvironment } from '../env/env'
import { IParserConfig } from '../main'
import { VoidExpression } from './expressions/void'
export class Parser {
protected prefixParselets = new Map<TTokenType, IPrefixParselet>()
protected infixParselets = new Map<TTokenType, IInfixParselet>()
protected readTokens: Token[] = []
protected tokenIterator = new Tokenizer()
executionEnv!: ExecutionEnvironment
constructor(public config: Partial<IParserConfig>) {}
updateConfig(config: Partial<IParserConfig>) {
this.config = config
}
init(expression: string) {
this.tokenIterator.init(expression)
this.readTokens = []
}
setTokenizer(tokenizer: Tokenizer) {
this.tokenIterator = tokenizer
}
setExecutionEnvironment(executionEnv: ExecutionEnvironment) {
this.executionEnv = executionEnv
}
parseExpression(precedence = 0): IExpression {
let token = this.consume()
if (token.getType() === 'EOF') return new VoidExpression()
const prefix = this.prefixParselets.get(token.getType())
if (!prefix) {
throw new Error(
`Cannot parse ${token.getType()} expression "${token.getType()}"`
)
}
let expressionLeft = prefix.parse(this, token)
return this.parseInfixExpression(expressionLeft, precedence)
}
parseInfixExpression(expressionLeft: IExpression, precedence = 0) {
let token
while (this.getPrecedence() > precedence) {
token = this.consume()
let tokenType = token.getType()
if (tokenType === 'EQUALS' && !this.match('EQUALS')) {
tokenType = 'ASSIGN'
}
const infix = <IInfixParselet>this.infixParselets.get(tokenType)
if (!infix)
throw new Error(`Unknown infix parselet: "${tokenType}"`)
expressionLeft = infix.parse(this, expressionLeft, token)
}
return expressionLeft
}
getPrecedence() {
const parselet = this.infixParselets.get(this.lookAhead(0).getType())
return parselet?.precedence ?? 0
}
consume(expected?: TTokenType) {
//Sets the lastLineNumber & startColumn before consuming next token
//Used for getting the exact location an error occurs
// this.tokenIterator.step()
const token = this.lookAhead(0)
if (expected && token.getType() !== expected) {
throw new Error(
`Expected token "${expected}" and found "${token.getType()}"`
)
}
this.readTokens.shift()!
return token
}
match(expected: TTokenType, consume = true) {
const token = this.lookAhead(0)
if (token.getType() !== expected) return false
if (consume) this.consume()
return true
}
lookAhead(distance: number) {
while (distance >= this.readTokens.length)
this.readTokens.push(this.tokenIterator.next())
return this.readTokens[distance]
}
registerInfix(tokenType: TTokenType, infixParselet: IInfixParselet) {
this.infixParselets.set(tokenType, infixParselet)
}
registerPrefix(tokenType: TTokenType, prefixParselet: IPrefixParselet) {
this.prefixParselets.set(tokenType, prefixParselet)
}
getInfix(tokenType: TTokenType) {
return this.infixParselets.get(tokenType)
}
getPrefix(tokenType: TTokenType) {
return this.prefixParselets.get(tokenType)
}
}

View File

@@ -1,21 +0,0 @@
import { Parser } from '../parse'
import { Token } from '../../tokenizer/token'
import { IExpression } from '../expression'
import { GenericOperatorExpression } from '../expressions/genericOperator'
import { IInfixParselet } from './infix'
export class AndOperator implements IInfixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, leftExpression: IExpression, token: Token) {
if (parser.match('AND'))
return new GenericOperatorExpression(
leftExpression,
parser.parseExpression(this.precedence),
'&&',
(leftExpression: IExpression, rightExpression: IExpression) =>
leftExpression.eval() && rightExpression.eval()
)
else throw new Error(`"&" not followed by another "&"`)
}
}

View File

@@ -1,22 +0,0 @@
import { Token } from '../../tokenizer/token'
import { Parser } from '../parse'
import { IInfixParselet } from './infix'
import { IExpression } from '../expression'
import { ArrayAccessExpression } from '../expressions/arrayAccess'
export class ArrayAccessParselet implements IInfixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, left: IExpression, token: Token) {
const expr = parser.parseExpression(this.precedence - 1)
if (!left.setPointer) throw new Error(`"${left.type}" is not an array`)
if (!parser.match('ARRAY_RIGHT'))
throw new Error(
`No closing bracket for opening bracket "[${expr.eval()}"`
)
return new ArrayAccessExpression(left, expr)
}
}

View File

@@ -1,134 +0,0 @@
import { IInfixParselet } from './infix'
import { Parser } from '../parse'
import { IExpression } from '../expression'
import { Token } from '../../tokenizer/token'
import { GenericOperatorExpression } from '../expressions/genericOperator'
const plusHelper = (
leftExpression: IExpression,
rightExpression: IExpression
) => {
const leftValue = leftExpression.eval()
const rightValue = rightExpression.eval()
if (
!(typeof leftValue === 'number' || typeof leftValue === 'boolean') ||
!(typeof rightValue === 'number' || typeof rightValue === 'boolean')
)
throw new Error(
`Cannot use numeric operators for expression "${leftValue} + ${rightValue}"`
)
//@ts-ignore
return leftValue + rightValue
}
const minusHelper = (
leftExpression: IExpression,
rightExpression: IExpression
) => {
const leftValue = leftExpression.eval()
const rightValue = rightExpression.eval()
if (
!(typeof leftValue === 'number' || typeof leftValue === 'boolean') ||
!(typeof rightValue === 'number' || typeof rightValue === 'boolean')
)
throw new Error(
`Cannot use numeric operators for expression "${leftValue} - ${rightValue}"`
)
//@ts-ignore
return leftValue - rightValue
}
const divideHelper = (
leftExpression: IExpression,
rightExpression: IExpression
) => {
const leftValue = leftExpression.eval()
const rightValue = rightExpression.eval()
if (
!(typeof leftValue === 'number' || typeof leftValue === 'boolean') ||
!(typeof rightValue === 'number' || typeof rightValue === 'boolean')
)
throw new Error(
`Cannot use numeric operators for expression "${leftValue} / ${rightValue}"`
)
//@ts-ignore
return leftValue / rightValue
}
const multiplyHelper = (
leftExpression: IExpression,
rightExpression: IExpression
) => {
const leftValue = leftExpression.eval()
const rightValue = rightExpression.eval()
if (
!(typeof leftValue === 'number' || typeof leftValue === 'boolean') ||
!(typeof rightValue === 'number' || typeof rightValue === 'boolean')
)
throw new Error(
`Cannot use numeric operators for expression "${leftValue} * ${rightValue}"`
)
//@ts-ignore
return leftValue * rightValue
}
const assignHelper = (
leftExpression: IExpression,
rightExpression: IExpression
) => {
if (leftExpression.setPointer) {
leftExpression.setPointer(rightExpression.eval())
return 0
} else {
throw Error(`Cannot assign to ${leftExpression.type}`)
}
}
export class BinaryOperator implements IInfixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, leftExpression: IExpression, token: Token) {
const rightExpression = parser.parseExpression(this.precedence)
// return new AdditionExpression(leftExpression, rightExpression)
const tokenText = token.getText()
switch (tokenText) {
case '+':
return new GenericOperatorExpression(
leftExpression,
rightExpression,
tokenText,
plusHelper
)
case '-':
return new GenericOperatorExpression(
leftExpression,
rightExpression,
tokenText,
minusHelper
)
case '*':
return new GenericOperatorExpression(
leftExpression,
rightExpression,
tokenText,
multiplyHelper
)
case '/':
return new GenericOperatorExpression(
leftExpression,
rightExpression,
tokenText,
divideHelper
)
case '=': {
return new GenericOperatorExpression(
leftExpression,
rightExpression,
'=',
assignHelper
)
}
default:
throw new Error(`Operator not implemented`)
}
}
}

View File

@@ -1,12 +0,0 @@
import { IPrefixParselet } from './prefix'
import { Token } from '../../tokenizer/token'
import { Parser } from '../parse'
import { BooleanExpression } from '../expressions/boolean'
export class BooleanParselet implements IPrefixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, token: Token) {
return new BooleanExpression(token.getText() === 'true')
}
}

View File

@@ -1,12 +0,0 @@
import { Parser } from '../parse'
import { Token } from '../../tokenizer/token'
import { IPrefixParselet } from './prefix'
import { BreakExpression } from '../expressions/break'
export class BreakParselet implements IPrefixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, token: Token) {
return new BreakExpression()
}
}

View File

@@ -1,12 +0,0 @@
import { Parser } from '../parse'
import { Token } from '../../tokenizer/token'
import { IPrefixParselet } from './prefix'
import { ContinueExpression } from '../expressions/continue'
export class ContinueParselet implements IPrefixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, token: Token) {
return new ContinueExpression()
}
}

View File

@@ -1,19 +0,0 @@
import { Parser } from '../../parser/parse'
import { Token } from '../../tokenizer/token'
import { IExpression } from '../expression'
import { GenericOperatorExpression } from '../expressions/genericOperator'
import { IInfixParselet } from './infix'
export class EqualsOperator implements IInfixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, leftExpression: IExpression, token: Token) {
return new GenericOperatorExpression(
leftExpression,
parser.parseExpression(this.precedence),
'==',
(leftExpression: IExpression, rightExpression: IExpression) =>
leftExpression.eval() === rightExpression.eval()
)
}
}

View File

@@ -1,29 +0,0 @@
import { Parser } from '../parse'
import { Token } from '../../tokenizer/token'
import { IPrefixParselet } from './prefix'
import { IExpression } from '../expression'
import { ForEachExpression } from '../expressions/forEach'
export class ForEachParselet implements IPrefixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, token: Token) {
parser.consume('LEFT_PARENT')
const args: IExpression[] = []
if (parser.match('RIGHT_PARENT'))
throw new Error(`for_each() called without arguments`)
do {
args.push(parser.parseExpression())
} while (parser.match('COMMA'))
parser.consume('RIGHT_PARENT')
if (args.length !== 3)
throw new Error(
`There must be exactly three for_each() arguments; found ${args.length}`
)
return new ForEachExpression(args[0], args[1], args[2])
}
}

View File

@@ -1,26 +0,0 @@
import { Token } from '../../tokenizer/token'
import { Parser } from '../parse'
import { IInfixParselet } from './infix'
import { IExpression } from '../expression'
import { FunctionExpression } from '../expressions/function'
export class FunctionParselet implements IInfixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, left: IExpression, token: Token) {
const args: IExpression[] = []
if (!left.setFunctionCall)
throw new Error(`${left.type} is not callable!`)
left.setFunctionCall(true)
if (!parser.match('RIGHT_PARENT')) {
do {
args.push(parser.parseExpression())
} while (parser.match('COMMA'))
parser.consume('RIGHT_PARENT')
}
return new FunctionExpression(left, args)
}
}

View File

@@ -1,31 +0,0 @@
import { Parser } from '../parse'
import { Token } from '../../tokenizer/token'
import { IExpression } from '../expression'
import { GenericOperatorExpression } from '../expressions/genericOperator'
import { IInfixParselet } from './infix'
export class GreaterOperator implements IInfixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, leftExpression: IExpression, token: Token) {
if (parser.match('EQUALS'))
return new GenericOperatorExpression(
leftExpression,
parser.parseExpression(this.precedence),
'>=',
(leftExpression: IExpression, rightExpression: IExpression) =>
// @ts-ignore
leftExpression.eval() >= rightExpression.eval()
)
else {
return new GenericOperatorExpression(
leftExpression,
parser.parseExpression(this.precedence),
'>',
(leftExpression: IExpression, rightExpression: IExpression) =>
// @ts-ignore
leftExpression.eval() > rightExpression.eval()
)
}
}
}

View File

@@ -1,18 +0,0 @@
import { IPrefixParselet } from './prefix'
import { Token } from '../../tokenizer/token'
import { Parser } from '../parse'
import { GroupExpression } from '../expressions/group'
export class GroupParselet implements IPrefixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, token: Token) {
const expression = parser.parseExpression(this.precedence)
parser.consume('RIGHT_PARENT')
if (parser.config.keepGroups)
return new GroupExpression(expression, '()')
return expression
}
}

View File

@@ -1,8 +0,0 @@
import { Parser } from '../parse'
import { IExpression } from '../expression'
import { Token } from '../../tokenizer/token'
export interface IInfixParselet {
readonly precedence: number
parse: (parser: Parser, left: IExpression, token: Token) => IExpression
}

View File

@@ -1,29 +0,0 @@
import { Parser } from '../parse'
import { Token } from '../../tokenizer/token'
import { IPrefixParselet } from './prefix'
import { IExpression } from '../expression'
import { LoopExpression } from '../expressions/loop'
export class LoopParselet implements IPrefixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, token: Token) {
parser.consume('LEFT_PARENT')
const args: IExpression[] = []
if (parser.match('RIGHT_PARENT'))
throw new Error(`loop() called without arguments`)
do {
args.push(parser.parseExpression())
} while (parser.match('COMMA'))
parser.consume('RIGHT_PARENT')
if (args.length !== 2)
throw new Error(
`There must be exactly two loop() arguments; found ${args.length}`
)
return new LoopExpression(args[0], args[1])
}
}

View File

@@ -1,43 +0,0 @@
import { IPrefixParselet } from './prefix'
import { Token } from '../../tokenizer/token'
import { Parser } from '../parse'
import { NameExpression } from '../expressions/name'
import { ContextSwitchExpression } from '../expressions/contextSwitch'
export class NameParselet implements IPrefixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, token: Token) {
const nameExpr = new NameExpression(
parser.executionEnv,
token.getText()
)
const nextTokens = <const>[parser.lookAhead(0), parser.lookAhead(1)]
// Context switching operator "->"
if (
nextTokens[0].getType() === 'MINUS' &&
nextTokens[1].getType() === 'GREATER'
) {
parser.consume('MINUS')
parser.consume('GREATER')
const nameToken = parser.lookAhead(0)
if (nameToken.getType() !== 'NAME')
throw new Error(
`Cannot use context switch operator "->" on ${parser.lookAhead(
0
)}`
)
parser.consume('NAME')
return new ContextSwitchExpression(
nameExpr,
new NameExpression(parser.executionEnv, nameToken.getText())
)
}
return nameExpr
}
}

View File

@@ -1,23 +0,0 @@
import { Parser } from '../parse'
import { Token } from '../../tokenizer/token'
import { IExpression } from '../expression'
import { GenericOperatorExpression } from '../expressions/genericOperator'
import { IInfixParselet } from './infix'
export class NotEqualsOperator implements IInfixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, leftExpression: IExpression, token: Token) {
if (parser.match('EQUALS')) {
return new GenericOperatorExpression(
leftExpression,
parser.parseExpression(this.precedence),
'!=',
(leftExpression: IExpression, rightExpression: IExpression) =>
leftExpression.eval() !== rightExpression.eval()
)
} else {
throw new Error(`! was used as a binary operator`)
}
}
}

View File

@@ -1,12 +0,0 @@
import { IPrefixParselet } from './prefix'
import { Token } from '../../tokenizer/token'
import { Parser } from '../parse'
import { NumberExpression } from '../expressions/number'
export class NumberParselet implements IPrefixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, token: Token) {
return new NumberExpression(Number(token.getText()))
}
}

View File

@@ -1,21 +0,0 @@
import { Parser } from '../parse'
import { Token } from '../../tokenizer/token'
import { IExpression } from '../expression'
import { GenericOperatorExpression } from '../expressions/genericOperator'
import { IInfixParselet } from './infix'
export class OrOperator implements IInfixParselet {
constructor(public precedence = 0) {}
parse(parser: Parser, leftExpression: IExpression, token: Token) {
if (parser.match('OR'))
return new GenericOperatorExpression(
leftExpression,
parser.parseExpression(this.precedence),
'||',
(leftExpression: IExpression, rightExpression: IExpression) =>
leftExpression.eval() || rightExpression.eval()
)
else throw new Error(`"|" not followed by another "|"`)
}
}

View File

@@ -1,3 +0,0 @@
import { IInfixParselet } from './infix'
export interface IPostfixParselet extends IInfixParselet {}

Some files were not shown because too many files have changed in this diff Show More