This commit is contained in:
Freddie
2022-04-16 15:47:01 +08:00
parent e9e932e6e7
commit d44fb477dc
18 changed files with 279 additions and 193 deletions

View File

@@ -1,3 +1,8 @@
## v1.50a
- **API**: Extended `R.WebUIEvent` to allow the handler to respond with data.
- **WebUI**: `emit()` function now returns an axios promise, in which you can grab the response data.
## v1.40d
- **API**: Added `R.ExtraModuleHandler` to allow plugins to define extra modules.

View File

@@ -1,3 +1,3 @@
function emit(event, data) {
return axios.post(`/emit/${event}`, data);
return axios.post(`/emit/${event}`, data ?? {});
}

View File

@@ -18,8 +18,3 @@ npx ncc build .\dist\AsphyxiaCore.js -o .\build-env --external pug --external ts
# Packing
Write-Output "Packing exe"
npx pkg .\build-env -t "node12.16.1-win-x64,node12.16.1-win-x86" -o .\build\asphyxia-core --options no-warnings
# Packing zips
Compress-Archive -Path ".\build\asphyxia-core-win-x64.exe", ".\plugins" -DestinationPath ".\build\asphyxia-core-win-x64.zip" -Force
Compress-Archive -Path ".\build\asphyxia-core-win-x86.exe", ".\plugins" -DestinationPath ".\build\asphyxia-core-win-x86.zip" -Force
Compress-Archive -Path ".\build\asphyxia-core-linux-x64", ".\plugins" -DestinationPath ".\build\asphyxia-core-linux-x64.zip" -Force

2
docs

Submodule docs updated: 7dd2123c47...3a51c7e14e

220
package-lock.json generated
View File

