diff --git a/.gitignore b/.gitignore index c42fe09..ae55c85 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,6 @@ classes/ # vscode .settings/ -.vscode/ bin/ .classpath .project diff --git a/README.md b/README.md index fffafed..b7e9f4f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # ScriptCraft JS API for Minecraft +## API +[View TypeDoc](https://jenkins.thebrokenrail.com/job/ScriptCraft/job/master/TypeDoc/) + ## Changelog [View Changelog](CHANGELOG.md) diff --git a/src/main/js/src/types/scriptcraft/index.d.ts b/src/main/js/src/types/scriptcraft/index.d.ts deleted file mode 100644 index f5a84d5..0000000 --- a/src/main/js/src/types/scriptcraft/index.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -interface JavaObject { - discriminator: 'JavaObject'; -} - -type BridgeValueType = void | string | number | boolean | JavaObject | BridgeValueType[]; -type BridgeType = (...args: BridgeValueType[]) => BridgeValueType; - -interface ScriptCraft { - useBridge(name: string, ...args: BridgeValueType[]): BridgeValueType; - - bridges: { [key: string]: BridgeType }; -} - -declare const __scriptcraft__: ScriptCraft; - -interface Console { - log(...args: string[]): void; - info(...args: string[]): void; - warn(...args: string[]): void; - error(...args: string[]): void; - dir(...args: string[]): void; - debug(...args: string[]): void; - trace(...args: string[]): void; - - assert(condition: boolean, ...args: string[]): void; -} - -declare const console: Console; - -declare module 'scriptcraft-core' { - function addBridge(name: string, bridge: BridgeType): void; - - function useBridge(name: string, ...args: BridgeValueType[]): BridgeValueType; -} diff --git a/src/main/js/.eslintrc.json b/src/main/ts/.eslintrc.json similarity index 64% rename from src/main/js/.eslintrc.json rename to src/main/ts/.eslintrc.json index da8979c..33812fa 100644 --- a/src/main/js/.eslintrc.json +++ b/src/main/ts/.eslintrc.json @@ -16,28 +16,42 @@ "plugin:@typescript-eslint/recommended-requiring-type-checking" ], "rules": { + "no-extra-parens": "off", "@typescript-eslint/no-extra-parens": "error", + "semi": "off", "@typescript-eslint/semi": "error", "curly": "error", + "indent": "off", "@typescript-eslint/indent": ["error", 4], "arrow-parens": ["error", "as-needed"], "@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-empty-function": "off", "@typescript-eslint/no-use-before-define": "off", - "quotes": ["error", "single"], + "quotes": "off", + "@typescript-eslint/quotes": ["error", "single"], "eol-last": ["error", "always"], "no-eq-null": "error", "no-unneeded-ternary": "error", "block-spacing": "error", - "camelcase": "error", + "camelcase": "off", + "@typescript-eslint/camelcase": "error", "comma-dangle": ["error", "never"], - "func-call-spacing": ["error", "never"], + "func-call-spacing": "off", + "@typescript-eslint/func-call-spacing": ["error", "never"], "function-call-argument-newline": ["error", "never"], "implicit-arrow-linebreak": ["error", "beside"], "linebreak-style": ["error", "unix"], "no-trailing-spaces": "error", "no-lonely-if": "error", "no-var": "error", - "prefer-arrow-callback": "error" + "prefer-arrow-callback": "error", + "@typescript-eslint/no-explicit-any": "error", + "@typescript-eslint/prefer-readonly": "error", + "brace-style": "off", + "@typescript-eslint/brace-style": "error", + "dot-notation": "off", + "@typescript-eslint/dot-notation": "error", + "no-extra-semi": "off", + "@typescript-eslint/no-extra-semi": "error" } } \ No newline at end of file diff --git a/src/main/js/.gitignore b/src/main/ts/.gitignore similarity index 100% rename from src/main/js/.gitignore rename to src/main/ts/.gitignore diff --git a/src/main/ts/.vscode/extensions.json b/src/main/ts/.vscode/extensions.json new file mode 100644 index 0000000..897af65 --- /dev/null +++ b/src/main/ts/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "dbaeumer.vscode-eslint" + ] +} \ No newline at end of file diff --git a/src/main/ts/.vscode/settings.json b/src/main/ts/.vscode/settings.json new file mode 100644 index 0000000..12914a8 --- /dev/null +++ b/src/main/ts/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "[typescript]": { + "editor.defaultFormatter": "dbaeumer.vscode-eslint" + }, + "files.autoSave": "afterDelay", + "typescript.updateImportsOnFileMove.enabled": "always", + "eslint.format.enable": true, + "editor.insertSpaces": true, + "editor.detectIndentation": false, + "editor.tabSize": 4 +} \ No newline at end of file diff --git a/src/main/js/package.json b/src/main/ts/package.json similarity index 100% rename from src/main/js/package.json rename to src/main/ts/package.json diff --git a/src/main/js/src/minecraft/block.ts b/src/main/ts/src/minecraft/block.ts similarity index 99% rename from src/main/js/src/minecraft/block.ts rename to src/main/ts/src/minecraft/block.ts index c3d1e47..e403ba3 100644 --- a/src/main/js/src/minecraft/block.ts +++ b/src/main/ts/src/minecraft/block.ts @@ -73,7 +73,7 @@ export class CustomBlock { /** * @internal */ - settings: BlockSettings; + readonly settings: BlockSettings; constructor(settings: BlockSettings) { this.settings = settings; diff --git a/src/main/js/src/minecraft/core.ts b/src/main/ts/src/minecraft/core.ts similarity index 100% rename from src/main/js/src/minecraft/core.ts rename to src/main/ts/src/minecraft/core.ts diff --git a/src/main/js/src/minecraft/entity.ts b/src/main/ts/src/minecraft/entity.ts similarity index 100% rename from src/main/js/src/minecraft/entity.ts rename to src/main/ts/src/minecraft/entity.ts diff --git a/src/main/js/src/minecraft/index.ts b/src/main/ts/src/minecraft/index.ts similarity index 100% rename from src/main/js/src/minecraft/index.ts rename to src/main/ts/src/minecraft/index.ts diff --git a/src/main/js/src/minecraft/item.ts b/src/main/ts/src/minecraft/item.ts similarity index 100% rename from src/main/js/src/minecraft/item.ts rename to src/main/ts/src/minecraft/item.ts diff --git a/src/main/js/src/minecraft/registry.ts b/src/main/ts/src/minecraft/registry.ts similarity index 100% rename from src/main/js/src/minecraft/registry.ts rename to src/main/ts/src/minecraft/registry.ts diff --git a/src/main/js/src/minecraft/tag.ts b/src/main/ts/src/minecraft/tag.ts similarity index 100% rename from src/main/js/src/minecraft/tag.ts rename to src/main/ts/src/minecraft/tag.ts diff --git a/src/main/js/src/minecraft/world.ts b/src/main/ts/src/minecraft/world.ts similarity index 100% rename from src/main/js/src/minecraft/world.ts rename to src/main/ts/src/minecraft/world.ts diff --git a/src/main/js/src/test/index.ts b/src/main/ts/src/test/index.ts similarity index 100% rename from src/main/js/src/test/index.ts rename to src/main/ts/src/test/index.ts diff --git a/src/main/ts/src/types/scriptcraft/index.d.ts b/src/main/ts/src/types/scriptcraft/index.d.ts new file mode 100644 index 0000000..e1e15ea --- /dev/null +++ b/src/main/ts/src/types/scriptcraft/index.d.ts @@ -0,0 +1,26 @@ +interface JavaObject { + discriminator: 'JavaObject'; +} + +type BridgeValueType = void | string | number | boolean | JavaObject | BridgeValueType[]; +type BridgeType = (...args: readonly BridgeValueType[]) => BridgeValueType; + +interface Console { + log(...args: readonly string[]): void; + info(...args: readonly string[]): void; + warn(...args: readonly string[]): void; + error(...args: readonly string[]): void; + dir(...args: readonly string[]): void; + debug(...args: readonly string[]): void; + trace(...args: readonly string[]): void; + + assert(condition: boolean, ...args: readonly string[]): void; +} + +declare const console: Console; + +declare module 'scriptcraft-core' { + function addBridge(name: string, bridge: BridgeType): void; + + function useBridge(name: string, ...args: readonly BridgeValueType[]): BridgeValueType; +} diff --git a/src/main/js/tsconfig.json b/src/main/ts/tsconfig.json similarity index 100% rename from src/main/js/tsconfig.json rename to src/main/ts/tsconfig.json diff --git a/src/main/js/typedoc.json b/src/main/ts/typedoc.json similarity index 100% rename from src/main/js/typedoc.json rename to src/main/ts/typedoc.json diff --git a/typescript.build.gradle b/typescript.build.gradle index 865bc27..5ff0455 100644 --- a/typescript.build.gradle +++ b/typescript.build.gradle @@ -1,6 +1,6 @@ def typescriptOut = new File(buildDir, 'generated/typescript') -def typescriptRoot = 'src/main/js' +def typescriptRoot = 'src/main/ts' def typescriptRootFile = new File(rootDir.absolutePath, typescriptRoot) task typescript(group: 'build') { @@ -19,7 +19,7 @@ task typescript(group: 'build') { executable 'npm' args 'run', 'build', '--' - args '--outDir', new File(typescriptOut, 'scriptcraft').absolutePath + args '--outDir', typescriptOut.absolutePath } } } @@ -58,16 +58,7 @@ task typedoc(group: 'documentation') { } processResources { - from typescriptOut.absolutePath -} - -task typedocJar(type: Jar) { - classifier 'typedoc' - from typedocOut -} - -typedocJar.dependsOn typedoc - -artifacts { - archives typedocJar + from(typescriptOut.absolutePath) { + into 'scriptcraft' + } } \ No newline at end of file