Compare commits

..

167 Commits

Author SHA1 Message Date
b323d16123 v0.6.4 2020-05-11 17:52:13 +08:00
85240608a1 feat: add npmignore
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:46:57 +08:00
6f9b458e6a v0.6.3 2020-05-11 17:32:02 +08:00
64159b621f feat: support address arg
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:24:26 +08:00
393ae6ce25 feat: support online load plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:22:45 +08:00
b9b80ecb83 feat: support blockly online debug
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:22:15 +08:00
57e2845ad9 feat: compatible blockly plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:20:50 +08:00
e03a4f9b34 feat: add i18n load tip
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-11 17:19:44 +08:00
72015ec132 feat: ignore jar:file stack info
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-10 16:25:04 +08:00
3e329233ce feat: add incremental compiler config
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-10 16:24:19 +08:00
b53d9e8a4e remove: plugins public file 2020-05-08 18:42:17 +08:00
331357f1a2 feat: support basic plugin... 2020-05-08 18:41:56 +08:00
ec809fb013 feat: update init command... 2020-05-08 10:11:30 +08:00
e38e772b17 feat: update gitpod init command... 2020-05-08 10:05:47 +08:00
2b56b1e573 feat: add gitpod config... 2020-05-08 09:53:18 +08:00
2df09b2472 feat: complate deploy feature 2020-05-08 00:50:30 +08:00
f9303b0e11 v0.6.2 2020-05-07 18:38:28 +08:00
d43f52a2a4 fix: reload & download error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-07 18:33:10 +08:00
7cf9718a9a v0.6.1 2020-05-07 17:18:38 +08:00
9693dc235f feat: update docs & MSPM
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-07 17:13:48 +08:00
40e9d1db6e feat: support source map & reload
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-07 17:12:15 +08:00
d50506ab9d v0.6.0 2020-05-03 00:15:06 +08:00
c34d3027e4 refactor: rename scope to @ccms
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-05-03 00:14:47 +08:00
edf8410cd1 v0.5.0 2020-04-26 10:24:49 +08:00
b0b4bbcc2b feat: merge stage exec & catch error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-26 10:19:44 +08:00
e68689c560 feat: update plugin & websocket
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 16:42:36 +08:00
58353cb5b8 feat: support stage decorators and remove space plugin floder
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 15:38:00 +08:00
8c6b75ff10 fix: netty inject error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 13:05:46 +08:00
d53287fc51 feat: support base64 source map
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-24 13:04:45 +08:00
13a3611ebd feat: update MiaoConsole
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-07 13:39:35 +08:00
6d90980726 v0.4.2 2020-04-07 13:39:50 +08:00
42de3700ba feat: add 1.8.8 reflect & export io namespace
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-07 13:31:20 +08:00
5991662764 feat: console执行异常只打印一次
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-03 13:32:54 +08:00
1c98c19e37 feat: cancel all task when disable engine
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-03 11:36:06 +08:00
c596280d8d feat: use module export
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 17:53:12 +08:00
77301e0130 feat: add internal node moudle punycode
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 14:39:00 +08:00
90878fc7df feat: merge decorators meta interface
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 11:08:57 +08:00
a0a4c13e7b feat: add pipeline reflect
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-04-01 11:08:15 +08:00
0e92a9c795 upgrade: js-yaml version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-31 16:16:13 +08:00
0c69462bb4 v0.4.1 2020-03-31 16:16:40 +08:00
78a5ed31b3 fix: disable server error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-31 14:53:23 +08:00
f4e9b2627d feat: add new nodejs modules
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-31 14:51:44 +08:00
9dd7abe6fd feat: update plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-30 18:49:19 +08:00
12743bbbe0 feat: instance i18n object
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-30 18:49:08 +08:00
d9a2ea9c78 v0.4.0 2020-03-25 13:54:45 +08:00
c505cda10b feat: export error handle & merge config
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 18:30:50 +08:00
100ccbcde3 feat: add api doc
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 17:59:18 +08:00
c6575ed481 fix: sourceMap sometime error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 15:02:20 +08:00
83359d8cb9 fix: ack callback call twice
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 14:52:50 +08:00
cca4979f16 feat: optimize framework add error catch(only log)
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 13:27:11 +08:00
251c9366f5 style: change error color
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-24 13:26:15 +08:00
8f01dcc8e8 feat: complate sockt.io server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-23 18:33:12 +08:00
c25a616dba feat: add adapter and socket
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-23 00:58:53 +08:00
aa9169b043 feat: tracatch plugin build
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-21 15:48:45 +08:00
d87e152f3b feat: add nodejs package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-21 15:47:59 +08:00
2fcadeda4e feat: complate socket.io base framework
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-21 15:47:42 +08:00
b7927830ae v0.3.2 2020-03-18 11:19:08 +08:00
2dbd2182c2 fix: source map print error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-18 11:15:49 +08:00
01df79eaf1 refactor: move docs to MiaoDocs
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-10 13:19:48 +08:00
16fe9ba9bd update: README
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:23:37 +08:00
950ce69b83 feat: modify stage order
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:11:55 +08:00
fa8e44d838 feat: update readme and fix container package error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:04:35 +08:00
b7af785273 feat: add docs package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-04 02:04:02 +08:00
6c9f7bbcf6 v0.3.1 2020-03-03 01:14:22 +08:00
c4c4c7f301 feat: public types package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-03 01:11:49 +08:00
6538c4b7bb feat: complate spiget and forgesvc api
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:40:18 +08:00
a4e6d1660d feat: update readme
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:38:34 +08:00
511b042eba feat: update MCBBS.MD
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:37:08 +08:00
6f0b5a5572 feat: add error handle
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:28:27 +08:00
e9ac46487c feat: merge type defiend
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 22:29:29 +08:00
9371823d30 remove: manager package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 21:00:54 +08:00
c86f0d9ec1 feat: add complate function
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-02 00:32:07 +08:00
c2d94ef104 feat: optimize types ref
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 20:28:16 +08:00
6ada3e41d0 fix: Dependency cycles
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 19:37:34 +08:00
8c12319dc9 feat: add i18n to ployfill
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 17:01:27 +08:00
395d2d8816 feat: add NativePluginManager
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-03-01 15:19:43 +08:00
6f628a3d7e feat: add download and getPluginsFolder
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-29 22:28:43 +08:00
2232e82c36 feat: upgrade typescript
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-29 18:21:02 +08:00
291b5010e7 feat: add command error i18n
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-29 00:44:11 +08:00
3595294444 feat: add normal env task
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 18:20:45 +08:00
e38358ef98 feat: MiaoConsole exclude nukkit
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 18:15:33 +08:00
4c418c33c0 feat: channel add ext data
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 18:14:17 +08:00
65d112be09 feat: add nukkit example
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 17:59:06 +08:00
15a75dffe2 fix: servers check error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 17:57:29 +08:00
7b8e693a03 v0.3.0 2020-02-27 12:27:19 +08:00
5426023adb feat: optimize code
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 12:26:04 +08:00
73b91c417e feat: improve i18n scope
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 12:11:18 +08:00
2693a22bf0 feat: support i18n translate
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 01:58:23 +08:00
2322de1e40 feat: add package i18n
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-27 01:57:44 +08:00
2320736a92 feat: remove async check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-26 10:43:47 +08:00
e8d5d10d44 feat: unmanaged baseEventDir
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-26 10:36:30 +08:00
a9996ba297 feat: use inversify autoProvide inject
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-26 10:15:33 +08:00
68380ddbba feat: exclude async event monitor
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-25 23:32:12 +08:00
0baf8f3cab fix: event execute class type error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-25 23:15:39 +08:00
a2bce715f3 fix: nukkit unregister event error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-25 18:25:16 +08:00
3c55df03d8 feat: use new channel service
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 18:36:32 +08:00
f6526e79fc feat: add channel support for bungee bukkit sponge
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 18:36:08 +08:00
f4c2294c06 feat: update ignore file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:35:19 +08:00
cf9508ba31 v0.2.1 2020-02-24 16:27:49 +08:00
e0f4c5e77d feat: add nukkit support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:25:54 +08:00
e4a87095ce feat: add config support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:25:38 +08:00
950575edbc feat: inject config folder
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:25:16 +08:00
c2a71b9a7a feat: add config support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 16:24:36 +08:00
068ac7b76e feat: update typescript version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 15:28:47 +08:00
05cbd85828 feat: add nukkit support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 04:02:29 +08:00
ea28d20aa1 feat: add nukkit package 2020-02-24 04:01:39 +08:00
d3f33f50e0 feat: add nukkit type defiend 2020-02-24 02:54:05 +08:00
d004ba17e6 v0.2.0 2020-02-24 00:21:48 +08:00
7a25dd8b3b feat: set manager and client to private
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:19:13 +08:00
dedc8393da feat: update plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:13:19 +08:00
8d344492d9 feat: add config decorator bate
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:12:32 +08:00
81a76af7be feat: update mcbbs file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-24 00:11:46 +08:00
b458da7a6e feat: add auto respawn support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-23 22:35:05 +08:00
45cb6fa667 fix: some bug at xhr and console
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-23 22:33:51 +08:00
9c4543df30 feat: channelRead0 处理逻辑移动到业务线程
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 19:46:50 +08:00
512bdb22c5 feat: update main script
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 19:03:09 +08:00
f6e39c131c feat: add source map support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 19:00:26 +08:00
73d4dad7f6 feat: add mc console client package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 18:59:02 +08:00
de4a22362f feat: remove script npx
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-19 18:56:02 +08:00
5fde2e5554 feat: update example plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 19:40:25 +08:00
6a6765e5c3 feat: add source map support(only local)
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 19:39:45 +08:00
4a1f25ee6a feat: enable sourceMap
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 18:49:18 +08:00
5999567ee3 feat: update dependencies version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-15 18:48:46 +08:00
fad4e27a7f fix: bungee servers forEach error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-14 04:03:25 +08:00
b477938e4f fix: bungee unregister error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-14 04:02:37 +08:00
7cbd91826a feat: chat compatible catserver
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-14 04:02:18 +08:00
6797761a2f feat: add bungee tab complate
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-09 22:07:00 +08:00
be114e6d1b feat: add core-js
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-09 22:06:45 +08:00
3e40934339 feat: rename plugin
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-08 17:07:56 +08:00
3e6c7b2d8c fix: compile error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-02 01:58:07 +08:00
6c0bb75561 feat: use dom types and set Proxy global
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-02 01:56:45 +08:00
a47896a97f feat: update Proxy handle and optimize core index
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 03:37:56 +08:00
1d97bbc9ce feat: update Readme
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:54:03 +08:00
b1f1f9837e feat: add websocket package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:47:39 +08:00
99dee28fd4 feat: add plugin stage log
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:46:55 +08:00
c7f66d8252 feat: move type bind and export impl function
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:46:06 +08:00
8c4f266356 feat: move global declare to @ms/ployfill
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-02-01 02:44:23 +08:00
39e899211b feat: complete cross server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:48:23 +08:00
da72a0dac6 feat: optimize code
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:47:38 +08:00
9984787202 fix: sponge task callSyncMethod
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:45:39 +08:00
4493d35786 feat: optimiz plugin system
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:45:13 +08:00
e1aad59eeb feat: add tellraw string
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:44:08 +08:00
849393492f feat: update server filter
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 17:43:45 +08:00
1ff33702d8 feat: plugin & cmd add server check
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:11:20 +08:00
e68005fd6f feat: use inject container
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:10:30 +08:00
17269b50f4 fix: bungee event error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:09:16 +08:00
363d0c164a feat: add callSyncMethod
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:08:51 +08:00
13a0b62103 fix: with error
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-17 11:08:10 +08:00
cb4e152800 feat: add plugin controller
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:28:10 +08:00
fb83acfcc8 feat: update plugins
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:27:24 +08:00
7263fbb437 feat: add bungee support
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:26:31 +08:00
23868a58b9 feat: complete event and dispatch command
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-16 17:19:10 +08:00
effa7f70ec feat: add tellraw & Proxy utils
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 18:38:22 +08:00
eef0baa740 feat: formatting code & remove chinese
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:48:18 +08:00
4d0c0122c7 feat: completion base func
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:44:14 +08:00
aa581afbe5 feat: add bungee package
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:43:00 +08:00
1425c473fd feat: delombok and regenerate d.ts
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 16:42:15 +08:00
53e4f6c658 feat: update bungee type file
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-15 01:02:08 +08:00
73db4a9169 feat: add server module
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-14 17:44:20 +08:00
a2efd878db feat: add bungee typings
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-14 17:40:28 +08:00
4e6cda0545 feat: support multi code page
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-13 15:28:25 +08:00
859a3a9171 feat: upgrade version
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-01-08 09:48:37 +08:00
96481032c5 feat: update websocket server
Signed-off-by: MiaoWoo <admin@yumc.pw>
2019-11-10 10:11:13 +08:00
f950c3dae8 feat: update gitignore 2019-11-09 18:35:26 +08:00
9248294cb3 feat: add jdk support 2019-11-09 18:34:54 +08:00
53873d7b63 feat: update type defiend 2019-11-07 16:40:27 +08:00
be59ae480b feat: add bukkit sponge jdk type 2019-11-07 15:13:28 +08:00
6630 changed files with 379303 additions and 5968 deletions

View File

@@ -20,5 +20,3 @@ wallaby.js
.vscode
.theia
type_definitions
tsconfig.tsbuildinfo
*.tsbuildinfo

View File

