mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: typescript language features
This commit is contained in:
1 parent
a44055d54a
commit
0bd1b5fdbd
8 files changed
+196
-109
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.24.17",
|
||||
"version": "2.24.18",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -482,6 +482,10 @@ export class Handler extends HandlerCommon {
|
||||
}
|
||||
|
||||
async init({ domainId }) {
|
||||
if (this.request.headers.referer) {
|
||||
const hostname = new URL(this.request.headers.referer).hostname;
|
||||
if (hostname !== this.request.hostname) throw new CsrfTokenError();
|
||||
}
|
||||
if (!argv.benchmark) await this.limitRate('global', 10, 88);
|
||||
const [absoluteDomain, inferDomain, bdoc] = await Promise.all([
|
||||
domain.get(domainId),
|
||||
|
||||
@@ -173,10 +173,7 @@ export default function (env = {}) {
|
||||
customInterpolateName: (url) => beautifyOutputUrl(url),
|
||||
},
|
||||
}),
|
||||
new MonacoWebpackPlugin({
|
||||
// available options are documented at https://github.com/Microsoft/monaco-editor-webpack-plugin#options
|
||||
languages: ['markdown', 'yaml', 'cpp', 'csharp', 'java', 'javascript', 'python', 'rust', 'ruby', 'php', 'pascal', 'go', 'julia'],
|
||||
}),
|
||||
new MonacoWebpackPlugin({}),
|
||||
new StaticManifestPlugin({
|
||||
fileName: 'static-manifest.json',
|
||||
ignore: [
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
.ScratchpadMonacoEditor
|
||||
flex: 1
|
||||
position: relative
|
||||
overflow: hidden
|
||||
|
||||
.cm-s-vjcm
|
||||
position: absolute
|
||||
|
||||
@@ -19,6 +19,22 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
},
|
||||
});
|
||||
|
||||
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
||||
noSemanticValidation: false,
|
||||
noSyntaxValidation: false,
|
||||
});
|
||||
monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
||||
target: monaco.languages.typescript.ScriptTarget.ES6,
|
||||
allowNonTsExtensions: true,
|
||||
});
|
||||
const libSource = [
|
||||
'declare function readline(): string;',
|
||||
'declare function print(content: string): void',
|
||||
].join('\n');
|
||||
const libUri = 'ts:filename/basic.d.ts';
|
||||
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
|
||||
monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(class MonacoEditor extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const value = this.props.value || '';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.7.3",
|
||||
"version": "4.7.4",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
Reference in new issue
Block a user