@@ -276,9 +276,9 @@
}
},
"ansi-regex": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg=="
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz",
"integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g=="
},
"ansi-styles": {
"version": "4.2.1",
@@ -379,9 +379,9 @@
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
},
"async": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz",
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==",
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
"integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
"requires": {
"lodash": "^4.17.14"
}
@@ -638,9 +638,9 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"color-string": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.3.tgz",
"integrity": "sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw==",
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.0.tgz",
"integrity": "sha512-9Mrz2AQLefkH1UvASKj6v6hj/7eWgjnT/cVsR8CumieLoT+g900exWeNogqtweI8dxloXN9BDQTYro1oWu/5CQ==",
"requires": {
"color-name": "^1.0.0",
"simple-swizzle": "^0.2.2"
@@ -1335,9 +1335,9 @@
"integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4="
},
"glob": {
"version": "7.1.6",
"resolved": "https://registry.npm.taobao.org/glob/download/glob-7.1.6.tgz",
"integrity": "sha1-FB8zuBp8JJLhJVlDB0gMRmeSeKY=",
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
@@ -1373,18 +1373,6 @@
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz",
"integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw=="
},
"handlebars": {
"version": "4.7.7",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
"integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==",
"requires": {
"minimist": "^1.2.5",
"neo-async": "^2.6.0",
"source-map": "^0.6.1",
"uglify-js": "^3.1.4",
"wordwrap": "^1.0.0"
}
},
"har-schema": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
@@ -1427,11 +1415,6 @@
"resolved": "https://registry.npmjs.org/hashids/-/hashids-2.2.1.tgz",
"integrity": "sha512-+hQeKWwpSDiWFeu/3jKUvwboE4Z035gR6FnpscbHPOEEjCbgv2px9/Mlb3O0nOTRyZOw4MMFRYfVL3zctOV6OQ=="
},
"highlight.js": {
"version": "10.4.1",
"resolved": "https://registry.npm.taobao.org/highlight.js/download/highlight.js-10.4.1.tgz",
"integrity": "sha1-1I+89KmXHENhs/lfMCdHr+GdutA="
},
"http-errors": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
@@ -1496,11 +1479,6 @@
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="
},
"interpret": {
"version": "1.4.0",
"resolved": "https://registry.npm.taobao.org/interpret/download/interpret-1.4.0.tgz",
"integrity": "sha1-Zlq4vE2iendKQFhOgS4+D6RbGh4="
},
"into-stream": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/into-stream/-/into-stream-5.1.1.tgz",
@@ -1672,9 +1650,9 @@
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM="
},
"json-schema": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM="
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz",
"integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA=="
},
"json-schema-traverse": {
"version": "0.4.1",
@@ -1686,6 +1664,11 @@
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
},
"jsonc-parser": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.0.0.tgz",
"integrity": "sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA=="
},
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
@@ -1695,13 +1678,13 @@
}
},
"jsprim": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
"integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz",
"integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==",
"requires": {
"assert-plus": "1.0.0",
"extsprintf": "1.3.0",
"json-schema": "0.2.3",
"json-schema": "0.4.0",
"verror": "1.10.0"
}
},
@@ -1783,8 +1766,8 @@
},
"lunr": {
"version": "2.3.9",
"resolved": "https://registry.npm.taobao.org/lunr/download/lunr-2.3.9.tgz",
"integrity": "sha1-GLEjFCgyM33W6WTfGlp3B7JdNeE="
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz",
"integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow=="
},
"make-error": {
"version": "1.3.6",
@@ -1792,9 +1775,9 @@
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw=="
},
"marked": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/marked/download/marked-1.0.0.tgz?cache=0&sync_timestamp=1605794918833&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmarked%2Fdownload%2Fmarked-1.0.0.tgz",
"integrity": "sha1-01eEJFoEhx5ZiKSR4ohnNi6UFpM="
"version": "4.0.14",
"resolved": "https://registry.npmjs.org/marked/-/marked-4.0.14.tgz",
"integrity": "sha512-HL5sSPE/LP6U9qKgngIIPTthuxC0jrfxpYMZ3LdGDD3vTnLs59m2Z7r6+LNDR3ToqEQdkKd6YaaEfJhodJmijQ=="
},
"media-typer": {
"version": "0.3.0",
@@ -1876,9 +1859,9 @@
}
},
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
},
"mkdirp": {
"version": "0.5.5",
@@ -1964,11 +1947,6 @@
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
},
"neo-async": {
"version": "2.6.2",
"resolved": "https://registry.npm.taobao.org/neo-async/download/neo-async-2.6.2.tgz",
"integrity": "sha1-tKr7k+OustgXTKU88WOrfXMIMF8="
},
"node-abi": {
"version": "2.26.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.26.0.tgz",
@@ -2110,9 +2088,9 @@
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
},
"path-parse": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw=="
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
"integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="
},
"path-to-regexp": {
"version": "0.1.7",
@@ -2462,14 +2440,6 @@
"util-deprecate": "^1.0.1"
}
},
"rechoir": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
"requires": {
"resolve": "^1.1.6"
}
},
"regenerator-runtime": {
"version": "0.13.7",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz",
@@ -2611,14 +2581,14 @@
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
},
"shelljs": {
"version": "0.8.4",
"resolved": "https://registry.npm.taobao.org/shelljs/download/shelljs-0.8.4.tgz",
"integrity": "sha1-3naE/ut2f4cWsyYHiooAh1iQ48I=",
"shiki": {
"version": "0.10.1",
"resolved": "https://registry.npmjs.org/shiki/-/shiki-0.10.1.tgz",
"integrity": "sha512-VsY7QJVzU51j5o1+DguUd+6vmCmZ5v/6gYu4vyYAhzjuNQU6P/vmSy4uQaOhvje031qQMiW0d2BwgMH52vqMng==",
"requires": {
"glob": "^7.0.0",
"interpret": "^1.0.0",
"rechoir": "^0.6.2"
"jsonc-parser": "^3.0.0",
"vscode-oniguruma": "^1.6.1",
"vscode-textmate": "5.2.0"
}
},
"showdown": {
@@ -2640,9 +2610,9 @@
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q=="
},
"simple-get": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz",
"integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz",
"integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==",
"requires": {
"decompress-response": "^4.2.0",
"once": "^1.3.1",
@@ -2914,28 +2884,33 @@
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
},
"typedoc": {
"version": "0.17.8",
"resolved": "https://registry.npm.taobao.org/typedoc/download/typedoc-0.17.8.tgz",
"integrity": "sha1-lrZ+lFSqeFO/xNyaVciget/VR44=",
"version": "0.22.15",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.15.tgz",
"integrity": "sha512-CMd1lrqQbFvbx6S9G6fL4HKp3GoIuhujJReWqlIvSb2T26vGai+8Os3Mde7Pn832pXYemd9BMuuYWhFpL5st0Q==",
"requires": {
"fs-extra": "^8.1.0",
"handlebars": "^4.7.6",
"highlight.js": "^10.0.0",
"lodash": "^4.17.15",
"lunr": "^2.3.8",
"marked": "1.0.0",
"minimatch": "^3.0.0",
"progress": "^2.0.3",
"shelljs": "^0.8.4",
"typedoc-default-themes": "^0.10.2"
}
},
"typedoc-default-themes": {
"version": "0.10.2",
"resolved": "https://registry.npm.taobao.org/typedoc-default-themes/download/typedoc-default-themes-0.10.2.tgz",
"integrity": "sha1-dDOAqAr+YsXvksob1KvirFlr5NI=",
"requires": {
"lunr": "^2.3.8"
"glob": "^7.2.0",
"lunr": "^2.3.9",
"marked": "^4.0.12",
"minimatch": "^5.0.1",
"shiki": "^0.10.1"
},
"dependencies": {
"brace-expansion": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
"requires": {
"balanced-match": "^1.0.0"
}
},
"minimatch": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz",
"integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==",
"requires": {
"brace-expansion": "^2.0.1"
}
}
}
},
"typescript": {
@@ -2943,12 +2918,6 @@
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.3.tgz",
"integrity": "sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw=="
},
"uglify-js": {
"version": "3.13.9",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.9.tgz",
"integrity": "sha512-wZbyTQ1w6Y7fHdt8sJnHfSIuWeDgk6B5rCb4E/AM6QNNPbOMIZph21PW5dRB3h7Df0GszN+t7RuUH6sWK5bF0g==",
"optional": true
},
"uid-safe": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz",
@@ -3025,6 +2994,16 @@
"resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz",
"integrity": "sha1-YU9/v42AHwu18GYfWy9XhXUOTwk="
},
"vscode-oniguruma": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.6.2.tgz",
"integrity": "sha512-KH8+KKov5eS/9WhofZR8M8dMHWN2gTxjMsG4jd04YhpbPR91fUj7rYQ2/XjeHCJWbg7X++ApRIU9NUwM2vTvLA=="
},
"vscode-textmate": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-5.2.0.tgz",
"integrity": "sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ=="
},
"which-module": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
@@ -3036,35 +3015,11 @@
"integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs="
},
"wide-align": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz",
"integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==",
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz",
"integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==",
"requires": {
"string-width": "^1.0.2 || 2"
},
"dependencies": {
"ansi-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg="
},
"string-width": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
"integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
"requires": {
"is-fullwidth-code-point": "^2.0.0",
"strip-ansi": "^4.0.0"
}
},
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
"requires": {
"ansi-regex": "^3.0.0"
}
}
"string-width": "^1.0.2 || 2 || 3 || 4"
}
},
"winston": {
@@ -3146,11 +3101,6 @@
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ=="
},
"wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
"integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus="
},
"wrap-ansi": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz",