@@ -4,8 +4,3 @@
- 更新日志 [![Build Status](https://ci.yumc.pw/job/Minecraft/job/MiaoScript/badge/icon?style=flat-square&subject=MiaoScript&status=CHANGELOG&color=green)](https://docs.yumc.pw/MiaoScript/CHANGELOG.html)
- 安装文档 [![Build Status](https://ci.yumc.pw/job/Minecraft/job/MiaoScript/badge/icon?style=flat-square&subject=MiaoScript&status=MiaoDoc%20USER&color=red)](https://docs.yumc.pw/MiaoScript/1-user/1.1-check-env.html)
- 开发文档 [![Build Status](https://ci.yumc.pw/job/Minecraft/job/MiaoScript/badge/icon?style=flat-square&subject=MiaoScript&status=MiaoDoc%20DEVELOP&color=darkred)](https://docs.yumc.pw/MiaoScript/2-develop/1.1-check-env.html)
- 兼容服务端 Spigot CatServer Sponge BungeeCord Nukkit(没错 他还兼容Nukkit)
### 腐竹版本(开发中)
- 先上几张图

View File

@@ -1,5 +1,5 @@
{
"version": "0.8.4",
"version": "0.6.4",
"useWorkspaces": true,
"npmClient": "yarn",
"packages": [
@@ -10,7 +10,6 @@
"stream": true
},
"publish": {
"access": "public",
"registry": "https://repo.yumc.pw/repository/npm-hosted/"
}
}

View File

@@ -12,14 +12,12 @@
"build": "lerna run build --scope=\"@ccms/!(plugins)\"",
"build:plugins": "lerna run build --scope=\"@ccms/plugins\"",
"ug": "yarn upgrade-interactive --latest",
"np": "lerna exec \"npm publish --access=public --registry https://registry.npmjs.org\" --scope=\"@ccms/!(client|plugins)\"",
"lsp": "npm login --registry=https://registry.npmjs.org --scope=@ccms",
"lp": "lerna publish --registry https://registry.npmjs.org"
"lp": "lerna publish"
},
"workspaces": [
"packages/*"
],
"devDependencies": {
"lerna": "^3.22.1"
"lerna": "^3.20.2"
}
}
}

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,35 +0,0 @@
{
"name": "@ccms/amqp",
"version": "0.8.4",
"description": "MiaoScript amqp package",
"keywords": [
"miaoscript",
"minecraft",
"bukkit",
"sponge"
],
"author": "MiaoWoo <admin@yumc.pw>",
"homepage": "https://github.com/circlecloud/ms.git",
"license": "ISC",
"main": "dist/index.js",
"scripts": {
"clean": "rimraf dist",
"watch": "tsc --watch",
"build": "yarn clean && tsc",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@ccms/api": "^0.8.4",
"@ccms/common": "^0.8.4",
"@ccms/container": "^0.8.4"
},
"devDependencies": {
"@ccms/nashorn": "^0.8.4",
"@javatypes/amqp-client": "^0.0.2",
"@javatypes/spring-amqp": "^0.0.2",
"@javatypes/spring-rabbit": "^0.0.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
}
}

View File

@@ -1,17 +0,0 @@
import { ConnectionFactoryAdapter } from "./connection"
import { RabbitTemplateAdapter } from "./template"
import { JSClass } from "@ccms/container"
export const RabbitAdmin = Java.type('org.springframework.amqp.rabbit.core.RabbitAdmin')
export class RabbitAdminAdapter {
@JSClass('org.springframework.amqp.rabbit.core.RabbitAdmin')
private RabbitAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin
private _Handler: org.springframework.amqp.rabbit.core.RabbitAdmin
constructor(config: RabbitTemplateAdapter | org.springframework.amqp.rabbit.core.RabbitTemplate | ConnectionFactoryAdapter | org.springframework.amqp.rabbit.connection.ConnectionFactory) {
this._Handler = new RabbitAdmin((config instanceof RabbitTemplateAdapter || config instanceof ConnectionFactoryAdapter) ? config.getHandler() : config)
}
getHandler(): org.springframework.amqp.rabbit.core.RabbitAdmin {
return this._Handler
}
}

View File

@@ -1,30 +0,0 @@
export const ConfirmCallback = Java.type('org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback')
export const ReturnCallback = Java.type('org.springframework.amqp.rabbit.core.RabbitTemplate.ReturnCallback')
export abstract class ConfirmCallbackAdapter {
private _Handler: org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback
constructor() {
let ConfirmCallbackImpl = Java.extend(ReturnCallback, {
confirm: (correlationData: org.springframework.amqp.rabbit.connection.CorrelationData, ack: boolean, cause: string) => this.confirm(correlationData, ack, cause)
})
this._Handler = new ConfirmCallbackImpl()
}
abstract confirm(correlationData: org.springframework.amqp.rabbit.connection.CorrelationData, ack: boolean, cause: string)
getHandler() {
return this._Handler
}
}
export abstract class ReturnCallbackAdapter {
private _Handler: org.springframework.amqp.rabbit.core.RabbitTemplate.ReturnCallback
constructor() {
let ReturnCallbackImpl = Java.extend(ReturnCallback, {
returnedMessage: (message: org.springframework.amqp.core.Message, replyCode: number, replyText: string, exchange: string, routingKey: string) => this.returnedMessage(message, replyCode, replyText, exchange, routingKey)
})
this._Handler = new ReturnCallbackImpl()
}
abstract returnedMessage(message: org.springframework.amqp.core.Message, replyCode: number, replyText: string, exchange: string, routingKey: string)
getHandler() {
return this._Handler
}
}

View File

@@ -1,31 +0,0 @@
import threadPool from '@ccms/common/dist/thread-pool'
export const ConnectionFactory = Java.type('org.springframework.amqp.rabbit.connection.ConnectionFactory')
const CachingConnectionFactory = Java.type('org.springframework.amqp.rabbit.connection.CachingConnectionFactory')
interface ConnectionConfig {
url: string,
username?: string,
password?: string,
publisherConfirms?: boolean
cacheSize?: number
}
export class ConnectionFactoryAdapter {
private _Handler: org.springframework.amqp.rabbit.connection.CachingConnectionFactory
constructor(config: ConnectionConfig) {
if (!config.url) { throw new Error('Connection UrI Can\'t be undefiend!') }
config = { publisherConfirms: true, cacheSize: 50, ...config }
this._Handler = new CachingConnectionFactory(new java.net.URI(config.url))
config.username && this._Handler.setUsername(config.username)
config.password && this._Handler.setPassword(config.password)
this._Handler.setPublisherConfirms(config.publisherConfirms)
this._Handler.setExecutor(threadPool.create({
groupName: '@ccms/amqp-rabbit'
}))
this._Handler.setChannelCacheSize(config.cacheSize)
}
getHandler() {
return this._Handler
}
}

View File

@@ -1,30 +0,0 @@
import { ConnectionFactoryAdapter, ConnectionFactory } from "./connection"
import { ChannelAwareMessageListenerAdapter, ChannelAwareMessageListener } from "./listener"
export const SimpleMessageListenerContainer = org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
export const AcknowledgeMode: org.springframework.amqp.core.AcknowledgeMode = Java.type('org.springframework.amqp.core.AcknowledgeMode')
interface ContainerConfig {
connectionFactory: ConnectionFactoryAdapter | typeof ConnectionFactory
queueNames: string[]
messageListener: ChannelAwareMessageListenerAdapter | typeof ChannelAwareMessageListener
maxConcurrentConsumers?: number
concurrentConsumers?: number
acknowledgeMode?: org.springframework.amqp.core.AcknowledgeMode
}
export class MessageListenerContainerAdapter {
private _Handler: org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
constructor(config: ContainerConfig) {
config = { concurrentConsumers: 5, maxConcurrentConsumers: 10, acknowledgeMode: AcknowledgeMode.AUTO, ...config }
this._Handler = new SimpleMessageListenerContainer(config.connectionFactory instanceof ConnectionFactoryAdapter ? config.connectionFactory.getHandler() : config.connectionFactory)
//@ts-ignore
this._Handler.setQueueNames(config.queueNames)
this._Handler.setMaxConcurrentConsumers(config.maxConcurrentConsumers)
this._Handler.setConcurrentConsumers(config.concurrentConsumers)
this._Handler.setAcknowledgeMode(config.acknowledgeMode)
this._Handler.setMessageListener(config.messageListener instanceof ChannelAwareMessageListenerAdapter ? config.messageListener.getHandler() : config.messageListener)
}
getHandler() {
return this._Handler
}
}

View File

@@ -1,37 +0,0 @@
const JavaString = Java.type('java.lang.String')
const MessageProperties = org.springframework.amqp.core.MessageProperties
const Message = org.springframework.amqp.core.Message
export const MessageConverter = Java.type('org.springframework.amqp.support.converter.MessageConverter')
export class MessageConverterAdapter {
private _Handler: org.springframework.amqp.support.converter.MessageConverter
constructor() {
var MessageConverterImpl = Java.extend(MessageConverter, {
toMessage: (object: any, messageProperties: org.springframework.amqp.core.MessageProperties) => this.toMessage(object, messageProperties),
fromMessage: (message: org.springframework.amqp.core.Message) => this.fromMessage(message)
})
this._Handler = new MessageConverterImpl()
}
toMessage(object: any, messageProperties: org.springframework.amqp.core.MessageProperties) {
if (typeof object == "string") {
messageProperties.setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN)
return new Message(new JavaString(object).getBytes(), messageProperties)
} else {
messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON)
return new Message(new JavaString(JSON.stringify(object)).getBytes(), messageProperties)
}
}
fromMessage(message: org.springframework.amqp.core.Message) {
if (message.getMessageProperties().getContentType() == MessageProperties.CONTENT_TYPE_TEXT_PLAIN) {
return new JavaString(message.getBody(), message.getMessageProperties().getContentEncoding())
}
if (message.getMessageProperties().getContentType() == MessageProperties.CONTENT_TYPE_JSON) {
return JSON.parse(new JavaString(message.getBody(), message.getMessageProperties().getContentEncoding()))
}
return message
}
getHandler() {
return this._Handler
}
}

View File

@@ -1,7 +0,0 @@
export * from './admin'
export * from './callback'
export * from './connection'
export * from './container'
export * from './converter'
export * from './listener'
export * from './template'

View File

@@ -1,49 +0,0 @@
const JavaString = Java.type('java.lang.String')
export const MessageProperties = org.springframework.amqp.core.MessageProperties
export const ChannelAwareMessageListener = Java.type('org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener')
export const AmqpRejectAndDontRequeueException = org.springframework.amqp.AmqpRejectAndDontRequeueException
export const Channel: com.rabbitmq.client.Channel = Java.type('com.rabbitmq.client.Channel')
export const Message = org.springframework.amqp.core.Message
export type MessageHandler<T> = (content: T, message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel) => any
export abstract class ChannelAwareMessageListenerAdapter<T = any> {
private _Handler: org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener
constructor(manual: boolean = false) {
let ChannelAwareMessageListenerImpl = Java.extend(ChannelAwareMessageListener, {
onMessage: (message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel) => {
let content = new JavaString(message.getBody(), message.getMessageProperties().getContentEncoding() || "UTF-8")
try {
if (message.getMessageProperties().getContentType() == MessageProperties.CONTENT_TYPE_JSON) {
content = JSON.parse(content)
}
} catch (error) {
if (manual) {
channel.basicReject(message.getMessageProperties().getDeliveryTag(), true)
} else {
throw new AmqpRejectAndDontRequeueException(`${error}`, error)
}
}
manual ? this.manualOnMessage(content, message, channel) : this.onMessage(content, message, channel)
}
})
this._Handler = new ChannelAwareMessageListenerImpl()
}
abstract onMessage(content: T, message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel): any
onError(error: Error, message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel): any { }
getHandler() {
return this._Handler
}
private manualOnMessage(content: T, message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel) {
let deliveryTag = message.getMessageProperties().getDeliveryTag()
try {
if (this.onMessage(content, message, channel)) {
channel.basicAck(deliveryTag, false)
} else if (message.getMessageProperties().getRedelivered()) {
channel.basicReject(deliveryTag, true)
} else {
channel.basicNack(deliveryTag, false, true)
}
} catch (error) {
channel.basicReject(deliveryTag, this.onError(error, message, channel))
}
}
}

View File

@@ -1,27 +0,0 @@
import { MessageConverterAdapter } from "./converter"
import { ConnectionFactoryAdapter } from "./connection"
import { ConfirmCallbackAdapter, ReturnCallbackAdapter } from "./callback"
export const RabbitTemplate = Java.type('org.springframework.amqp.rabbit.core.RabbitTemplate')
interface TemplateConfig {
connectionFactory: ConnectionFactoryAdapter | org.springframework.amqp.rabbit.connection.ConnectionFactory
confirmCallback?: ConfirmCallbackAdapter
returnCallback?: ReturnCallbackAdapter
messageConverter?: MessageConverterAdapter
}
export class RabbitTemplateAdapter {
private _Handler: org.springframework.amqp.rabbit.core.RabbitTemplate
constructor(config: TemplateConfig) {
config = { messageConverter: new MessageConverterAdapter(), ...config }
console.debug(JSON.stringify(config))
this._Handler = new RabbitTemplate(config.connectionFactory instanceof ConnectionFactoryAdapter ? config.connectionFactory.getHandler() : config.connectionFactory)
config.returnCallback && this._Handler.setReturnCallback(config.returnCallback.getHandler())
config.confirmCallback && this._Handler.setConfirmCallback(config.confirmCallback.getHandler())
config.messageConverter && this._Handler.setMessageConverter(config.messageConverter.getHandler())
}
getHandler() {
return this._Handler
}
}

View File

@@ -1,89 +0,0 @@
import { JSClass } from "@ccms/container"
import { RabbitAdminAdapter, MessageListenerContainerAdapter, AcknowledgeMode, MessageHandler, ChannelAwareMessageListenerAdapter } from "./adapter"
export class AmqpAdmin {
@JSClass('org.springframework.amqp.core.TopicExchange')
private TopicExchange: typeof org.springframework.amqp.core.TopicExchange
@JSClass('org.springframework.amqp.core.Queue')
private Queue: typeof org.springframework.amqp.core.Queue
@JSClass('org.springframework.amqp.core.Binding')
private Binding: typeof org.springframework.amqp.core.Binding
@JSClass('org.springframework.amqp.rabbit.core.RabbitAdmin')
private RabbitAdmin: typeof org.springframework.amqp.rabbit.core.RabbitAdmin
@JSClass('org.springframework.amqp.core.Binding.DestinationType')
private DestinationType: org.springframework.amqp.core.Binding.DestinationType
private amqpAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin
constructor(amqpAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin | any) {
if (amqpAdmin instanceof this.RabbitAdmin) {
this.amqpAdmin = amqpAdmin
} else if (amqpAdmin instanceof RabbitAdminAdapter) {
this.amqpAdmin = amqpAdmin.getHandler()
} else {
this.amqpAdmin = new RabbitAdminAdapter(amqpAdmin).getHandler()
}
}
getHandler() {
return this.amqpAdmin
}
getQueueProperties(name: string) {
return this.amqpAdmin.getQueueProperties(name)
}
declareExchange(name: string) {
let exchange = new this.TopicExchange(name, true, false)
this.amqpAdmin.declareExchange(exchange)
return this
}
declareQueue(name: string) {
let queue = new this.Queue(name, true)
this.amqpAdmin.declareQueue(queue)
return this
}
declareBinding(queue: string, exchange: string, routerKey: string, argument: any = null) {
let binding = new this.Binding(queue, this.DestinationType.QUEUE, exchange, routerKey, argument)
this.amqpAdmin.declareBinding(binding)
return this
}
declareQueueAndBindExchange(queue: string, exchange: string, routerKey: string) {
return this.declareQueue(queue).declareExchange(exchange).declareBinding(queue, exchange, routerKey)
}
createContainer<T>(queue: string, listener: MessageHandler<T>, acknowledgeMode = AcknowledgeMode.AUTO) {
let connection = this.amqpAdmin.getRabbitTemplate().getConnectionFactory()
return new MessageListenerContainerAdapter({
connectionFactory: connection,
queueNames: [queue],
messageListener: new SimpleMessageHandler(listener),
acknowledgeMode: acknowledgeMode
}).getHandler()
}
send()
send() {
}
getTemplate() {
return this.amqpAdmin.getRabbitTemplate()
}
close() {
this.getTemplate().stop()
}
}
export class SimpleMessageHandler extends ChannelAwareMessageListenerAdapter {
constructor(private handler: MessageHandler<any>) {
super()
}
onMessage(content: any, message: org.springframework.amqp.core.Message, channel: com.rabbitmq.client.Channel) {
return this.handler(content, message, channel)
}
}

View File

@@ -1,3 +0,0 @@
export const METADATA_KEY = {
}

View File

@@ -1,34 +0,0 @@
/// <reference types="@ccms/nashorn" />
/// <reference types="@javatypes/jdk" />
/// <reference types="@javatypes/spring-amqp" />
/// <reference types="@javatypes/spring-rabbit" />
/// <reference types="@javatypes/amqp-client" />
import { amqp } from '@ccms/api'
import { getContainer, reduceMetadata } from '@ccms/container'
function init() {
const beanFactory = base.getInstance().getAutowireCapableBeanFactory()
getContainer().bind(amqp.rabbit.Template).toDynamicValue((ctx) => {
let metadata = reduceMetadata(ctx)
if (!metadata.named) {
return beanFactory.getBean('rabbitTemplate')
} else {
return beanFactory.getBean(`${metadata.named}-rabbitTemplate`)
}
})
getContainer().bind(amqp.rabbit.Admin).toDynamicValue((ctx) => {
let metadata = reduceMetadata(ctx)
if (!metadata.named) {
return beanFactory.getBean('rabbitAdmin')
} else {
return beanFactory.getBean(`${metadata.named}-rabbitAdmin`)
}
})
}
init()
export * from './admin'
export * from './adapter'
export * from './manager'
export * from './constants'

View File

@@ -1,5 +0,0 @@
export class AmqpListener {
constructor() {
}
}

View File

@@ -1,18 +0,0 @@
import { amqp } from "@ccms/api"
import { provideSingleton } from "@ccms/container"
import { ConnectionFactoryAdapter, RabbitTemplateAdapter, RabbitAdminAdapter } from "./adapter"
import { AmqpAdmin } from "./admin"
@provideSingleton(amqp.Manager)
export class AmqpManager {
createConnection(url: string, username: string, password: string) {
return new ConnectionFactoryAdapter({ url, username, password })
}
createTemplate(adapter: ConnectionFactoryAdapter) {
return new RabbitTemplateAdapter({ connectionFactory: adapter })
}
createAdmin(adapter: RabbitTemplateAdapter | ConnectionFactoryAdapter) {
return new AmqpAdmin(new RabbitAdminAdapter(adapter))
}
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "src",
"outDir": "dist"
}
}

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/api",
"version": "0.8.4",
"version": "0.6.4",
"description": "MiaoScript api package",
"keywords": [
"miaoscript",
@@ -19,16 +19,15 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@ccms/common": "^0.8.4",
"@ccms/container": "^0.8.4",
"@ccms/ployfill": "^0.8.4",
"@ccms/container": "^0.6.0",
"@ccms/ployfill": "^0.6.4",
"base64-js": "^1.3.1",
"source-map-builder": "^0.0.7"
},
"devDependencies": {
"@types/base64-js": "^1.3.0",
"@types/base64-js": "^1.2.5",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
}
}