View File

@@ -46,7 +46,7 @@
"showdown": "^1.9.1",
"sizeof": "^1.0.0",
"ts-node": "^9.1.1",
"typedoc": "^0.17.8",
"typedoc": "^0.22.15",
"typescript": "^4.2.3",
"winston": "^3.2.1"
}

View File

@@ -243,6 +243,61 @@ declare interface EamuseSend {
*/
declare type EamusePluginRoute = (req: EamuseInfo, data: any, send: EamuseSend) => Promise<any>;
declare interface WebUISend {
/**
* Respond with json data
*
* @param data Plain JavaScript object
*/
json: (data: any) => void;
/**
* Respond with string
*
* @param data String
*/
text: (data: string) => void;
/**
* Respond with file
*
* @param path Relative file path to this plugin's directory
*/
file: (path: string) => void;
/**
* Respond with binary data
*
* @param buffer Binary data
*/
buffer: (buffer: Buffer) => void;
/**
* Respond with redirect calls
* This is useful for progressing your WebUI to the next page when using form.
*
* @param url Target url
*/
redirect: (url: string) => void;
/**
* Respond with error
*
* @param code HTTP Code. Like 404, for example
* @param message String message
*/
error: (code: number, message: string) => void;
}
/**
* Helper type for typing your WebUIEvent.
*
* If you don't need to send anything. You can ignore send parameter.
* By default, if the handler don't send anything manually, it will send a
* redirect response to refresh the page when using form.
*/
declare type WebUIEventHandler = (data: any, send?: WebUISend) => Promise<void>;
/**
* Helper type for typing your custom route.
*
@@ -327,7 +382,7 @@ declare namespace R {
*
* Callback can be async function if you want to use await for your DB operations.
*/
function WebUIEvent(event: string, callback: (data: any) => void | Promise<void>): void;
function WebUIEvent(event: string, callback: WebUIEventHandler): void;
/**
* Register a handler for adding extra modules

View File

@@ -5,6 +5,7 @@ import { writeFileSync, readFileSync, write } from 'fs';
import { ReadConfig, SaveConfig, ARGS } from './utils/ArgConfig';
import { renderFile as pugFile } from 'pug';
import { KDataReader } from './utils/KDataReader';
import { IFS } from './utils/IFSTools';
// const data = readFileSync('response.bin');
// const decode = kdecode(data);
@@ -48,5 +49,7 @@ import { KDataReader } from './utils/KDataReader';
// const data = xmlToData(pugFile('build\\plugins\\sdvx\\template\\common4.pug'));
// console.log(data);
const data =
'{"collection":"mix","id":2,"code":"202974059619","name":"VVVV RANDOM MIX No.1","creator":"VVVV","param":"{ "dbVer" : "20191217", "gene" : { "params" : "{ \\"minorVer\\" : \\"20190729\\", \\"seed\\" : 847044788 }", "ver" : "20180222" }, "musics" : [ { "grade" : 3, "id" : 24 }, { "grade" : 3, "id" : 252 }, { "grade" : 2, "id" : 606 } ], "voxdj" : { "params" : "", "ver" : "20180222" } }","tag":1,"jacket":0,"_id":"keYijDT6zXc9sLgU","createdAt":"2020-05-31T00:07:38.734Z","updatedAt":"2020-05-31T00:07:38.734Z","__s":"plugins_profile","__a":"sdvx@asphyxia","__refid":"A59A6D7499842E3B"}';
// const data =
// '{"collection":"mix","id":2,"code":"202974059619","name":"VVVV RANDOM MIX No.1","creator":"VVVV","param":"{ "dbVer" : "20191217", "gene" : { "params" : "{ \\"minorVer\\" : \\"20190729\\", \\"seed\\" : 847044788 }", "ver" : "20180222" }, "musics" : [ { "grade" : 3, "id" : 24 }, { "grade" : 3, "id" : 252 }, { "grade" : 2, "id" : 606 } ], "voxdj" : { "params" : "", "ver" : "20180222" } }","tag":1,"jacket":0,"_id":"keYijDT6zXc9sLgU","createdAt":"2020-05-31T00:07:38.734Z","updatedAt":"2020-05-31T00:07:38.734Z","__s":"plugins_profile","__a":"sdvx@asphyxia","__refid":"A59A6D7499842E3B"}';
// const ifs = new IFS('')

View File

@@ -20,7 +20,7 @@ async function CheckProfile(gameCode: string, refid: string) {
if (!plugin) {
return false;
}
const profile = await APIFindOne({ name: plugin.Identifier, core: true }, refid, {});
const profile = await APIFindOne({ identifier: plugin.Identifier, core: true }, refid, {});
if (profile != null) {
return true;
}

View File

@@ -90,6 +90,16 @@ async function sanitization(gameCode: string, data: any, refMap: any = {}) {
return data;
}
export type WebUISend = {
json: (data: any) => void;
text: (data: string) => void;
file: (path: string) => void;
buffer: (buffer: Buffer) => void;
redirect: (url: string) => void;
error: (code: number, message: string) => void;
};
export type WebUIEventHandler = (data: any, send: WebUISend) => Promise<void>;
export class EamusePlugin {
private pluginName: string;
private pluginIdentifier: string;
@@ -106,7 +116,7 @@ export class EamusePlugin {
private uiPages: string[];
private uiProfiles: string[];
private uiEvents: {
[event: string]: (data: any) => void | Promise<void>;
[event: string]: WebUIEventHandler;
};
private uiCache: {
[file: string]: {
@@ -225,13 +235,13 @@ export class EamusePlugin {
this.routes[method] = route;
}
public RegisterWebUIEvent(event: string, callback: (data: any) => void | Promise<void>) {
public RegisterWebUIEvent(event: string, callback: WebUIEventHandler) {
this.uiEvents[event] = callback;
}
public async CallEvent(event: string, data: any) {
public async CallEvent(event: string, data: any, send: WebUISend) {
if (this.uiEvents[event]) {
await this.uiEvents[event](data);
return await this.uiEvents[event](data, send);
} else {
Logger.warn(`event "${event}" does not exists`, { plugin: this.pluginIdentifier });
}
@@ -266,10 +276,10 @@ export class EamusePlugin {
const DB = {
FindOne: (arg1: any, arg2?: any) => {
return APIFindOne({ name: this.pluginIdentifier, core: false }, arg1, arg2);
return APIFindOne({ identifier: this.pluginIdentifier, core: false }, arg1, arg2);
},
Find: (arg1: any, arg2?: any) => {
return APIFind({ name: this.pluginIdentifier, core: false }, arg1, arg2);
return APIFind({ identifier: this.pluginIdentifier, core: false }, arg1, arg2);
},
};
const U = {

View File

@@ -40,7 +40,7 @@ import {
FILE_OPTIONS,
PluginRegisterFile,
} from '../utils/ArgConfig';
import { EamusePlugin } from './EamusePlugin';
import { EamusePlugin, WebUIEventHandler } from './EamusePlugin';
import { EamuseRouteHandler } from './EamuseRouteContainer';
import xml2json from 'fast-xml-parser';
import _ from 'lodash';
@@ -80,7 +80,7 @@ const WrapCall = (methodName: string, func: any, def: any) => {
Logger.error(`${methodName} unexpected error`);
return def;
}
return func({ name: plugin, core: false }, ...args);
return func({ identifier: plugin, core: false }, ...args);
};
};
@@ -89,7 +89,7 @@ const Pro = (res: any) => {
};
export type PluginDetect = {
name: string;
identifier: string;
core: boolean;
};
@@ -221,7 +221,7 @@ export function LoadExternalPlugins() {
$.R.Contributor = (name: string, link?: string) => {
plugin.RegisterContributor(name, link);
};
$.R.WebUIEvent = (event: string, callback: (data: any) => void | Promise<void>) => {
$.R.WebUIEvent = (event: string, callback: WebUIEventHandler) => {
plugin.RegisterWebUIEvent(event, callback);
};
$.R.Config = (key: string, options: CONFIG_OPTIONS) => {

View File

@@ -1,4 +1,4 @@
export const VERSION = 'v1.40d';
export const VERSION = 'v1.50a';
export const NAMES = [
'Akehiro',
'Akihiro',

View File

@@ -85,7 +85,7 @@ const LoadDatabase = async (file: string) => {
let CoreDB: nedb = null;
export const LoadCoreDB = async () => {
CoreDB = await LoadDatabase(COREDB_FILE);
if (!CoreDB) {
process.exit(1);
}
@@ -135,11 +135,11 @@ export function ReadAssets(file: string): any {
// Public IO
// =========================================
export function Resolve(plugin: PluginDetect, file: string) {
return path.resolve(PLUGIN_PATH, plugin.name, file);
return path.resolve(PLUGIN_PATH, plugin.identifier, file);
}
export async function ReadDir(plugin: PluginDetect, file: string) {
const target = path.resolve(PLUGIN_PATH, plugin.name, file);
const target = path.resolve(PLUGIN_PATH, plugin.identifier, file);
return new Promise<{ name: string; type: 'file' | 'dir' | 'unsupported' }[]>(resolve => {
readdir(target, { encoding: 'utf8', withFileTypes: true }, (err, files) => {
@@ -158,7 +158,7 @@ export async function ReadDir(plugin: PluginDetect, file: string) {
}
export function Exists(plugin: PluginDetect, file: string) {
const target = path.resolve(PLUGIN_PATH, plugin.name, file);
const target = path.resolve(PLUGIN_PATH, plugin.identifier, file);
return existsSync(target);
}
@@ -168,7 +168,7 @@ export async function WriteFile(
data: string | Buffer,
options: { encoding?: string | null; mode?: number | string; flag?: string } | string | null
) {
const target = path.resolve(PLUGIN_PATH, plugin.name, file);
const target = path.resolve(PLUGIN_PATH, plugin.identifier, file);
PrepareDirectory(path.dirname(target));
@@ -192,7 +192,7 @@ export async function WriteFile(
}
export async function DeleteFile(plugin: PluginDetect, file: string) {
const target = path.resolve(PLUGIN_PATH, plugin.name, file);
const target = path.resolve(PLUGIN_PATH, plugin.identifier, file);
return new Promise<void>(resolve => {
unlink(target, err => {
@@ -209,7 +209,7 @@ export async function ReadFile(
file: string,
options: { encoding?: string | null; flag?: string } | string | undefined | null
) {
const target = path.resolve(PLUGIN_PATH, plugin.name, file);
const target = path.resolve(PLUGIN_PATH, plugin.identifier, file);
return new Promise<string | Buffer>(resolve => {
if (options == null) {
@@ -546,7 +546,7 @@ export async function APIFindOne(plugin: PluginDetect, arg1: string | any, arg2?
throw new Error('invalid FindOne query');
}
const DB = await GET_DB(plugin.name);
const DB = await GET_DB(plugin.identifier);
if (!DB) throw new Error(`database failed to load`);
const result = await DB.findOne(query, {});
@@ -578,7 +578,7 @@ export async function APIFind(plugin: PluginDetect, arg1: string | any, arg2?: a
throw new Error('invalid Find query');
}
const DB = await GET_DB(plugin.name);
const DB = await GET_DB(plugin.identifier);
if (!DB) throw new Error(`database failed to load`);
const result = await DB.find<any>(query, {}).sort({ createdAt: 1 }).exec();
@@ -592,7 +592,9 @@ export async function APIInsert(plugin: PluginDetect, arg1: string | any, arg2?:
if (!plugin.core) {
const profile = await FindProfile(arg1);
if (profile == null) {
Logger.warn('refid does not exists, insert operation canceled', { plugin: plugin.name });
Logger.warn('refid does not exists, insert operation canceled', {
plugin: plugin.identifier,
});
return null;
}
}
@@ -613,7 +615,7 @@ export async function APIInsert(plugin: PluginDetect, arg1: string | any, arg2?:
throw new Error('invalid Insert query');
}
const DB = await GET_DB(plugin.name);
const DB = await GET_DB(plugin.identifier);
if (!DB) throw new Error(`database failed to load`);
const result = await DB.insert<any>(doc);
@@ -656,7 +658,7 @@ export async function APIUpdate(plugin: PluginDetect, arg1: string | any, arg2:
};
}
const DB = await GET_DB(plugin.name);
const DB = await GET_DB(plugin.identifier);
if (!DB) throw new Error(`database failed to load`);
const docs = await DB.update<any>(query, update, {
@@ -683,7 +685,9 @@ export async function APIUpsert(plugin: PluginDetect, arg1: string | any, arg2:
if (!plugin.core) {
const profile = await FindProfile(arg1);
if (profile == null) {
Logger.warn('refid does not exists, upsert operation canceled', { plugin: plugin.name });
Logger.warn('refid does not exists, upsert operation canceled', {
plugin: plugin.identifier,
});
return { updated: 0, docs: [], upsert: false };
}
}
@@ -712,7 +716,7 @@ export async function APIUpsert(plugin: PluginDetect, arg1: string | any, arg2:
};
}
const DB = await GET_DB(plugin.name);
const DB = await GET_DB(plugin.identifier);
if (!DB) throw new Error(`database failed to load`);
const docs = await DB.update<any>(query, update, {
@@ -755,7 +759,7 @@ export async function APIRemove(plugin: PluginDetect, arg1: string | any, arg2?:
throw new Error('invalid Remove query');
}
const DB = await GET_DB(plugin.name);
const DB = await GET_DB(plugin.identifier);
if (!DB) throw new Error(`database failed to load`);
return await DB.remove(query, { multi: true });
@@ -786,7 +790,7 @@ export async function APICount(plugin: PluginDetect, arg1: string | any, arg2?:
throw new Error('invalid Count query');
}
const DB = await GET_DB(plugin.name);
const DB = await GET_DB(plugin.identifier);
if (!DB) throw new Error(`database failed to load`);
return await DB.count(query);

29
src/utils/IFSTools.ts Normal file
View File

@@ -0,0 +1,29 @@
import * as fs from 'fs';
export class IFS {
private path: string;
private stream: fs.ReadStream;
constructor(path: string) {
this.path = path;
}
public async open() {
this.stream = fs.createReadStream(this.path);
return new Promise<void>((resolve, reject) => {
this.stream.on('open', () => {
const header = this.stream.read(36);
resolve();
});
this.stream.on('error', err => {
reject(err);
});
});
}
public async close() {
this.stream.close();
this.stream = null;
}
}

View File

@@ -3,8 +3,9 @@ import { urlencoded, json } from 'body-parser';
import { ROOT_CONTAINER } from '../eamuse/index';
import { Logger } from '../utils/Logger';
import multer from 'multer';
import { WriteFile, DeleteFile } from '../utils/EamuseIO';
import { WriteFile, DeleteFile, Resolve } from '../utils/EamuseIO';
import { DATAFILE_MAP } from '../utils/ArgConfig';
import { WebUISend } from '../eamuse/EamusePlugin';
export const ajax = Router();
@@ -32,16 +33,50 @@ ajax.post(
const event = req.params.event;
let sent = false;
const send: WebUISend = {
json: (data: any) => {
res.json(data);
sent = true;
},
text: (data: string) => {
if (typeof data !== 'string') {
throw new Error('text() must be called with a string');
}
res.send(data);
sent = true;
},
file: (path: string) => {
res.sendFile(Resolve({ identifier: plugin.Identifier, core: false }, path));
sent = true;
},
buffer: (buffer: Buffer) => {
res.send(buffer);
sent = true;
},
redirect: (url: string) => {
res.redirect(url);
sent = true;
},
error: (code: number, message: string) => {
res.status(code).send(message);
sent = true;
},
};
try {
await plugin.CallEvent(event, req.body);
await plugin.CallEvent(event, req.body, send);
if (!sent) {
res.redirect(req.headers.referer);
return;
}
} catch (err) {
Logger.error(`WebUIEvent Error: ${event}`);
Logger.error(err, { plugin: plugin.Identifier });
res.status(500).send(err);
return;
}
res.redirect(req.headers.referer);
}
);
@@ -68,7 +103,9 @@ ajax.post('/upload/:path', upload.single('upload'), async (req, res) => {
const path = req.params.path;
if (DATAFILE_MAP[plugin.Identifier] && DATAFILE_MAP[plugin.Identifier].has(path)) {
WriteFile({ name: plugin.Identifier, core: true }, path, req.file.buffer, { encoding: null });
WriteFile({ identifier: plugin.Identifier, core: true }, path, req.file.buffer, {
encoding: null,
});
res.sendStatus(200);
} else {
@@ -97,7 +134,7 @@ ajax.delete('/upload/:path', upload.single('upload'), async (req, res) => {
const path = req.params.path;
if (DATAFILE_MAP[plugin.Identifier] && DATAFILE_MAP[plugin.Identifier].has(path)) {
try {
await DeleteFile({ name: plugin.Identifier, core: true }, path);
await DeleteFile({ identifier: plugin.Identifier, core: true }, path);
res.sendStatus(200);
} catch {
res.sendStatus(500);

View File

@@ -350,25 +350,25 @@ webui.post(
try {
switch (command) {
case 'FindOne':
res.json(await (APIFindOne as any)({ name: plugin, core: false }, ...args));
res.json(await (APIFindOne as any)({ idendifier: plugin, core: false }, ...args));
break;
case 'Find':
res.json(await (APIFind as any)({ name: plugin, core: false }, ...args));
res.json(await (APIFind as any)({ idendifier: plugin, core: false }, ...args));
break;
case 'Insert':
res.json(await (APIInsert as any)({ name: plugin, core: false }, ...args));
res.json(await (APIInsert as any)({ idendifier: plugin, core: false }, ...args));
break;
case 'Remove':
res.json(await (APIRemove as any)({ name: plugin, core: false }, ...args));
res.json(await (APIRemove as any)({ idendifier: plugin, core: false }, ...args));
break;
case 'Update':
res.json(await (APIUpdate as any)({ name: plugin, core: false }, ...args));
res.json(await (APIUpdate as any)({ idendifier: plugin, core: false }, ...args));
break;
case 'Upsert':
res.json(await (APIUpsert as any)({ name: plugin, core: false }, ...args));
res.json(await (APIUpsert as any)({ idendifier: plugin, core: false }, ...args));
break;
case 'Count':
res.json(await (APICount as any)({ name: plugin, core: false }, ...args));
res.json(await (APICount as any)({ idendifier: plugin, core: false }, ...args));
break;
}
} catch (err) {
@@ -466,7 +466,7 @@ webui.delete(
return res.sendStatus(400);
}
if (await APIRemove({ name: plugin.Identifier, core: true }, refid, {})) {
if (await APIRemove({ identifier: plugin.Identifier, core: true }, refid, {})) {
return res.sendStatus(200);
} else {
return res.sendStatus(404);
@@ -511,7 +511,7 @@ webui.get(
}
const profiles = groupBy(
await APIFind({ name: plugin.Identifier, core: true }, null, {}),
await APIFind({ identifier: plugin.Identifier, core: true }, null, {}),
'__refid'
);

View File

@@ -1,8 +1,6 @@
{
"includeDeclarations": true,
"excludeExternals": true,
"externalPattern": ["!./plugins/asphyxia-core.d.ts"],
"mode": "file",
"entryPoints": ["./plugins/asphyxia-core.d.ts"],
"readme": "none",
"name": "Asphyxia CORE Module API",
"out": "./docs/typedoc",