View File

@@ -1,6 +1,5 @@
import i18n from '@ccms/i18n'
import { injectable } from "@ccms/container"
import { plugin } from './interfaces'
import { injectable } from "@ccms/container";
export namespace command {
@injectable()
@@ -11,17 +10,16 @@ export namespace command {
* @param name 命令
* @param exec 执行器
*/
on(plugin: plugin.Plugin, name: string, exec: { cmd: Function, tab?: Function }) {
var cmd = this.create(plugin, name)
if (!cmd) { throw Error("") }
on(plugin: any, name: string, exec: { cmd: Function, tab?: Function }) {
var cmd = this.create(plugin, name);
console.debug(i18n.translate("ms.api.command.register", { plugin: plugin.description.name, name, cmd }))
if (exec.cmd && typeof exec.cmd === "function") {
this.onCommand(plugin, cmd, exec.cmd)
this.onCommand(plugin, cmd, exec.cmd);
} else {
throw Error(i18n.translate("ms.api.command.register.input.error", { exec: exec.cmd }))
}
if (exec.tab && typeof exec.tab === "function") {
this.onTabComplete(plugin, cmd, exec.tab)
this.onTabComplete(plugin, cmd, exec.tab);
}
}
/**
@@ -29,40 +27,40 @@ export namespace command {
* @param plugin 插件
* @param name 命令
*/
off(plugin: plugin.Plugin, name: string) {
off(plugin: any, name: string) {
console.debug(i18n.translate("ms.api.command.unregister", { plugin: plugin.description.name, name }))
this.remove(plugin, name)
this.remove(plugin, name);
}
protected abstract create(plugin: plugin.Plugin, command: string): any
protected abstract remove(plugin: plugin.Plugin, command: string): void
protected abstract onCommand(plugin: plugin.Plugin, command: any, executor: Function)
protected abstract onTabComplete(plugin: plugin.Plugin, command: any, tabCompleter: Function)
protected setExecutor(plugin: plugin.Plugin, command: any, executor: Function) {
protected abstract create(plugin: any, command: string);
protected abstract remove(plugin: any, command: string);
protected abstract onCommand(plugin: any, command: any, executor: Function);
protected abstract onTabComplete(plugin: any, command: any, tabCompleter: Function);
protected setExecutor(plugin: any, command: any, executor: Function) {
return (sender: any, _: any, command: string, args: string[]) => {
try {
return executor(sender, command, Java.from(args))
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)
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)])
}
return true
return true;
}
}
}
protected setTabCompleter(plugin: plugin.Plugin, command: any, tabCompleter: Function) {
protected setTabCompleter(plugin: any, command: any, tabCompleter: Function) {
return (sender: any, _: any, command: string, args: string[]) => {
try {
var token = args[args.length - 1]
var complete = tabCompleter(sender, command, Java.from(args)) || []
return this.copyPartialMatches(complete, token)
var token = args[args.length - 1];
var complete = tabCompleter(sender, command, Java.from(args)) || [];
return this.copyPartialMatches(complete, token);
} catch (ex) {
console.i18n("ms.api.command.tab.completer.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex })
console.ex(ex)
console.sender(sender, [i18n.translate("ms.api.command.tab.completer.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)])
return []
console.ex(ex);
console.sender(sender, [i18n.translate("ms.api.command.tab.completer.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)]);
return [];
}
}
}
@@ -72,7 +70,7 @@ export namespace command {
if (typeof e === "string" && e.toLowerCase().startsWith(token.toLowerCase())) {
array.push(e)
}
})
});
return array
}
}

View File

@@ -2,10 +2,10 @@ import i18m from '@ccms/i18n'
import { SourceMapBuilder } from 'source-map-builder'
import * as base64 from 'base64-js'
const Arrays = Java.type('java.util.Arrays')
const Level = Java.type('java.util.logging.Level')
const Paths = Java.type('java.nio.file.Paths')
const ignoreLogPrefix = ['java.', 'javax.', 'sun.', 'net.minecraft.', 'org.bukkit.', 'jdk.nashorn.', 'io.netty.', 'org.spongepowered.', 'org.apache', 'org.springframework']
const Arrays = Java.type('java.util.Arrays');
const Level = Java.type('java.util.logging.Level');
const Paths = Java.type('java.nio.file.Paths');
const ignoreLogPrefix = ['java.', 'net.minecraft.', 'org.bukkit.', 'jdk.nashorn.', 'io.netty.', 'org.spongepowered.'];
enum LogLevel {
ALL,
@@ -19,19 +19,19 @@ enum LogLevel {
}
export class MiaoScriptConsole implements Console {
Console: NodeJS.ConsoleConstructor
Console: NodeJS.ConsoleConstructor;
private static sourceMaps: { [key: string]: SourceMapBuilder } = {}
private static sourceFileMaps: { [key: string]: string } = {}
private _name: string = ''
private _level: LogLevel = LogLevel.INFO
private sourceMaps: { [key: string]: SourceMapBuilder } = {};
private sourceFileMaps: { [key: string]: string } = {};
private _name: string = '';
private _level: LogLevel = LogLevel.INFO;
protected logger: any
protected prefix: string = '§6[§bMiaoScript§6]§r '
protected logger: any;
protected prefix: string = '§6[§bMiaoScript§6]§r ';
constructor(name?: string) {
this.name = name
this.logger = global.logger
this.name = name;
this.logger = global.logger;
if (global.debug) {
this._level = LogLevel.DEBUG
}
@@ -41,36 +41,36 @@ export class MiaoScriptConsole implements Console {
}
get name() {
return this._name
return this._name;
}
set name(name: string) {
if (name) {
this._name = `[${name}] `
this._name = `[${name}] `;
// noinspection JSUnusedGlobalSymbols
this.prefix = `§6[§cMS§6][§b${name}§6]§r `
this.prefix = `§6[§cMS§6][§b${name}§6]§r `;
}
}
log(...args: any[]): void {
this.logger.info(this.name + args.join(' '))
this.logger.info(this.name + args.join(' '));
}
info(...args: any[]) {
this.logger.info(this.name + args.join(' '))
this.logger.info(this.name + args.join(' '));
}
warn(...args: any[]) {
this.logger.warning(this.name + args.join(' '))
this.logger.warning(this.name + args.join(' '));
}
error(...args: any[]) {
this.logger.log(Level.SEVERE, this.name + args.join(' '))
this.logger.log(Level.SEVERE, this.name + args.join(' '));
}
debug(...args: any[]) {
if (global.debug) {
this.logger.info(this.name + '[DEBUG] ' + args.join(' '))
this.logger.info(this.name + '[DEBUG] ' + args.join(' '));
}
}
trace(...args: any[]): void {
if (this._level <= LogLevel.TRACE) {
this.logger.info(this.name + '[TRACE] ' + args.join(' '))
this.logger.info(this.name + '[TRACE] ' + args.join(' '));
}
}
sender(...args) {
@@ -93,31 +93,31 @@ export class MiaoScriptConsole implements Console {
readSourceMap(fileName: string, lineNumber: number) {
try {
if (fileName.endsWith('js')) {
if (MiaoScriptConsole.sourceMaps[fileName] === undefined) {
MiaoScriptConsole.sourceMaps[fileName] = null
let sourceLine = base.read(fileName).split('\n')
if (this.sourceMaps[fileName] === undefined) {
this.sourceMaps[fileName] = null
let sourceLine = base.read(fileName).split('\n');
let lastLine = sourceLine[sourceLine.length - 1]
if (lastLine.startsWith('//# sourceMappingURL=')) {
let sourceContent = null
let sourceMappingURL = lastLine.split('sourceMappingURL=', 2)[1]
if (sourceMappingURL.startsWith('data:application/jsonbase64,')) {
let sourceContent = null;
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')) {
// TODO
} else {
let file = Paths.get(Paths.get(fileName, '..', sourceMappingURL).toFile().getCanonicalPath()).toFile()
let file = Paths.get(Paths.get(fileName, '..', sourceMappingURL).toFile().getCanonicalPath()).toFile();
if (file.exists()) { sourceContent = base.read(file) }
}
if (sourceContent) {
MiaoScriptConsole.sourceMaps[fileName] = new SourceMapBuilder(JSON.parse(sourceContent))
MiaoScriptConsole.sourceFileMaps[fileName] = Paths.get(fileName, '..', MiaoScriptConsole.sourceMaps[fileName].sources[0]).toFile().getCanonicalPath()
this.sourceMaps[fileName] = new SourceMapBuilder(JSON.parse(sourceContent))
this.sourceFileMaps[fileName] = Paths.get(fileName, '..', this.sourceMaps[fileName].sources[0]).toFile().getCanonicalPath();
}
}
}
if (MiaoScriptConsole.sourceMaps[fileName]) {
let sourceMapping = MiaoScriptConsole.sourceMaps[fileName].getSource(lineNumber, 25, true, true)
fileName = MiaoScriptConsole.sourceFileMaps[fileName]
if (sourceMapping && lineNumber != sourceMapping.mapping.sourceLine) { lineNumber = sourceMapping.mapping.sourceLine }
if (this.sourceMaps[fileName]) {
let sourceMapping = this.sourceMaps[fileName].getSource(lineNumber, 25, true, true);
fileName = this.sourceFileMaps[fileName]
if (sourceMapping && lineNumber != sourceMapping.mapping.sourceLine) { lineNumber = sourceMapping.mapping.sourceLine; }
}
}
} catch (error) {
@@ -128,26 +128,22 @@ export class MiaoScriptConsole implements Console {
lineNumber
}
}
stack(ex: Error, color: boolean = true): string[] {
let stack = ex.getStackTrace()
let cache = [(color ? '§c' : '') + ex]
stack(ex: Error): string[] {
let stack = ex.getStackTrace();
let cache = ['§c' + ex];
//@ts-ignore
if (stack.class) {
stack = Arrays.asList(stack)
}
stack.forEach(trace => {
if (!trace.fileName || trace.fileName.startsWith('jar:file:') || trace.fileName.startsWith('file:')) { return }
if (trace.fileName.startsWith('jar:file:')) { return }
if (trace.className.startsWith('<')) {
let { fileName, lineNumber } = this.readSourceMap(trace.fileName, trace.lineNumber)
if (fileName.startsWith(root)) { fileName = fileName.split(root)[1] }
if (color) {
cache.push(` §e->§c ${fileName}:${lineNumber} => §4${trace.methodName}`)
} else {
cache.push(` -> ${fileName}:${lineNumber} => ${trace.methodName}`)
}
cache.push(` §e->§c ${fileName} => §4${trace.methodName}:${lineNumber}`)
} else {
let className = trace.className
var fileName = trace.fileName as string
let className = trace.className;
var fileName = trace.fileName as string;
if (className.startsWith('jdk.nashorn.internal.scripts')) {
className = className.substr(className.lastIndexOf('$') + 1)
var { fileName, lineNumber } = this.readSourceMap(trace.fileName, trace.lineNumber)
@@ -155,74 +151,70 @@ export class MiaoScriptConsole implements Console {
} else {
for (let prefix in ignoreLogPrefix) {
if (className.startsWith(ignoreLogPrefix[prefix])) {
return
return;
}
}
}
if (color) {
cache.push(` §e->§c ${className}.${trace.methodName}(§4${fileName}:${lineNumber}§c)`)
} else {
cache.push(` -> ${className}.${trace.methodName}(${fileName}:${lineNumber})`)
}
cache.push(` §e->§c ${className}.${trace.methodName}(§4${fileName}:${lineNumber}§c)`);
}
})
return cache
});
return cache;
}
assert(value: any, message?: string, ...optionalParams: any[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
clear(): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
count(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
countReset(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
dir(obj: any, options?: NodeJS.InspectOptions): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
dirxml(...data: any[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
group(...label: any[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
groupCollapsed(...label: any[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
groupEnd(): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
table(tabularData: any, properties?: string[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
time(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
timeEnd(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
timeLog(label?: string, ...data: any[]): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
markTimeline(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
profile(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
profileEnd(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
timeStamp(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
timeline(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
timelineEnd(label?: string): void {
throw new Error("Method not implemented.")
throw new Error("Method not implemented.");
}
}

View File

@@ -11,7 +11,6 @@ export namespace constants {
Bukkit = 'bukkit',
Sponge = 'sponge',
Nukkit = 'nukkit',
Bungee = 'bungee',
Spring = 'spring'
Bungee = 'bungee'
}
}

View File

@@ -1,7 +0,0 @@
export namespace amqp {
export const Manager = Symbol('AmqpManager')
export namespace rabbit {
export const Admin = Symbol('RabbitAdmin')
export const Template = Symbol('RabbitTemplate')
}
}

View File

@@ -1,5 +0,0 @@
export namespace database {
export const DataBaseManager = Symbol("DataBaseManager");
export const DataSource = Symbol("DataSource");
export const DataBase = Symbol("DataBase");
}

View File

@@ -1,5 +1,2 @@
export * from './web'
export * from './amqp'
export * from './plugin'
export * from './server'
export * from './database'

View File

@@ -2,186 +2,73 @@ export namespace plugin {
/**
* MiaoScript Plugin
*/
export const Plugin = Symbol("Plugin")
export const Plugin = Symbol("Plugin");
/**
* MiaoScript Plugin Folder
*/
export const PluginFolder = Symbol("PluginFolder")
export const PluginFolder = Symbol("PluginFolder");
/**
* Runtime Plugin Instance
*/
export const PluginInstance = Symbol("PluginInstance")
export const PluginInstance = Symbol("PluginInstance");
/**
* MiaoScript Plugin Manager Symbol
*/
export const PluginManager = Symbol("PluginManager")
export const PluginManager = Symbol("PluginManager");
/**
* MiaoScript Plugin Manager Interface
*/
export interface PluginManager {
scan(folder: string): void
build(): void
loadFromFile(file: string, scanner?: plugin.PluginScanner): Plugin
load(...args: any[]): void
enable(...args: any[]): void
disable(...args: any[]): void
reload(...args: any[]): void
getPlugin(name: string): plugin.Plugin
getPlugins(): Map<string, plugin.Plugin>
}
export const PluginScanner = Symbol("PluginScanner")
/**
* 插件加载元信息
*/
export interface PluginLoadMetadata {
/**
* 插件加载类型
*/
type: string
/**
* 插件名称
*/
name?: string
/**
* 插件文件
*/
file?: string
/**
* 插件实例
*/
instance?: any
/**
* 插件元信息
*/
metadata?: PluginMetadata
/**
* 插件扫描器
*/
scanner: PluginScanner
/**
* 插件加载器
*/
loader?: PluginLoader
/**
* 是否已加载
*/
loaded?: boolean
[key: string]: any
}
/**
* 插件扫描器
*/
export interface PluginScanner {
/**
* 扫描器类型
*/
type: string
/**
* 扫描插件目录 返回插件加载元信息列表
* @param target 扫描目标
*/
scan(target: any): PluginLoadMetadata[]
/**
* 读取插件 返回插件加载元信息
* @param target
*/
read(target: any): PluginLoadMetadata
/**
* 加载扫描到的目标
* @param target 加载目标
*/
load(target: PluginLoadMetadata): PluginLoadMetadata
}
export const PluginLoader = Symbol("PluginLoader")
/**
* 插件加载器
*/
export interface PluginLoader {
/**
* 加载器类型
*/
type: string
/**
* 加载插件 获取元数据
* @param target 加载目标
* @param result 扫描器加载的结果
*/
require(loadMetadata: PluginLoadMetadata): PluginLoadMetadata
/**
* 构建插件
* @param metadata 插件元信息
*/
build(metadata: PluginMetadata): Plugin
/**
* Load 阶段
* @param plugin 插件
*/
load(plugin: Plugin): void
/**
* Enable 阶段
* @param plugin 插件
*/
enable(plugin: Plugin): void
/**
* Disable 阶段
* @param plugin 插件
*/
disable(plugin: Plugin): void
/**
* Reload 阶段
* @param plugin 插件
*/
reload(plugin: Plugin): void
scan(folder: string): void;
build(): void;
loadFromFile(file: string): Plugin;
load(...args: any[]): void;
enable(...args: any[]): void;
disable(...args: any[]): void;
reload(...args: any[]): void;
getPlugins(): Map<string, any>;
}
export interface Plugin {
description: PluginMetadata
logger: Console
load(): void
enable(): void
disable(): void
description: PluginMetadata;
logger: Console;
load(): void;
enable(): void;
disable(): void;
}
export interface BaseMetadata {
interface BaseMetadata {
/**
* 名称 为空则为对象名称
*/
name?: string
name?: string;
/**
* 支持的服务器列表 为空则代表所有
*/
servers?: string[]
servers?: string[];
}
export interface PluginMetadata extends BaseMetadata {
/**
* 插件名称 不填默认为类名
* 插件名称
*/
name?: string
name: string;
/**
* 前缀
*/
prefix?: string
prefix?: string;
/**
* 插件版本 不填默认为 1.0.0
* 插件版本
*/
version?: string
version: string;
/**
* 插件作者 不填默认为 Unknow
* 插件版本
*/
author?: string | string[]
author: string | string[];
/**
* 插件源文件 必须指定为 __filename
*/
source: string
/**
* 插件类型 默认为 ioc 执行 MiaoScript 加载逻辑
*/
type?: string
/**
* 插件加载信息
*/
loadMetadata?: PluginLoadMetadata
source: string;
/**
* 插件本体
*/
target?: any
target?: any;
}
}

View File

@@ -1,160 +1,36 @@
import * as reflect from '@ccms/common/dist/reflect'
import { injectable, inject } from '@ccms/container'
import { NativePluginManager } from './native_plugin'
import { constants } from '../../constants'
export namespace server {
/**
* Runtime ServerType
*/
export const ServerType = Symbol("ServerType")
export const ServerType = Symbol("ServerType");
/**
* Runtime Console
*/
export const Console = Symbol("Console")
export const Console = Symbol("Console");
/**
* MiaoScript Server
*/
export const Server = Symbol("Server")
export const Server = Symbol("Server");
/**
* Runtime Server Instance
*/
export const ServerInstance = Symbol("ServerInstance")
export const ServerInstance = Symbol("ServerInstance");
/**
* MiaoScript Server
*/
export interface Server {
getVersion(): string
getPlayer(name: string): any
getOnlinePlayers(): any[]
getConsoleSender(): any
getService(service: string): any
dispatchCommand(sender: string | any, command: string): boolean
dispatchConsoleCommand(command: string): boolean
getPluginsFolder(): string
getNativePluginManager(): NativePluginManager
getDedicatedServer?(): any
getNettyPipeline(): any
getRootLogger(): any
sendJson(sender: string | any, json: object | string): void
tabComplete?(sender: string | any, input: string, index?: number): string[]
}
@injectable()
export class ServerChecker {
@inject(ServerType)
private serverType: string
check(servers: string[]) {
// Not set servers -> allow
if (!servers || !servers.length) return true
// include !type -> deny
let denyServers = servers.filter(svr => svr.startsWith("!"))
if (denyServers.length !== 0) {
return !denyServers.includes(`!${this.serverType}`)
} else {
// only include -> allow
return servers.includes(this.serverType)
}
}
}
@injectable()
export abstract class ReflectServer implements server.Server {
protected pipeline: any
protected rootLogger: any
constructor() {
this.reflect()
}
getVersion(): string {
throw new Error("Method not implemented.")
}
getPlayer(name: string) {
throw new Error("Method not implemented.")
}
getOnlinePlayers(): any[] {
throw new Error("Method not implemented.")
}
getConsoleSender() {
throw new Error("Method not implemented.")
}
getService(service: string) {
throw new Error("Method not implemented.")
}
dispatchCommand(sender: any, command: string): boolean {
throw new Error("Method not implemented.")
}
dispatchConsoleCommand(command: string): boolean {
throw new Error("Method not implemented.")
}
getPluginsFolder(): string {
throw new Error("Method not implemented.")
}
getNativePluginManager(): NativePluginManager {
throw new Error("Method not implemented.")
}
getDedicatedServer() {
throw new Error("Method not implemented.")
}
getNettyPipeline() {
throw new Error("Method not implemented.")
}
getRootLogger() {
throw new Error("Method not implemented.")
}
sendJson(sender: any, json: string | object): void {
throw new Error("Method not implemented.")
}
tabComplete?(sender: any, input: string, index?: number): string[] {
throw new Error("Method not implemented.")
}
protected reflect() {
try {
let consoleServer = this.getDedicatedServer()
this.reflectPipeline(consoleServer)
this.reflectRootLogger(consoleServer)
} catch (error) {
console.error('Error When Reflect MinecraftServer!', error)
console.ex(error)
}
}
protected reflectPipeline(consoleServer: any) {
let connection: any
let promise: any
for (const method of constants.Reflect.Method.getServerConnection) {
try {
connection = reflect.on(consoleServer).call(method).get()
if (connection.class.name.indexOf('ServerConnection') !== -1
|| connection.class.name.indexOf('NetworkSystem') !== -1) { break }
connection = undefined
} catch (error) { }
}
if (!connection) { console.error("Can't found ServerConnection!"); return }
for (const field of constants.Reflect.Field.listeningChannels) {
try {
promise = reflect.on(connection).get(field).get().get(0)
if (promise.class.name.indexOf('Promise') !== -1) { break }
promise = undefined
} catch (error) { }
}
if (!promise) { console.error("Can't found listeningChannels!"); return }
this.pipeline = reflect.on(promise).get('channel').get().pipeline()
}
protected reflectRootLogger(consoleServer: any) {
try {
this.rootLogger = reflect.on(consoleServer).get('LOGGER').get().parent
} catch (error) {
try { this.rootLogger = reflect.on(consoleServer).get(0).get().parent } catch (error) { }
}
if (this.rootLogger && this.rootLogger.class.name.indexOf('Logger') === -1) {
console.error('Error Logger Class: ' + this.rootLogger.class.name)
this.rootLogger = undefined
}
// get root logger
for (let index = 0; index < 5 && this.rootLogger.parent; index++) {
this.rootLogger = this.rootLogger.parent
}
if (!this.rootLogger) { console.error("Can't found rootLogger!") }
}
getVersion(): string;
getPlayer(name: string): any;
getOnlinePlayers(): any[];
getConsoleSender(): any;
getService(service: string): any;
dispatchCommand(sender: string | any, command: string): boolean;
dispatchConsoleCommand(command: string): boolean;
getPluginsFolder(): string;
getNativePluginManager(): NativePluginManager;
getNettyPipeline(): any;
sendJson(sender: string | any, json: object | string): void;
}
}

View File

@@ -1,3 +0,0 @@
export namespace web {
export const Server = Symbol('Server')
}

View File

@@ -58,9 +58,9 @@ export namespace task {
return this;
}
protected run(...args: any[]): void {
protected run(): void {
try {
this.func(...args);
this.func();
} catch (ex) {
console.console('§4插件执行任务时发生错误', ex)
console.ex(ex);
@@ -69,9 +69,8 @@ export namespace task {
/**
* 提交任务
* @param args 任务参数
*/
abstract submit(...args: any[]): Cancelable;
abstract submit(): Cancelable;
}
/**
* 返可取消的对象

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/bukkit",
"version": "0.8.4",
"version": "0.6.4",
"description": "MiaoScript bukkit package",
"keywords": [
"miaoscript",
@@ -19,14 +19,13 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"@javatypes/spigot-api": "^0.0.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
},
"dependencies": {
"@ccms/api": "^0.8.4",
"@ccms/common": "^0.8.4",
"@ccms/container": "^0.8.4"
"@ccms/api": "^0.6.4",
"@ccms/common": "^0.6.4",
"@ccms/container": "^0.6.0"
}
}

View File

@@ -8,30 +8,18 @@ const Messenger = Bukkit.getMessenger()
@provideSingleton(channel.Channel)
export class BukkitChannel extends channel.Channel {
@inject(plugin.PluginInstance)
private pluginInstance: any
private pluginInstance: any;
/**
* 给玩家发送通道消息
* @param player 接受消息的玩家
* @param channel 通道
* @param data 数据
*/
send(player: any, channel: string, data: number[]) {
player.sendPluginMessage(this.pluginInstance, channel, data)
send(player: any, channel: string, data: any) {
player.sendPluginMessage(this.pluginInstance, channel, data);
}
/**
* 注册通道监听器
* @param channel 通道
* @param listener 监听器
*/
register(channel: string, listener: channel.ChannelListener) {
Messenger.registerIncomingPluginChannel(this.pluginInstance, channel, new PluginMessageListener({
onPluginMessageReceived: (/**String */ channel, /**Player */ player, /**byte[] */data) => {
listener(data, { channel, player, data })
}
}))
Messenger.registerOutgoingPluginChannel(this.pluginInstance, channel)
}));
Messenger.registerOutgoingPluginChannel(this.pluginInstance, channel);
}
unregister(channel: string, listener: any) {
Messenger.unregisterIncomingPluginChannel(this.pluginInstance, channel)

View File

@@ -1,4 +1,4 @@
/// <reference types="@javatypes/spigot-api" />
/// <reference types="@ccms/types/dist/typings/bukkit" />
import { server } from '@ccms/api'
import { Container } from '@ccms/container'

View File

@@ -7,12 +7,13 @@ import chat from './enhance/chat'
let Bukkit = org.bukkit.Bukkit;
@provideSingleton(server.Server)
export class BukkitServer extends server.ReflectServer {
export class BukkitServer implements server.Server {
private pluginsFolder: string;
private pipeline: any;
constructor() {
super();
this.pluginsFolder = Bukkit.getUpdateFolderFile().getParentFile().getCanonicalPath();
this.reflectPipeline()
}
getPlayer(name: string) {
@@ -45,15 +46,9 @@ export class BukkitServer extends server.ReflectServer {
getNativePluginManager() {
return Bukkit.getPluginManager() as any;
}
getDedicatedServer() {
return reflect.on(Bukkit.getServer()).get('console').get()
}
getNettyPipeline() {
return this.pipeline;
}
getRootLogger() {
return this.rootLogger;
}
sendJson(sender: string | any, json: object | string): void {
if (typeof sender === "string") {
sender = this.getPlayer(sender)
@@ -63,4 +58,27 @@ export class BukkitServer extends server.ReflectServer {
this.dispatchConsoleCommand(result)
}
}
private reflectPipeline() {
let consoleServer = reflect.on(Bukkit.getServer()).get('console').get()
let connection: any;
let promise: any;
for (const method of constants.Reflect.Method.getServerConnection) {
try {
connection = reflect.on(consoleServer).call(method).get()
if (connection.class.name.indexOf('ServerConnection') !== -1) { break; }
connection = undefined;
} catch (error) { }
}
if (!connection) { console.error("Can't found ServerConnection!"); return }
for (const field of constants.Reflect.Field.listeningChannels) {
try {
promise = reflect.on(connection).get(field).get().get(0);
if (promise.class.name.indexOf('Promise') !== -1) { break; }
promise = undefined;
} catch (error) { }
}
if (!promise) { console.error("Can't found listeningChannels!"); return }
this.pipeline = reflect.on(promise).get('channel').get().pipeline()
}
}

View File

@@ -23,8 +23,10 @@ export class BukkitTaskManager implements task.TaskManager {
}
export class BukkitTask extends task.Task {
submit(...args: any[]): task.Cancelable {
let run = new BukkitRunnable({ run: () => this.run(...args) })
submit(): task.Cancelable {
let run = new BukkitRunnable({
run: () => this.run()
})
let funcName = `runTask${this.interval ? 'Timer' : 'Later'}${this.isAsync ? 'Asynchronously' : ''}`
if (this.interval) {
return run[funcName](this.plugin, this.laterTime, this.interval)

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/bungee",
"version": "0.8.4",
"version": "0.6.4",
"description": "MiaoScript bungee package",
"keywords": [
"miaoscript",
@@ -19,14 +19,13 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"@javatypes/bungee-api": "^0.0.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
},
"dependencies": {
"@ccms/api": "^0.8.4",
"@ccms/common": "^0.8.4",
"@ccms/container": "^0.8.4"
"@ccms/api": "^0.6.4",
"@ccms/common": "^0.6.4",
"@ccms/container": "^0.6.0"
}
}

View File

@@ -1,4 +1,4 @@
/// <reference types="@javatypes/bungee-api" />
/// <reference types="@ccms/types/dist/typings/bungee" />
import { server } from '@ccms/api'
import { Container } from '@ccms/container'

View File

@@ -9,7 +9,6 @@ let Bungee: net.md_5.bungee.api.ProxyServer = base.getInstance().getProxy();
export class BungeeServer implements server.Server {
private pluginsFolder: string;
private pipeline: any;
private rootLogger: any;
@inject(task.TaskManager)
private task: task.TaskManager
@@ -36,11 +35,6 @@ export class BungeeServer implements server.Server {
}
}
}).later(10).timer(20).submit()
try {
this.rootLogger = Bungee.getLogger()
} catch (error) {
console.error("Can't found rootLogger!")
}
}
getPlayer(name: string) {
@@ -76,9 +70,6 @@ export class BungeeServer implements server.Server {
getNettyPipeline() {
return this.pipeline;
}
getRootLogger() {
return this.rootLogger;
}
sendJson(sender: string | any, json: string): void {
throw new Error("Method not implemented.");
}

View File

@@ -22,8 +22,8 @@ export class BungeeTaskManager implements task.TaskManager {
}
export class BungeeTask extends task.Task {
submit(...args: any[]): task.Cancelable {
let run = new Runnable({ run: () => this.run(...args) })
submit(): task.Cancelable {
let run = new Runnable({ run: () => this.run() })
if (this.isAsync) {
return this.plugin.getProxy().getScheduler().runAsync(this.plugin, run)
}

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "@ccms/client",
"version": "0.8.3",
"version": "0.6.3",
"description": "MiaoScript client package",
"keywords": [
"miaoscript",
@@ -22,10 +22,10 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"minecraft-protocol": "^1.13.0"
"minecraft-protocol": "^1.11.0"
},
"devDependencies": {
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
}
}

View File

@@ -1 +0,0 @@
../../.npmignore

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -1,202 +1,196 @@
/// <reference types="@javatypes/jdk" />
/**
* 反射工具类
* Created by MiaoWoo on 2017/2/9 0009.
*/
const JavaClass = Java.type('java.lang.Class')
const JavaClass = Java.type('java.lang.Class');
const JavaObject = Java.type('java.lang.Object')
const NoSuchFieldException = Java.type('java.lang.NoSuchFieldException')
const methodCache = []
const NoSuchFieldException = Java.type('java.lang.NoSuchFieldException');
const methodCache = [];
class Reflect {
private obj: java.lang.Object
private class: java.lang.Class<any>
private obj: any;
private class: any
constructor(obj: any) {
// if (obj === undefined || obj === null) { throw Error(`reflect object can't be ${obj}!`) }
if (obj instanceof JavaClass) {
this.obj = null
this.class = obj
this.obj = null;
this.class = obj;
} else {
this.obj = obj
this.obj = obj;
if (obj !== null && obj !== undefined && obj.class) {
this.class = obj.class
this.class = obj.class;
}
}
}
method(name: string, ...args: java.lang.Class<any>[]) {
return declaredMethod(this.class, name, ...args)
method(...args: any[]) {
return declaredMethod(this.class, args[0], types(args.slice(1)));
}
methods() {
return Java.from(declaredMethods(this.class))
return Java.from(declaredMethods(this.class));
}
field(name: string | java.lang.String): Reflect {
field(name): Reflect {
try {
// Try getting a public field
let field = this.class.getField(name)
return on(field.get(this.obj))
let field = this.class.field(name);
return on(field.get(this.obj));
} catch (ex) {
// Try again, getting a non-public field
return on(accessible(declaredField(this.class, name)).get(this.obj))
return on(accessible(declaredField(this.class, name)).get(this.obj));
}
}
};
fields(declared = false): java.lang.reflect.Field[] {
return Java.from(declared ? this.class.getDeclaredFields() : this.class.getFields())
fields(declared = false) {
return Java.from(declared ? this.class.declaredFields : this.class.fields);
}
values(declared = false) {
return this.fields(declared).reduce((cache, field) => { return cache[field.getName()] = this.field(field.getName()).get() }, {}) as any
let cache = {};
this.fields(declared).forEach(fed => cache[fed.name] = this.field(fed.name).get())
return cache;
}
call(...args: any[]): Reflect {
let params = args.slice(1)
let method = accessible(declaredMethod(this.class, args[0], ...types(params)))
let result = method.invoke(this.get(), params)
return result && on(result)
}
call(...args): Reflect {
let params = args.slice(1);
let method = accessible(declaredMethod(this.class, args[0], types(params)));
let result = method.invoke(this.get(), params);
return result && on(result);
};
get(): any
get(index: number, declared?: boolean): Reflect
get(prop: string): Reflect
get(param?: string | number, declared: boolean = true): Reflect | any {
if (param == undefined || param == null) return this.obj
if (typeof param == "number") {
return on(accessible(this.fields(declared)[param]).get(this.obj))
}
if (typeof param == "string") {
return this.field(param)
}
}
get(...args): Reflect | any {
return args.length === 1 ? this.field(args[0]) : this.obj;
};
set(name: any, value: any): Reflect {
accessible(declaredField(this.class, name)).set(this.obj, value)
return this
}
// noinspection JSUnusedGlobalSymbols
set(name, value): Reflect {
accessible(declaredField(this.class, name)).set(this.obj, value);
return this;
};
create(...args): Reflect {
return on(declaredConstructor(this.class, args).newInstance(args))
}
return on(declaredConstructor(this.class, args).newInstance(args));
};
}
/**
* Get an array of types for an array of objects
*/
function types(values: any[], def?: any) {
function types(values, def?) {
if (values === null) {
return []
return [];
}
let result: java.lang.Class<any>[] = []
values.forEach(t => result.push((t || def) ? JavaObject.class : t instanceof JavaClass ? t : t.class))
return result
let result: any[] = [];
values.forEach(t => result.push((t || def) ? JavaObject.class : t instanceof JavaClass ? t : t.class));
return result;
}
function accessible<T extends java.lang.reflect.AccessibleObject>(accessible: T): T {
if (!accessible?.isAccessible()) {
accessible.setAccessible(true)
function accessible(accessible) {
if (accessible === null) {
return null;
}
return accessible
if (!accessible.isAccessible()) {
accessible.setAccessible(true);
}
return accessible;
}
function declaredConstructor(clazz, param) {
let constructor
let constructor;
try {
constructor = clazz.getDeclaredConstructor(types(param))
constructor = clazz.getDeclaredConstructor(types(param));
} catch (ex) {
try {
constructor = clazz.getDeclaredConstructor(types(param, true))
constructor = clazz.getDeclaredConstructor(types(param, true));
} catch (ex) {
constructor = clazz.getDeclaredConstructors()[0]
constructor = clazz.getDeclaredConstructors()[0];
}
}
return accessible(constructor)
return accessible(constructor);
}
function declaredField(clazz: java.lang.Class<any>, name: string | java.lang.String) {
function declaredField(clazz, name) {
if (!clazz) { throw Error(`target class can't be ${clazz}!`) }
let target = clazz
let field = null
let target = clazz;
let field = null;
// noinspection JSUnresolvedVariable
while (target !== JavaObject.class) {
try {
field = target.getDeclaredField(name)
if (field !== null) { break }
field = target.getDeclaredField(name);
if (field !== null) { break; }
} catch (e) {
if (target === undefined) { break }
target = target.getSuperclass()
if (target === undefined) { break; }
target = target.getSuperclass();
}
}
if (field === null) {
throw new NoSuchFieldException(name + " is not found in " + clazz.getName())
throw new NoSuchFieldException(name + " is not found in " + clazz.name);
}
return field
return field;
}
function declaredMethod(clazz: java.lang.Class<any>, name: string, ...clazzs: java.lang.Class<any>[]): java.lang.reflect.Method {
let key = clazz.getName() + '.' + name + ':' + (clazzs || []).join(':')
function declaredMethod(clazz, name, clazzs) {
let key = clazz.name + '.' + name + ':' + (clazzs || []).join(':');
if (!methodCache[key]) {
try {
// @ts-ignore
methodCache[key] = clazz.getMethod(name, clazzs)
methodCache[key] = clazz.getMethod(name, clazzs);
} catch (ex) {
try {
methodCache[key] = clazz.getDeclaredMethod(name, clazzs as any)
methodCache[key] = clazz.getDeclaredMethod(name, clazzs);
} catch (ex) {
for (const m of Java.from(declaredMethods(clazz))) {
if (m.getName() == name) {
methodCache[key] = m
break
if (m.name == name) {
methodCache[key] = m;
break;
}
}
}
}
}
return methodCache[key]
return methodCache[key];
}
function declaredMethods(clazz: java.lang.Class<any>) {
return clazz.getDeclaredMethods()
function declaredMethods(clazz) {
return clazz.declaredMethods;
}
let classMethodsCache: any[] = []
let classMethodsCache: any[] = [];
function mapToObject(javaObj) {
if (!javaObj || !javaObj.class) { throw new TypeError(`参数 ${javaObj} 不是一个Java对象!`) }
let target = {}
getJavaObjectMethods(javaObj).forEach(t => mapMethod(target, javaObj, t))
return target
let target = {};
getJavaObjectMethods(javaObj).forEach(t => mapMethod(target, javaObj, t));
return target;
}
function getJavaObjectMethods(javaObj) {
let className = javaObj.class.name
let className = javaObj.class.name;
if (!classMethodsCache[className]) {
let names: any[] = []
let methods = javaObj.class.methods
let names: any[] = [];
let methods = javaObj.class.methods;
for (let i in methods) {
names.push(methods[i].name)
names.push(methods[i].name);
}
classMethodsCache[className] = names
classMethodsCache[className] = names;
}
return classMethodsCache[className]
return classMethodsCache[className];
}
function mapMethod(target, source, name) {
target[name] = function __SimpleDynamicMethod__(...args) {
if (args.length > 0) {
return source[name](args)
return source[name](args);
} else {
return source[name]()
return source[name]();
}
}
};
}
function on(obj) {
// if (!obj || !obj.class) { throw new TypeError(`参数 ${obj} 不是一个Java对象!`) }
return new Reflect(obj)
return new Reflect(obj);
}
export = {

View File

@@ -1,32 +0,0 @@
const Thread = Java.type('java.lang.Thread')
const ThreadGroup = Java.type("java.lang.ThreadGroup")
const AtomicInteger = Java.type("java.util.concurrent.atomic.AtomicInteger")
const ThreadPoolExecutor = Java.type('java.util.concurrent.ThreadPoolExecutor')
const LinkedBlockingQueue = Java.type("java.util.concurrent.LinkedBlockingQueue")
interface ThreadPoolConfig {
corePoolSize?: number
maximumPoolSize?: number
keepAliveTime?: number
workQueueSize?: number
groupName: string
}
export default {
create(config: ThreadPoolConfig): java.util.concurrent.ThreadPoolExecutor {
let threadCount = new AtomicInteger(0)
config = {
corePoolSize: 10,
maximumPoolSize: 100,
keepAliveTime: 60,
workQueueSize: 500,
...config
}
return new ThreadPoolExecutor(
config.corePoolSize, config.maximumPoolSize, config.keepAliveTime, Packages.java.util.concurrent.TimeUnit.SECONDS,
new LinkedBlockingQueue(config.workQueueSize),
(run: any) => new Thread(new ThreadGroup(config.groupName), run, config.groupName + "-" + threadCount.incrementAndGet()),
new ThreadPoolExecutor.CallerRunsPolicy()
)
}
}

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/compile",
"version": "0.8.3",
"version": "0.6.0",
"description": "MiaoScript compile package",
"keywords": [
"miaoscript",
@@ -21,6 +21,6 @@
"devDependencies": {
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
}
}

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/container",
"version": "0.8.4",
"version": "0.6.0",
"description": "MiaoScript container package",
"keywords": [
"miaoscript",
@@ -19,10 +19,9 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"@ccms/nashorn": "^0.8.4",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
},
"dependencies": {
"inversify": "^5.0.1",

View File

@@ -1,7 +0,0 @@
export namespace ioc {
export const Autowired = Symbol('Autowired')
export const Resource = Symbol('Resource')
export const JavaClass = Symbol('JavaClass')
export const JavaInstance = Symbol('JavaInstance')
export const JavaStaticClass = Symbol('JavaStaticClass')
}

View File

@@ -1,9 +1,9 @@
import { interfaces, Container } from "inversify"
import { interfaces, Container } from "inversify";
let _container: Container
let _container: Container;
const ContainerInstance = Symbol.for("@ccms/ioc:Container")
const INJECTION = Symbol.for("INJECTION")
const ContainerInstance = Symbol.for("@ccms/ioc:Container");
const INJECTION = Symbol.for("INJECTION");
function _proxyGetter(
proto: any,
@@ -13,17 +13,17 @@ function _proxyGetter(
) {
function getter(this: object) {
if (doCache && !Reflect.hasMetadata(INJECTION, this, key)) {
Reflect.defineMetadata(INJECTION, resolve(), this, key)
Reflect.defineMetadata(INJECTION, resolve(), this, key);
}
if (Reflect.hasMetadata(INJECTION, this, key)) {
return Reflect.getMetadata(INJECTION, this, key)
return Reflect.getMetadata(INJECTION, this, key);
} else {
return resolve()
return resolve();
}
}
function setter(this: object, newVal: any) {
Reflect.defineMetadata(INJECTION, newVal, this, key)
Reflect.defineMetadata(INJECTION, newVal, this, key);
}
Object.defineProperty(proto, key, {
@@ -31,63 +31,63 @@ function _proxyGetter(
enumerable: true,
get: getter,
set: setter
})
});
}
function initContainer(container: Container) {
Reflect.defineMetadata(ContainerInstance, container, Reflect)
return _container = container
Reflect.defineMetadata(ContainerInstance, container, Reflect);
_container = container;
}
function getContainer(): Container {
return _container || initContainer(new Container())
return _container || Reflect.getMetadata(ContainerInstance, Reflect)
}
function makePropertyInjectDecorator(doCache: boolean) {
return function (serviceIdentifier: interfaces.ServiceIdentifier<any>) {
return function (proto: any, key: string): void {
return function(serviceIdentifier: interfaces.ServiceIdentifier<any>) {
return function(proto: any, key: string): void {
let resolve = () => {
return getContainer().get(serviceIdentifier)
}
_proxyGetter(proto, key, resolve, doCache)
}
}
return getContainer().get(serviceIdentifier);
};
_proxyGetter(proto, key, resolve, doCache);
};
};
}
function makePropertyInjectNamedDecorator(doCache: boolean) {
return function (serviceIdentifier: interfaces.ServiceIdentifier<any>, named: string) {
return function (proto: any, key: string): void {
return function(serviceIdentifier: interfaces.ServiceIdentifier<any>, named: string) {
return function(proto: any, key: string): void {
let resolve = () => {
return getContainer().getNamed(serviceIdentifier, named)
}
_proxyGetter(proto, key, resolve, doCache)
}
}
return getContainer().getNamed(serviceIdentifier, named);
};
_proxyGetter(proto, key, resolve, doCache);
};
};
}
function makePropertyInjectTaggedDecorator(doCache: boolean) {
return function (serviceIdentifier: interfaces.ServiceIdentifier<any>, key: string, value: any) {
return function (proto: any, propertyName: string): void {
return function(serviceIdentifier: interfaces.ServiceIdentifier<any>, key: string, value: any) {
return function(proto: any, propertyName: string): void {
let resolve = () => {
return getContainer().getTagged(serviceIdentifier, key, value)
}
_proxyGetter(proto, propertyName, resolve, doCache)
}
}
return getContainer().getTagged(serviceIdentifier, key, value);
};
_proxyGetter(proto, propertyName, resolve, doCache);
};
};
}
function makePropertyMultiInjectDecorator(doCache: boolean) {
return function (serviceIdentifier: interfaces.ServiceIdentifier<any>) {
return function (proto: any, key: string): void {
return function(serviceIdentifier: interfaces.ServiceIdentifier<any>) {
return function(proto: any, key: string): void {
let resolve = () => {
return getContainer().getAll(serviceIdentifier)
}
_proxyGetter(proto, key, resolve, doCache)
}
}
return getContainer().getAll(serviceIdentifier);
};
_proxyGetter(proto, key, resolve, doCache);
};
};
}
let doCache = true
let doCache = true;
let lazyInject = makePropertyInjectDecorator(doCache)
let lazyInjectNamed = makePropertyInjectNamedDecorator(doCache)
@@ -102,4 +102,4 @@ export {
lazyInjectNamed,
lazyInjectTagged,
lazyMultiInject
}
};

View File

@@ -1,91 +1,25 @@
/// <reference types="@ccms/nashorn" />
import "reflect-metadata";
import { initContainer } from './decorators'
import { interfaces, Container } from 'inversify';
import { fluentProvide } from 'inversify-binding-decorators';
import "reflect-metadata"
import { initContainer, getContainer } from './decorators'
import { interfaces, Container } from 'inversify'
import { fluentProvide } from 'inversify-binding-decorators'
import { ioc } from "./constants"
const provideNamed = (identifier: interfaces.ServiceIdentifier<any>, name: string) => {
return fluentProvide(identifier).whenTargetNamed(name).done();
};
/**
* 注册一个命名对象
* @param identifier 标识符
* @param name 名称
*/
export const provideNamed = (identifier: interfaces.ServiceIdentifier<any>, name: string) => {
return fluentProvide(identifier).whenTargetNamed(name).done()
}
const provideSingleton = (identifier: interfaces.ServiceIdentifier<any>) => {
return fluentProvide(identifier).inSingletonScope().done();
};
/**
* 注册一个单例对象
* @param identifier 标识符
*/
export const provideSingleton = (identifier: interfaces.ServiceIdentifier<any>) => {
return fluentProvide(identifier).inSingletonScope().done()
}
/**
* 注册一个单例对象
* @param identifier 标识符
*/
export const provideSingletonNamed = (identifier: interfaces.ServiceIdentifier<any>, name: string) => {
return fluentProvide(identifier).inSingletonScope().whenTargetNamed(name).done()
}
/**
* 获得一个 java.lang.Class
* @param className Java全类名
*/
export const JavaClass = (className: string) => {
return function (target: any, propertyKey: string, index?: number) {
try { target[propertyKey] = Java.type(className).class; return } catch (error) { }
try { target[propertyKey] = base.getClass(className); return } catch (error) { }
console.warn('JavaClass Inject target', target, 'propertyKey', propertyKey, 'failed!')
}
}
/**
* 获得一个JS的Java类
* @param className Java 全类名
*/
export const JSClass = (className: string) => {
return function (target: any, propertyKey: string, index?: number) {
try { target[propertyKey] = Java.type(className); return } catch (error) { }
try { target[propertyKey] = base.getClass(className).static; return } catch (error) { }
console.warn('JSClass Inject target', target, 'propertyKey', propertyKey, 'failed!')
}
}
/**
* 自动注入实例由平台实现
* @param className 类名
*/
export const Autowired = (className?: string | any) => {
return function (target: any, propertyKey: string) {
target[propertyKey] = getContainer().getNamed(ioc.Autowired, className || propertyKey)
}
}
/**
* 自动注入资源由平台实现
* @param className 类名
*/
export const Resource = (resourceName?: string | any) => {
return function (target: any, propertyKey: string) {
target[propertyKey] = getContainer().getNamed(ioc.Resource, resourceName || propertyKey)
}
}
export const reduceMetadata = (ctx: interfaces.Context): any => {
return ctx.currentRequest.target.metadata.reduce((result, entry, index) => {
result[entry.key] = entry.value
return result
}, {})
}
export const DefaultContainer = new Container()
initContainer(DefaultContainer)
const DefaultContainer = new Container();
initContainer(DefaultContainer);
export * from 'inversify'
export * from './constants'
export * from './decorators'
export * from 'inversify-binding-decorators'
export {
fluentProvide,
provideNamed,
provideSingleton,
DefaultContainer
};

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/core",
"version": "0.8.4",
"version": "0.6.4",
"description": "MiaoScript api package",
"keywords": [
"miaoscript",
@@ -21,11 +21,11 @@
"devDependencies": {
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
},
"dependencies": {
"@ccms/api": "^0.8.4",
"@ccms/container": "^0.8.4"
"@ccms/api": "^0.6.4",
"@ccms/container": "^0.6.0"
},
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
}

View File

@@ -4,7 +4,6 @@ import { plugin, server, task, constants } from '@ccms/api'
import { DefaultContainer as container, inject, provideSingleton, ContainerInstance, buildProviderModule } from '@ccms/container'
console.i18n("ms.core.ioc.completed", { scope: global.scope, time: (Date.now() - containerStartTime) / 1000 })
import http from '@ccms/common/dist/http'
import { EventEmitter } from 'events'
@provideSingleton(MiaoScriptCore)
class MiaoScriptCore {
@@ -31,11 +30,11 @@ class MiaoScriptCore {
}
loadTaskFunction() {
global.setGlobal('setTimeout', (func: Function, tick: number, ...args: any[]) => {
return this.taskManager.create(func).later(tick).submit(...args)
global.setGlobal('setTimeout', (func: Function, tick: number, async: boolean = false) => {
this.taskManager.create(func).later(tick).async(async).submit()
}, { writable: false, configurable: false })
global.setGlobal('setInterval', (func: Function, tick: number, ...args: any[]) => {
return this.taskManager.create(func).timer(tick).submit(...args)
global.setGlobal('setInterval', (func: Function, tick: number, async: boolean = false) => {
this.taskManager.create(func).timer(tick).async(async).submit()
}, { writable: false, configurable: false })
}
@@ -44,16 +43,17 @@ class MiaoScriptCore {
console.i18n("ms.core.plugin.initialize")
this.pluginManager.scan(this.pluginFolder)
this.pluginManager.build()
this.pluginManager.load(this.pluginManager.getPlugins())
this.pluginManager.enable(this.pluginManager.getPlugins())
this.pluginManager.load()
this.pluginManager.enable()
console.i18n("ms.core.plugin.completed", { time: (new Date().getTime() - loadPluginStartTime) / 1000 })
}
disable() {
console.i18n("ms.core.engine.disable")
this.pluginManager.disable(this.pluginManager.getPlugins())
this.pluginManager.disable()
this.taskManager.disable()
process.exit(0)
//@ts-ignore
require.disable()
}
}
@@ -78,11 +78,6 @@ function detectServer(): constants.ServerType {
return constants.ServerType.Bungee
} catch (ex) {
}
try {
Java.type("org.springframework.boot.SpringApplication")
return constants.ServerType.Spring
} catch (ex) {
}
throw Error('Unknow Server Type...')
}
@@ -97,7 +92,6 @@ function initialize() {
let type = detectServer()
console.i18n("ms.core.initialize.detect", { scope: global.scope, type })
container.bind(server.ServerType).toConstantValue(type)
container.bind(server.ServerChecker).toSelf().inSingletonScope()
console.i18n("ms.core.package.initialize", { scope: global.scope, type })
require(`${global.scope}/${type}`).default(container)
require(`${global.scope}/plugin`)

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,31 +0,0 @@
{
"name": "@ccms/database",
"version": "0.8.4",
"description": "MiaoScript database package",
"keywords": [
"miaoscript",
"minecraft",
"bukkit",
"sponge"
],
"author": "MiaoWoo <admin@yumc.pw>",
"homepage": "https://github.com/circlecloud/ms.git",
"license": "ISC",
"main": "dist/index.js",
"scripts": {
"clean": "rimraf dist",
"watch": "tsc --watch",
"build": "yarn clean && tsc",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"@javatypes/spring-jdbc": "^0.0.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
},
"dependencies": {
"@ccms/api": "^0.8.4",
"@ccms/container": "^0.8.4"
}
}

View File

@@ -1,3 +0,0 @@
export const METADATA_KEY = {
}

View File

@@ -1,90 +0,0 @@
import { Model } from './model'
const HikariDataSource = Java.type('com.zaxxer.hikari.HikariDataSource')
const HikariConfig = Java.type('com.zaxxer.hikari.HikariConfig')
const JdbcTemplate = Java.type('org.springframework.jdbc.core.JdbcTemplate')
/**
* 数据库配置
*/
export interface DataBaseConfig {
/**
* 数据库连接串
*/
url: string | javax.sql.DataSource
/**
* 数据库驱动
*/
driverClassName?: string
/**
* 用户名
*/
username?: string
/**
* 密码
*/
password?: string
}
/**
* 数据库封装类
*/
export class DataBase {
private dataSource: javax.sql.DataSource
private jdbcTemplate: org.springframework.jdbc.core.JdbcTemplate
constructor(dbConfig: DataBaseConfig) {
if (!dbConfig.url) { throw new Error('DataBase url can\'t be null!') }
this.createDataSource(dbConfig)
this.initialize()
}
private createDataSource(dbConfig: DataBaseConfig) {
if (typeof dbConfig.url === "string") {
if (!dbConfig.username || !dbConfig.password) {
throw new Error('DataBase username or password can\'t be null!')
}
let config = new HikariConfig()
if (dbConfig.driverClassName) {
config.setDriverClassName(dbConfig.driverClassName)
}
config.setUsername(dbConfig.username)
config.setPassword(dbConfig.password)
config.setJdbcUrl(dbConfig.url)
this.dataSource = new HikariDataSource(config)
} else {
this.dataSource = dbConfig.url
}
}
private initialize() {
this.jdbcTemplate = new JdbcTemplate(this.dataSource)
}
/**
* 执行SQL查询
* @param sql SQL语句
*/
query<T>(sql: string, ...args: any[]): Array<T> {
let startTime = Date.now()
let result = Java.from<any>(this.jdbcTemplate.queryForList(sql, args))
console.debug(java.lang.String.format(`\n[DB] query \nSQL : ${sql.replace(/\?/ig, '%s')} \nCOST : ${Date.now() - startTime}ms`, args))
return result
}
/**
* 执行SQL更新
* @param sql SQL语句
*/
update(sql: string, ...args: any[]): number {
let startTime = Date.now()
let result = this.jdbcTemplate.update(sql, args)
console.debug(java.lang.String.format(`\n[DB] update \nSQL : ${sql.replace(/\?/ig, '%s')} \nCOST : ${Date.now() - startTime}ms`, args))
return result
}
close() {
//@ts-ignore
this.dataSource.close()
}
}

View File

@@ -1,7 +0,0 @@
import 'reflect-metadata'
export function id() {
return (target: Object, propertyKey: string | symbol) => void {
}
}

View File

@@ -1,6 +0,0 @@
/// <reference types="@ccms/nashorn" />
/// <reference types="@javatypes/jdk" />
/// <reference types="@javatypes/spring-jdbc" />
export * from './database'
export * from './manager'

View File

@@ -1,53 +0,0 @@
import { plugin, database } from '@ccms/api'
import { provideSingleton, inject, postConstruct } from '@ccms/container'
import { DataBase, DataBaseConfig } from './database'
@provideSingleton(database.DataBaseManager)
export class DataBaseManager {
@inject(plugin.PluginInstance)
private instance: any
private beanFactory: any
private mainDatabase: DataBase
private databases: { [key: string]: DataBase } = {}
@postConstruct()
initialize() {
try {
this.beanFactory = this.instance.getAutowireCapableBeanFactory()
let mainDatasource = this.beanFactory.getBean(Packages.javax.sql.DataSource.class)
this.mainDatabase = new DataBase({ url: mainDatasource })
} catch (error) {
console.ex(error)
}
}
/**
* 获得主数据库
* Get MainDatabase
*/
getMainDatabase() {
return this.mainDatabase
}
/**
* 创建数据库
* Create A Database Instance
* @param name 数据库名称 用于代码 database Name use at code
* @param config 数据库配置
*/
createDatabase(name: string, config: DataBaseConfig) {
Java.synchronized(() => {
if (this.databases[name]) return this.databases[name]
return this.databases[name] = new DataBase(config)
}, this.databases)()
}
getDatabase(name: string) {
return this.databases[name]
}
disable() {
Object.values(this.databases).forEach((ds) => ds?.close())
}
}

View File

@@ -1,11 +0,0 @@
import { DataBase } from "./database"
export class Model<T> {
constructor(private database: DataBase) {
}
queryForList(): Array<T> {
return []
}
}

View File

@@ -1,7 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "src",
"outDir": "dist"
}
}

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -43,6 +43,4 @@ ms.plugin.manager.build.error: "§6Load Plugin From §b{file} §6failed. §4Erro
ms.plugin.manager.build.update: "Auto Update Plugin {name} ..."
ms.plugin.manager.build.not.extends: "§4Found error plugin §b{source} §4it's not extends interfaces.Plugin, the plugin will be ignore!"
ms.plugin.manager.build.exists: "§4Found duplicate plugin §b{exists} §4and §b{source}§4. the first plugin will be ignore!"
ms.plugin.manager.config.load.error: "[{plugin}] config {name}.{format} load failed. Error: {error}"
ms.plugin.manager.config.save.error: "[{plugin}] config {name}.{format} save failed. Error: {error}"
ms.plugin.manager.config.save.default: "[{plugin}] config {name}.{format} not exists. auto create from default variable..."

View File

@@ -43,6 +43,4 @@ ms.plugin.manager.build.error: "§6从文件 §b{file} §6加载插件失败 §4
ms.plugin.manager.build.update: "自动更新插件 {name} ..."
ms.plugin.manager.build.not.extends: "§4发现错误的插件 §b{source} §4未继承接口 interfaces.Plugin, 将不会被载入到服务器!"
ms.plugin.manager.build.duplicate: "§4发现已存在插件 §b{exists} §4和 §b{source}§4 存在冲突. 已存在插件将会被替换!"
ms.plugin.manager.config.load.error: "[{plugin}] 配置 {name}.{format} 加载失败. 错误: {error}"
ms.plugin.manager.config.save.error: "[{plugin}] 配置 {name}.{format} 保存失败. 错误: {error}"
ms.plugin.manager.config.save.default: "[{plugin}] 配置 {name}.{format} 不存在. 从默认值自动创建保存..."

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/i18n",
"version": "0.8.4",
"version": "0.6.4",
"description": "MiaoScript i18n package",
"keywords": [
"miaoscript",
@@ -19,14 +19,14 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"@ccms/nashorn": "^0.8.4",
"@types/js-yaml": "^3.12.5",
"@types/js-yaml": "^3.12.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
},
"dependencies": {
"js-yaml": "^3.14.0"
"@ccms/nashorn": "^0.6.4",
"js-yaml": "^3.13.1"
},
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
}

View File

@@ -1,35 +0,0 @@
{
"name": "@ccms/keyvalue",
"version": "0.8.4",
"description": "MiaoScript keyvalue package",
"keywords": [
"miaoscript",
"minecraft",
"bukkit",
"sponge"
],
"author": "MiaoWoo <admin@yumc.pw>",
"homepage": "https://github.com/circlecloud/ms.git",
"license": "ISC",
"main": "dist/index.js",
"scripts": {
"clean": "rimraf dist",
"watch": "tsc --watch",
"build": "yarn clean && tsc",
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@ccms/api": "^0.8.4",
"@ccms/common": "^0.8.4",
"@ccms/container": "^0.8.4"
},
"devDependencies": {
"@ccms/nashorn": "^0.8.4",
"@javatypes/amqp-client": "^0.0.2",
"@javatypes/spring-amqp": "^0.0.2",
"@javatypes/spring-rabbit": "^0.0.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
}
}

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -0,0 +1,22 @@
test
typings
bundled
build
coverage
docs
wiki
gulpfile.js
bower.json
karma.conf.js
tsconfig.json
typings.json
CONTRIBUTING.md
ISSUE_TEMPLATE.md
PULL_REQUEST_TEMPLATE.md
tslint.json
wallaby.js
.travis.yml
.gitignore
.vscode
.theia
type_definitions

12
packages/nashorn/build.sh Executable file
View File

@@ -0,0 +1,12 @@
# sponge bukkit jdk bungee nukkit
TYPE=nukkit
TARGET=../types/dist/typings
npx tsc src/build.ts --outDir dist
cd dist
rm -rf temp
mkdir -p temp
node build.js ${TYPE}
cd ../
rm -rf ${TARGET}/${TYPE}
mkdir -p ${TARGET}/${TYPE}
cp dist/temp/* ${TARGET}/${TYPE}/ -R

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/nashorn",
"version": "0.8.4",
"version": "0.6.4",
"description": "MiaoScript api package",
"keywords": [
"miaoscript",
@@ -22,6 +22,6 @@
"devDependencies": {
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
}
}

View File

@@ -0,0 +1,200 @@
import * as fs from "fs";
function convertJson2TypeDefiend(infile: string, outDir: string) {
const file = infile.split(".json")[0];
const json = fs.readFileSync(`${inDir}/${file}.json`).toString();
const obj = JSON.parse(json);
const qnas: string[] = obj.qualifiedName.split(".");
let closeBuk = 0;
let temp = `declare namespace ${qnas[0]} {\n`;
closeBuk++;
const nms = qnas.slice(1, qnas.length - 1);
for (const nm of nms) {
temp += `${' '.repeat(closeBuk)}namespace ${nm.replace('function', 'function$')} {\n`;
closeBuk++;
}
let classModifier = formatClassModifier(obj.modifiers)
temp += `${' '.repeat(closeBuk)}// @ts-ignore\n`
temp += `${' '.repeat(closeBuk)}${classModifier}${qnas[qnas.length - 1]}`
let isInterface = classModifier.includes('interface')
let safeInterface = [];
for (const ifs of obj.interfaces) {
if (!ifs.qualifiedName.startsWith('java')) {
safeInterface.push(ifs)
}
}
if (isInterface) {
if (safeInterface.length > 0) {
temp += ' extends '
for (const ifs of safeInterface) {
temp += ifs.qualifiedName;
temp += ', '
}
temp = temp.substr(0, temp.length - 2);
}
} else {
temp += `${(obj.superclass) ? (' extends ' + (obj.superclass.qualifiedName == "<any>" ? "object" : obj.superclass.qualifiedName)) : ''}`;
if (safeInterface.length > 0) {
temp += ' implements '
for (const ifs of safeInterface) {
temp += ifs.qualifiedName;
temp += ', '
}
temp = temp.substr(0, temp.length - 2);
}
}
temp += ' {\n'
closeBuk++;
for (const constructor of obj.constructors) {
temp += `${formatDoc(constructor.docString, closeBuk)}${' '.repeat(closeBuk)}// @ts-ignore\n${' '.repeat(closeBuk)}constructor(${formatParameters(constructor.parameters)})\n`;
}
let members = [];
let methods = '';
for (const method of obj.methods) {
let methodModifier = isInterface ? '' : replaceModifiers(method.modifiers, classModifier.includes('abstract'))
if (!whiteKey.includes(method.name)) {
if (members[method.name] && methodModifier.includes('abstract')) {
continue;
}
members[method.name] = methodModifier;
}
methods += `${formatDoc(method.docString, closeBuk)}${' '.repeat(closeBuk)}// @ts-ignore\n${' '.repeat(closeBuk)}${methodModifier} ${method.name}(${formatParameters(method.parameters)}): ${mappingType(method.returnType.type)};\n`;
}
let fields = '';
for (const field of obj.fields) {
if (members[field.name]) {
continue;
}
fields += `${' '.repeat(closeBuk)}// @ts-ignore\n${' '.repeat(closeBuk)}${isInterface ? '' : replaceModifiers(field.modifiers)} ${field.name}: ${mappingType(field.type ? field.type.type : "any")};\n`;
}
temp += fields + methods;
for (let index = 0; index < closeBuk; index++) {
temp += `${' '.repeat(closeBuk - index - 1)}}\n`;
}
fs.writeFileSync(`${outDir}/${file}.${suffix}`, temp);
return `${file}.${suffix}`;
}
function formatClassModifier(modifiers: string) {
let tempm = modifiers.replace('public', '').replace('static', '').replace('final', '').trim();
if (!modifiers.includes('interface')) { tempm += ' class' }
return tempm.length > 0 ? (tempm + ' ') : '';
}
function formatDoc(doc: string, closeBuk: number) {
let middleDoc = '';
for (const line of doc.split('\n')) {
if (line.trim().length != 0) {
middleDoc += `${' '.repeat(closeBuk)} * ${line.trim()}\n`
}
}
return middleDoc.length > 0 ? `${' '.repeat(closeBuk)}/**\n${middleDoc}${' '.repeat(closeBuk)} */\n` : '';
}
function replaceModifiers(modifiers: string, absClass = false): string {
// modifiers = modifiers.replace(' final', ' readonly');
modifiers = modifiers.split(" final")[0];
modifiers = modifiers.split(" native")[0];
modifiers = modifiers.split(" volatile")[0];
modifiers = modifiers.split(" transient")[0];
modifiers = modifiers.split(" synchronized")[0];
if (!absClass) {
modifiers = modifiers.split(" abstract")[0];
}
return modifiers;
}
function formatParameters(params: any[]) {
let tempParam = '';
for (const p of params) {
tempParam += `${mappingName(p.name)}: ${mappingType(p.type ? p.type.qualifiedName : 'any')}, `
}
return tempParam.substr(0, tempParam.length - 2);
}
const nameMap = [];
nameMap['function'] = 'func'
nameMap['in'] = 'input'
nameMap['var'] = 'variable'
function mappingName(name: string) {
if (whiteKey.includes(name)) { return name }
let outName = nameMap[name] || name || '';
return outName;
}
let whiteKey = ['shift', "map", 'filter', 'values', 'valueOf', 'toString', 'length', 'includes', 'entries', 'keys', 'join', 'fill']
const typeMap = [];
typeMap['int'] = 'number';
typeMap['int[]'] = 'number[]';
typeMap['int[][]'] = 'number[][]';
typeMap['byte'] = 'number';
typeMap['byte[]'] = 'number[]';
typeMap['double'] = 'number';
typeMap['double[]'] = 'number[]';
typeMap['short'] = 'number';
typeMap['short[]'] = 'number[]';
typeMap['float'] = 'number';
typeMap['float[]'] = 'number[]';
typeMap['long'] = 'number';
typeMap['long[]'] = 'number[]';
typeMap['<any>'] = 'any';
typeMap['char'] = 'string';
typeMap['char[]'] = 'string[]';
typeMap['java.lang.String'] = "string";
// typeMap['java.util.Date'] = 'any /*java.util.Date*/'
// typeMap['java.util.List'] = 'any[] /*java.util.List*/'
// typeMap['java.util.Set'] = 'any[] /*java.util.Set*/'
// typeMap['java.util.Collection'] = 'any[] /*java.util.Collection*/'
// typeMap['java.util.Map'] = 'Map<any, any> /*java.util.Map*/'
// Sponge
typeMap['Vectori'] = 'any /*Vector3i*/'
typeMap['Vectord'] = 'any /*Vector3d*/'
typeMap['Vectorf'] = 'any /*Vector3f*/'
typeMap['Vector2i'] = 'any /*Vector2i*/'
typeMap['Vector2d'] = 'any /*Vector2d*/'
typeMap['Vector2f'] = 'any /*Vector2f*/'
typeMap['Vector3i'] = 'any /*Vector3i*/'
typeMap['Vector3d'] = 'any /*Vector3d*/'
typeMap['Vector3f'] = 'any /*Vector3f*/'
typeMap['Type'] = 'any /*Type*/'
typeMap['Gson'] = 'any /*Gson*/'
typeMap['Logger'] = 'any /*Logger*/'
typeMap['MethodVisitor'] = 'any /*MethodVisitor*/'
typeMap['ConfigurationNode'] = 'any /*ConfigurationNode*/'
typeMap['TypeSerializerCollection'] = 'any /*TypeSerializerCollection*/'
typeMap['Quaterniond'] = 'any /*Quaterniond*/'
typeMap['Matrix2d'] = 'any /*Matrix2d*/'
typeMap['Matrix3d'] = 'any /*Matrix3d*/'
typeMap['Matrix4d'] = 'any /*Matrix4d*/'
function mappingType(type: string): string {
let outType = typeMap[type] || type || 'any';
if (outType.indexOf('.') != -1) {
if (outType.startsWith('java.') || outType.startsWith('org.') || outType.startsWith('net.') || outType.startsWith('cn.')) {
} else {
outType = `any /*${outType}*/`
}
}
return outType.replace('function', 'function$');
}
var args = process.argv.splice(2)
const suffix = 'd.ts'
const inDir = `../docs/${args[0]}`
const outDir = "./temp";
const files = fs.readdirSync(inDir);
let index = '';
for (const file of files) {
index += `/// <reference path="./${convertJson2TypeDefiend(file, outDir)}" />\n`;
}
fs.writeFileSync(`${outDir}/index.${suffix}`, index);

View File

@@ -1,86 +1,75 @@
declare global {
const __FILE__: string
const __LINE__: number
const __DIR__: string
const Packages: any
const __FILE__: string;
const __LINE__: number;
const __DIR__: string;
let Packages: any;
function print(...message: any[]): void
function load(script: string | object)
function loadWithNewGlobal(script: string | object)
function exit(code?: number)
function quit(code?: number)
function JavaImporter(...className: string[])
function print(...message: any[]): void;
function load(script: string | object);
function loadWithNewGlobal(script: string | object);
function exit(code?: number);
function quit(code?: number);
function JavaImporter(...className: string[]);
namespace Java {
function type<T = any>(clazz: string): T
function from<T = any>(javaObj: T[]): T[]
function to<T = any>(array: T[], type?: T): T[]
function extend(...parentTypes: any[]): any
function synchronized(func: () => void, lock: any): Function
function asJSONCompatible<T = any>(obj: T): T
function type(clazz: string): any;
function from(javaObj: any): any[];
function to(array: any[]): any;
function extend(...parentTypes: any[]);
//@ts-ignore
// function super(type: any);
}
interface Error {
readonly class?: any
readonly lineNumber?: number
readonly columnNumber?: number
readonly fileName?: string
dumpStack?: Function
printStackTrace?: Function
getStackTrace?: () => any[]
readonly lineNumber?: number;
readonly columnNumber?: number;
readonly fileName?: string;
dumpStack?: Function;
printStackTrace?: Function;
getStackTrace?: () => any[];
}
interface String {
trimLeft(): string
trimRight(): string
trimLeft(): string;
trimRight(): string;
}
interface Object {
setPrototypeOf(obj: object, prototype: object): void
bindProperties(to: object, from: object): void
setPrototypeOf(obj: object, prototype: object): void;
bindProperties(to: object, from: object): void;
}
namespace NodeJS {
interface Global {
scope: string
logger: any
debug: boolean
level: string
NashornEngineStartTime: number
setGlobal: (key: string, value: any, config?: PropertyDescriptor & ThisType<any>) => void
noop: () => void
console: Console
}
interface Process {
on(event: string, listener: any): this
emit(event: string, ...message: any): this
scope: string;
logger: any;
debug: boolean;
level: string;
NashornEngineStartTime: number;
setGlobal: (key: string, value: any, config?: PropertyDescriptor & ThisType<any>) => void;
noop: () => void;
console: Console;
}
}
const root: string
const base: Core
const ScriptEngineContextHolder: any
function engineLoad(str: string | { script: string, name: string }): any
var root: string;
var base: Core;
var ScriptEngineContextHolder: any;
function engineLoad(str: string): any;
interface Core {
getClass(name: String): any
getProxyClass(): any
getInstance(): any
read(path: string): string
save(path: string, content: string): void
delete(path: string): void
getClass(name: String): any;
getProxyClass(): any;
getInstance(): any;
read(path: string): string;
save(path: string, content: string): void;
delete(path: string): void;
}
interface Console {
ex(err: Error): void
stack(err: Error, color?: boolean): string[]
sender(sender: any, ...args: any): void
sender(...args: any): void
console(...args: any): void
i18n(name: string, ...params: any[]): void
}
interface ProxyConstructor {
newProxy<T extends object>(target: T, handler: ProxyHandler<T>): T
ex(err: Error): void;
stack(err: Error): string[];
sender(...args: any): void;
console(...args: any): void;
i18n(name: string, ...params: any[]): void;
}
}
export { }
export { };

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/nodejs",
"version": "0.8.4",
"version": "0.6.4",
"description": "MiaoScript nodejs package",
"keywords": [
"miaoscript",
@@ -19,10 +19,12 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"@ccms/nashorn": "^0.8.4",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
},
"dependencies": {
"@ccms/nashorn": "^0.6.4"
},
"gitHead": "781524f83e52cad26d7c480513e3c525df867121"
}

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/nukkit",
"version": "0.8.4",
"version": "0.6.4",
"description": "MiaoScript nukkit package",
"keywords": [
"miaoscript",
@@ -19,14 +19,13 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"@javatypes/nukkit-api": "^0.0.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
},
"dependencies": {
"@ccms/api": "^0.8.4",
"@ccms/common": "^0.8.4",
"@ccms/container": "^0.8.4"
"@ccms/api": "^0.6.4",
"@ccms/common": "^0.6.4",
"@ccms/container": "^0.6.0"
}
}

View File

@@ -1,4 +1,4 @@
/// <reference types="@javatypes/nukkit-api" />
/// <reference types="@ccms/types/dist/typings/nukkit" />
import { server } from '@ccms/api'
import { Container } from '@ccms/container'

View File

@@ -45,9 +45,6 @@ export class NukkitServer implements server.Server {
getNettyPipeline() {
throw new Error("Method not implemented.");
}
getRootLogger() {
return Packages.org.apache.logging.log4j.LogManager.getRootLogger()
}
sendJson(sender: string | any, json: object | string): void {
throw new Error("Method not implemented.");
}

View File

@@ -21,8 +21,10 @@ export class NukkitTaskManager implements task.TaskManager {
}
export class NukkitTask extends task.Task {
submit(...args: any[]): task.Cancelable {
let run = new NukkitRunnable({ run: () => this.run(...args) })
submit(): task.Cancelable {
let run = new NukkitRunnable({
run: () => this.run()
})
let funcName = `runTask${this.interval ? 'Timer' : 'Later'}${this.isAsync ? 'Asynchronously' : ''}`
if (this.interval) {
run[funcName](this.plugin, this.laterTime, this.interval);

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/ployfill",
"version": "0.8.4",
"version": "0.6.4",
"description": "MiaoScript ployfill package",
"author": "MiaoWoo <admin@yumc.pw>",
"homepage": "https://github.com/circlecloud/ms.git",
@@ -14,14 +14,13 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"dependencies": {
"@ccms/i18n": "^0.8.4",
"@ccms/nodejs": "^0.8.4",
"core-js": "^3.6.5"
"@ccms/i18n": "^0.6.4",
"@ccms/nashorn": "^0.6.4",
"core-js": "^3.6.4"
},
"devDependencies": {
"@ccms/nashorn": "^0.8.4",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
}
}

View File

@@ -1,15 +1,12 @@
/// <reference types="@ccms/nashorn" />
import '@ccms/nodejs'
import i18n from '@ccms/i18n'
let ployfillStartTime = new Date().getTime()
i18n.initialize()
console.i18n("ms.ployfill.initialize")
require('./es5-ext')
require('./node-shim')
require('core-js')
//@ts-ignore
process.on('exit', () => require.disable())
let ployfillStartTime = new Date().getTime();
i18n.initialize();
console.i18n("ms.ployfill.initialize");
require('./es5-ext');
require('core-js');
global.setGlobal('Proxy', require('./proxy').Proxy)
global.setGlobal('XMLHttpRequest', require('./xml-http-request').XMLHttpRequest)
global.setGlobal('Blob', require('blob-polyfill').Blob)
console.i18n("ms.ployfill.completed", { time: (new Date().getTime() - ployfillStartTime) / 1000 })
console.i18n("ms.ployfill.completed", { time: (new Date().getTime() - ployfillStartTime) / 1000 });

View File

@@ -1,37 +0,0 @@
import { EventEmitter } from 'events'
const Thread = Java.type('java.lang.Thread')
const ThreadGroup = Java.type("java.lang.ThreadGroup")
const AtomicInteger = Java.type("java.util.concurrent.atomic.AtomicInteger")
const ThreadPoolExecutor = Java.type('java.util.concurrent.ThreadPoolExecutor')
const LinkedBlockingQueue = Java.type("java.util.concurrent.LinkedBlockingQueue")
const threadCount = new AtomicInteger(0)
const threadGroup = new ThreadGroup("@ccms/ployfill-micro-task")
const microTaskPool = new ThreadPoolExecutor(
10, 100, 60, Packages.java.util.concurrent.TimeUnit.SECONDS,
new LinkedBlockingQueue(500),
(run: any) => new Thread(threadGroup, run, "@ccms/micro-task-" + threadCount.incrementAndGet()),
new ThreadPoolExecutor.CallerRunsPolicy()
)
class Process extends EventEmitter {
env = {
__noSuchProperty__: (prop) => {
return Packages.java.lang.System.getenv(prop)
}
}
platform = Packages.java.lang.System.getProperty("os.name")
nextTick(func: Function) {
microTaskPool.execute(func)
}
queueMicrotask(func: Function) {
microTaskPool.execute(func)
}
exit(code: number) {
process.emit('exit', code)
microTaskPool.shutdown()
}
}
global.setGlobal('process', new Process(), {})
global.setGlobal('queueMicrotask', (func: any) => microTaskPool.execute(func), {})

View File

@@ -82,12 +82,10 @@ export class XMLHttpRequest {
private _url: string;
private _async: boolean;
private _mimeType: string;
private _requestHeaders: HttpHeader = {};
private _status: number = 0;
private _statusText: string = null;
private _response: any;
private _responseText: any;
private _responseURL: string;
private _responseHeaders: HttpHeader = {};
@@ -116,10 +114,10 @@ export class XMLHttpRequest {
return this._statusText;
}
get response() {
return this._response || this.get();
return this._response ? JSON.parse(this._response) : this._response;
}
get responseText() {
return this._responseText;
return this._response;
}
get responseXML() {
return this._response;
@@ -128,17 +126,17 @@ export class XMLHttpRequest {
return this._responseURL;
}
public onload: () => void;
public onerror: (ex: Error) => void;
public onabort: () => void;
public onprogress: () => void;
public ontimeout: (ex: Error) => void;
public onloadend: () => void;
public onloadstart: () => void;
public onreadystatechange: () => void;
onload() { }
onerror(ex: Error) { }
onabort() { }
onprogress() { }
ontimeout(ex: Error) { }
onloadend() { }
onloadstart() { }
onreadystatechange() { }
setRequestHeader(key: string, val: string) {
this._requestHeaders[key] = val;
this._connection.setRequestProperty(key, val);
}
getResponseHeader(key: string): string {
return this._responseHeaders[key];
@@ -173,36 +171,30 @@ export class XMLHttpRequest {
this.setReadyState(ReadyState.OPENED);
}
send(body?: string | object): Future<string> {
for (const header in this._requestHeaders) {
this._connection.setRequestProperty(header, this._requestHeaders[header]);
}
if (this._readyState !== ReadyState.OPENED) { throw new Error(`Error Status ${this._readyState}!`) }
let future = executor.submit(new Callable({ call: () => this._send(body) }));
if (!this._async) { future.get() }
return future;
}
get() {
if (this._response === undefined) {
switch (this._responseType) {
case "json":
return this._response = JSON.parse(this._responseText);
case "text":
return this._response = this._responseText;
default:
throw Error(`Unsupport ResponseType: ${this._responseType} !`)
}
switch (this._responseType) {
case "json":
return this.response;
case "text":
return this.responseText;
default:
throw Error(`Unsupport ResponseType: ${this._responseType} !`)
}
return this._response;
}
abort() {
this._connection.disconnect();
this.onabort && this.onabort();
this.onabort();
}
private _send(body?: string | object) {
try {
this._connection.connect();
this.onloadstart && this.onloadstart();
this.onloadstart();
if (body) {
let bodyType = Object.prototype.toString.call(body);
if (typeof body !== "string") { throw new Error(`body(${bodyType}) must be string!`) }
@@ -215,14 +207,14 @@ export class XMLHttpRequest {
this._status = this._connection.getResponseCode();
this._statusText = this._connection.getResponseMessage();
if (this._status >= 0 && this._status < 300) {
this._responseText = this.readOutput(this._connection.getInputStream());
this._response = this.readOutput(this._connection.getInputStream());
} else if (this._status >= 300 && this._status < 400) {
this._responseURL = this.getResponseHeader('Location');
} else {
this._responseText = this.readOutput(this._connection.getErrorStream());
this._response = this.readOutput(this._connection.getErrorStream());
}
this.setResponseHeaders(this._connection.getHeaderFields());
this.onloadend && this.onloadend();
this.onloadend();
} catch (ex) {
if (ex instanceof SocketTimeoutException && this.ontimeout) {
return this.ontimeout(ex)
@@ -244,7 +236,7 @@ export class XMLHttpRequest {
private setReadyState(state: ReadyState) {
this._readyState = state;
this.onreadystatechange && this.onreadystatechange();
this.onreadystatechange();
}
private readOutput(input: any) {

View File

@@ -1 +0,0 @@
../../.npmignore

View File

@@ -1,6 +1,6 @@
{
"name": "@ccms/plugin",
"version": "0.8.4",
"version": "0.6.4",
"description": "MiaoScript api package",
"keywords": [
"miaoscript",
@@ -19,16 +19,16 @@
"test": "echo \"Error: run tests from root\" && exit 1"
},
"devDependencies": {
"@types/js-yaml": "^3.12.5",
"@types/js-yaml": "^3.12.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"typescript": "^3.9.6"
"typescript": "^3.8.3"
},
"dependencies": {
"@ccms/api": "^0.8.4",
"@ccms/common": "^0.8.4",
"@ccms/container": "^0.8.4",
"@ccms/i18n": "^0.8.4",
"js-yaml": "^3.14.0"
"@ccms/api": "^0.6.4",
"@ccms/common": "^0.6.4",
"@ccms/container": "^0.6.0",
"@ccms/i18n": "^0.6.4",
"js-yaml": "^3.13.1"
}
}

View File

@@ -1,36 +0,0 @@
import { command, plugin, server } from '@ccms/api'
import { provideSingleton, postConstruct, inject } from '@ccms/container'
import { getPluginCommandMetadata, getPluginTabCompleterMetadata } from './utils'
@provideSingleton(PluginCommandManager)
export class PluginCommandManager {
@inject(server.ServerChecker)
private ServerChecker: server.ServerChecker
@inject(command.Command)
private CommandManager: command.Command
constructor() {
process.on('plugin.before.enable', (plugin: plugin.Plugin) => this.registryCommand(plugin))
process.on('plugin.after.disable', (plugin: plugin.Plugin) => this.unregistryCommand(plugin))
}
private registryCommand(pluginInstance: plugin.Plugin) {
let cmds = getPluginCommandMetadata(pluginInstance)
let tabs = getPluginTabCompleterMetadata(pluginInstance)
for (const [_, cmd] of cmds) {
let tab = tabs.get(cmd.name)
if (!this.ServerChecker.check(cmd.servers)) { continue }
this.CommandManager.on(pluginInstance, cmd.name, {
cmd: pluginInstance[cmd.executor].bind(pluginInstance),
tab: tab ? pluginInstance[tab.executor].bind(pluginInstance) : undefined
})
}
}
private unregistryCommand(pluginInstance: plugin.Plugin) {
let cmds = getPluginCommandMetadata(pluginInstance)
cmds.forEach(cmd => {
this.CommandManager.off(pluginInstance, cmd.name)
})
}
}

View File

@@ -1,75 +1,33 @@
import * as yaml from 'js-yaml'
import * as fs from '@ccms/common/dist/fs'
import { plugin } from '@ccms/api'
import { getPluginConfigMetadata } from './utils'
export interface PluginConfigLoader {
load(content: string): any
dump(variable: any): string
load(content: string): any;
dump(variable: any): string;
}
export class YamlPluginConfig implements PluginConfigLoader {
load(content: string) {
return yaml.safeLoad(content)
return yaml.safeLoad(content);
}
dump(variable: any): string {
return yaml.safeDump(variable, { skipInvalid: true })
return yaml.safeDump(variable);
}
}
export class JsonPluginConfig implements PluginConfigLoader {
load(content: string) {
return JSON.parse(content)
return JSON.parse(content);
}
dump(variable: any): string {
return JSON.stringify(variable)
return JSON.stringify(variable);
}
}
const configLoaderMap = new Map<string, PluginConfigLoader>()
const configLoaderMap = new Map<string, PluginConfigLoader>();
export function getConfigLoader(format: string) {
if (!configLoaderMap.has(format)) { throw new Error(`Unsupport config format ${format} !`) }
return configLoaderMap.get(format)
}
function loadConfig(plugin: plugin.Plugin) {
let configs = getPluginConfigMetadata(plugin)
for (let [_, config] of configs) {
try {
let configFile = fs.concat(fs.file(plugin.description.loadMetadata.file).parent, plugin.description.name, config.name + '.' + config.format)
let configFactory = getConfigLoader(config.format)
if (!fs.exists(configFile)) {
base.save(configFile, configFactory.dump(plugin[config.variable]))
console.i18n("ms.plugin.manager.config.save.default", { plugin: plugin.description.name, name: config.name, format: config.format })
} else {
plugin[config.variable] = configFactory.load(base.read(configFile))
plugin[config.variable].save = () => {
let result = configFactory.dump(plugin[config.variable])
base.save(configFile, result)
console.debug(`[${plugin.description.name}] Save Config ${config.variable} to file ${configFile} result ${result}`)
}
console.debug(`[${plugin.description.name}] Load Config ${config.variable} from file ${configFile} result ${JSON.stringify(plugin[config.variable])}`)
}
} catch (error) {
console.i18n("ms.plugin.manager.config.load.error", { plugin: plugin.description.name, name: config.name, format: config.format, error })
console.ex(error)
}
}
}
function saveConfig(plugin: plugin.Plugin) {
let configs = getPluginConfigMetadata(plugin)
for (let [_, config] of configs) {
try {
let configFile = fs.concat(fs.file(plugin.description.loadMetadata.file).parent, plugin.description.name, config.name + '.' + config.format)
let configFactory = getConfigLoader(config.format)
if (!config.readonly) { base.save(configFile, configFactory.dump(plugin[config.variable])) }
} catch (error) {
console.i18n("ms.plugin.manager.config.save.error", { plugin: plugin.description.name, name: config.name, format: config.format, error })
console.ex(error)
}
}
return configLoaderMap.get(format);
}
function init() {
@@ -77,8 +35,6 @@ function init() {
let yaml = new YamlPluginConfig()
configLoaderMap.set("yml", yaml)
configLoaderMap.set("yaml", yaml)
process.on('plugin.before.load', loadConfig)
process.on('plugin.after.load', saveConfig)
}
init()

View File

@@ -1,5 +1,4 @@
import { plugin as pluginApi } from "@ccms/api"
import { injectable, decorate } from "@ccms/container"
import { injectable, decorate } from "@ccms/container";
import { interfaces } from './interfaces'
import { METADATA_KEY } from './constants'
import { getPluginMetadatas, getPluginCommandMetadata, getPluginListenerMetadata, getPluginTabCompleterMetadata, getPluginConfigMetadata, getPluginStageMetadata, getPluginSources } from './utils'
@@ -8,19 +7,19 @@ import { getPluginMetadatas, getPluginCommandMetadata, getPluginListenerMetadata
* MiaoScript plugin
* @param metadata PluginMetadata
*/
export function plugin(metadata: pluginApi.PluginMetadata | any) {
export function plugin(metadata: interfaces.PluginMetadata) {
return function (target: any) {
if (!metadata.source) metadata = { souece: metadata }
metadata = { name: target.name, version: '1.0.0', author: 'Unknow', target, type: 'ioc', ...metadata }
decorate(injectable(), target)
Reflect.defineMetadata(METADATA_KEY.plugin, metadata, target)
const previousMetadata: Map<string, pluginApi.PluginMetadata> = getPluginMetadatas()
previousMetadata.set(metadata.name, metadata)
Reflect.defineMetadata(METADATA_KEY.plugin, previousMetadata, Reflect)
const previousSources: Map<string, pluginApi.PluginMetadata> = getPluginSources()
previousSources.set(metadata.source.toString(), metadata)
Reflect.defineMetadata(METADATA_KEY.souece, previousSources, Reflect)
}
metadata.target = target;
metadata.type = "ioc";
decorate(injectable(), target);
Reflect.defineMetadata(METADATA_KEY.plugin, metadata, target);
const previousMetadata: Map<string, interfaces.PluginMetadata> = getPluginMetadatas();
previousMetadata.set(metadata.name, metadata);
Reflect.defineMetadata(METADATA_KEY.plugin, previousMetadata, Reflect);
const previousSources: Map<string, interfaces.PluginMetadata> = getPluginSources();
previousSources.set(metadata.source.toString(), metadata);
Reflect.defineMetadata(METADATA_KEY.souece, previousSources, Reflect);
};
}
/**
@@ -29,13 +28,13 @@ export function plugin(metadata: pluginApi.PluginMetadata | any) {
*/
export function cmd(metadata: interfaces.CommandMetadata = {}) {
return function (target: any, key: string, value: any) {
metadata.name = metadata.name || key
metadata.executor = key
metadata.name = metadata.name || key;
metadata.executor = key;
metadata.paramtypes = Reflect.getMetadata("design:paramtypes", target, key)
const previousMetadata: Map<string, interfaces.CommandMetadata> = getPluginCommandMetadata(target)
previousMetadata.set(metadata.name, metadata)
Reflect.defineMetadata(METADATA_KEY.cmd, previousMetadata, target.constructor)
}
previousMetadata.set(metadata.name, metadata);
Reflect.defineMetadata(METADATA_KEY.cmd, previousMetadata, target.constructor);
};
}
/**
@@ -44,14 +43,14 @@ export function cmd(metadata: interfaces.CommandMetadata = {}) {
*/
export function tab(metadata: interfaces.CommandMetadata = {}) {
return function (target: any, key: string, value: any) {
metadata.name = metadata.name || (key.startsWith('tab') ? key.split('tab', 2)[1] : key)
if (!metadata.name) { return }
metadata.executor = key
metadata.name = metadata.name || (key.startsWith('tab') ? key.split('tab', 2)[1] : key);
if (!metadata.name) { return; }
metadata.executor = key;
metadata.paramtypes = Reflect.getMetadata("design:paramtypes", target, key)
const previousMetadata: Map<string, interfaces.CommandMetadata> = getPluginTabCompleterMetadata(target)
previousMetadata.set(metadata.name, metadata)
Reflect.defineMetadata(METADATA_KEY.tab, previousMetadata, target.constructor)
}
Reflect.defineMetadata(METADATA_KEY.tab, previousMetadata, target.constructor);
};
}
/**
@@ -60,35 +59,40 @@ export function tab(metadata: interfaces.CommandMetadata = {}) {
*/
export function listener(metadata: interfaces.ListenerMetadata = {}) {
return function (target: any, key: string, value: any) {
metadata.name = metadata.name || key
metadata.executor = key
metadata.name = metadata.name || key;
metadata.executor = key;
const previousMetadata: interfaces.ListenerMetadata[] = getPluginListenerMetadata(target)
Reflect.defineMetadata(METADATA_KEY.listener, [metadata, ...previousMetadata], target.constructor)
}
Reflect.defineMetadata(METADATA_KEY.listener, [metadata, ...previousMetadata], target.constructor);
};
}
export function config(metadata: interfaces.ConfigMetadata = {}) {
export function config(metadata: interfaces.ConfigMetadata = { version: 1, format: 'yml' }) {
return function (target: any, key: string) {
metadata.name = metadata.name || key
metadata.variable = key
metadata.version = metadata.version ?? 1
metadata.format = metadata.format ?? 'yml'
metadata.name = metadata.name || key;
metadata.variable = key;
const previousMetadata: Map<string, interfaces.ConfigMetadata> = getPluginConfigMetadata(target)
previousMetadata.set(metadata.name, metadata)
Reflect.defineMetadata(METADATA_KEY.config, previousMetadata, target.constructor)
previousMetadata.set(metadata.name, metadata);
Reflect.defineMetadata(METADATA_KEY.config, previousMetadata, target.constructor);
}
}
function stage(stage: string) {
return (metadata: interfaces.ExecMetadata = {}) => {
return function (target: any, key: string, value: any) {
metadata.name = metadata.name || key
metadata.executor = key
const previousMetadata: interfaces.ExecMetadata[] = getPluginStageMetadata(target, stage)
Reflect.defineMetadata(METADATA_KEY.stage[stage], [metadata, ...previousMetadata], target.constructor)
}
}
function stage(metadata: interfaces.ExecMetadata = {}, stage: string) {
return function (target: any, key: string, value: any) {
metadata.name = metadata.name || key;
metadata.executor = key;
const previousMetadata: interfaces.ExecMetadata[] = getPluginStageMetadata(target, stage)
Reflect.defineMetadata(METADATA_KEY.stage[stage], [metadata, ...previousMetadata], target.constructor);
};
}
export function load(metadata: interfaces.ExecMetadata = {}) {
return stage(metadata, 'load')
}
export function enable(metadata: interfaces.ExecMetadata = {}) {
return stage(metadata, 'enable')
}
export function disable(metadata: interfaces.ExecMetadata = {}) {
return stage(metadata, 'disable')
}
export const load = stage('load')
export const enable = stage('enable')
export const disable = stage('disable')

View File

@@ -1,30 +0,0 @@
import { event, plugin, server } from '@ccms/api'
import { provideSingleton, postConstruct, inject } from '@ccms/container'
import { getPluginListenerMetadata } from './utils'
@provideSingleton(PluginEventManager)
export class PluginEventManager {
@inject(server.ServerChecker)
private ServerChecker: server.ServerChecker
@inject(event.Event)
private EventManager: event.Event
constructor() {
process.on('plugin.before.enable', (plugin: plugin.Plugin) => this.registryListener(plugin))
process.on('plugin.after.disable', (plugin: plugin.Plugin) => this.unregistryListener(plugin))
}
private registryListener(pluginInstance: plugin.Plugin) {
let events = getPluginListenerMetadata(pluginInstance)
for (const event of events) {
// ignore space listener
if (!this.ServerChecker.check(event.servers)) { continue }
// here must bind this to pluginInstance
this.EventManager.listen(pluginInstance, event.name, pluginInstance[event.executor].bind(pluginInstance))
}
}
private unregistryListener(pluginInstance: plugin.Plugin) {
this.EventManager.disable(pluginInstance)
}
}

View File

@@ -1,15 +1,3 @@
import './scanner/file-scanner'
import './loader/ioc-loader'
import './loader/basic-loader'
export * from './manager'
export * from './decorators'
export * from './interfaces'
export {
plugin as JSPlugin,
cmd as Cmd,
tab as Tab,
listener as Listener,
config as Config
} from './decorators'

View File

@@ -1,14 +1,14 @@
import { server, MiaoScriptConsole, event, plugin } from "@ccms/api"
import { injectable, inject, postConstruct } from "@ccms/container"
import { getPluginMetadata } from "./utils"
import { server, MiaoScriptConsole, event } from "@ccms/api";
import { injectable, inject, postConstruct } from "@ccms/container";
import { getPluginMetadata } from "./utils";
export namespace interfaces {
@injectable()
export abstract class Plugin implements plugin.Plugin {
public description: plugin.PluginMetadata
public logger: Console
export abstract class Plugin {
public description: PluginMetadata;
public logger: Console;
@inject(server.Console)
private Console: MiaoScriptConsole
private Console: MiaoScriptConsole;
constructor() {
this.description = getPluginMetadata(this)
@@ -24,49 +24,82 @@ export namespace interfaces {
public enable() { }
public disable() { }
}
export interface ExecMetadata extends plugin.BaseMetadata {
interface BaseMetadata {
/**
* 名称 为空则为对象名称
*/
name?: string;
/**
* 支持的服务器列表 为空则代表所有
*/
servers?: string[];
}
export interface PluginMetadata extends BaseMetadata {
/**
* 插件名称
*/
name: string;
/**
* 前缀
*/
prefix?: string;
/**
* 插件版本
*/
version: string;
/**
* 插件版本
*/
author: string | string[];
/**
* 插件源文件 必须指定为 __filename
*/
source: string;
/**
* 插件类型 默认为 ioc 执行 MiaoScript 加载逻辑
*/
type?: string;
/**
* 插件本体
*/
target?: any;
}
export interface ExecMetadata extends BaseMetadata {
/**
* 执行器
*/
executor?: string
executor?: string;
}
export interface CommandMetadata extends ExecMetadata {
/**
* 命令描述
*/
description?: string
/**
* 参数列表
*/
paramtypes?: string[]
paramtypes?: string[];
}
export interface ListenerMetadata extends ExecMetadata {
/**
* 监听优先级
*/
priority?: event.EventPriority
priority?: event.EventPriority;
/**
* 是否忽略已取消的事件
*/
ignoreCancel?: boolean
ignoreCancel?: boolean;
}
export interface ConfigMetadata extends plugin.BaseMetadata {
export interface ConfigMetadata extends BaseMetadata {
/**
* 配置文件版本号
*/
version?: number
version?: number;
/**
* 实体变量名称
*/
variable?: string
variable?: string;
/**
* 配置文件格式 默认 yml
*/
format?: string
/**
* 是否为只读(关闭时将不会自动保存)
*/
readonly?: boolean
format?: string;
}
export type PluginLike = Plugin | string
export type PluginLike = Plugin | string;
}

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