diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md new file mode 100644 index 0000000..bd8b51f --- /dev/null +++ b/docs/ARCHITECTURE.md @@ -0,0 +1,26 @@ +# Architecture + +## JavaScript +Inside the JAR, JS source files are in ```/scriptcraft```, and inside a typical Gradle project they are in ```src/main/resources/scriptcraft```. + +### External Libraries +An external libraries API can be accessed using an ```import``` statement. + +## TypeScript +TypeScript-based projects use thw ```com.thebrokenrail.scriptcraft``` Gradle plugin, this plugin will handle installing TypeScript and download any API type declarations. The TypeScript root using this Gradle plugin is at ```src/main/ts```. + +### External Libraries +To access an external libraries' API in addition to an ```import``` statement, the TypeScript compiler must have access to the external libraries' type declarations. The ScriptCraft Gradle plugin generates and downloads these using JAR files called API JARs. + +To generate an API JAr from your project, run ```./gradlew apiJar```, or add the ```apiJar``` task to your Maven publication. + +To add an API JAR to your project, add it to the ```typescript``` configuration in your ```dependencies``` block. + +#### API JAR File Structure +``` +- API JAR Root + - src/ + - Source Root + - types/ + - File structure of node_modules/@types +``` \ No newline at end of file diff --git a/docs/FILE_STRUCTURE.md b/docs/FILE_STRUCTURE.md deleted file mode 100644 index d4335ec..0000000 --- a/docs/FILE_STRUCTURE.md +++ /dev/null @@ -1,17 +0,0 @@ -# File Structure -``` -- Jar Root - - scriptcraft/ - - Source Root -``` - -## Recommended Source Structure -``` -- Source Root - - ModID/ - - index.js/index.ts - - Other Modules -``` - -### Why is an index file necessary? -Because of the way module resolution in ScriptCraft works, you cannot load a module with ```import 'module-name';``` and no index file. Without an index file you would need to use ```import 'module-name/main';``` to load it and specify ```module-name/main``` as your entry-point. \ No newline at end of file diff --git a/docs/MODULE_RESOLUTION.md b/docs/MODULE_RESOLUTION.md index 925e5dd..5f58323 100644 --- a/docs/MODULE_RESOLUTION.md +++ b/docs/MODULE_RESOLUTION.md @@ -7,5 +7,5 @@ All ScriptCraft mods have a folder called ```scriptcraft``` in the root of their - ```.json``` ## Extra Details -- If the import path is a folder, ScriptCraft will load the ```index``` file with one of the supported file types. -- If an extension does not exist in the import path it will look for a file with the same name and one of the supported extensions. \ No newline at end of file +- If the import path is a folder, ScriptCraft will load the ```index``` file, and if it doesn't exist it will try to load ```/index```. +- If the specified import does not exist, it will try to load the import appended with each supported file type. \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index b02d337..640040c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,6 +5,6 @@ [View Bridges](BRIDGES.md) -[View File Structure](FILE_STRUCTURE.md) +[View Architecture](ARCHITECTURE.md) [View TypeDoc](https://jenkins.thebrokenrail.com/job/ScriptCraft/job/master/TypeDoc/) \ No newline at end of file diff --git a/examples/typescript/README.md b/examples/typescript/README.md index e23dba7..d6616bd 100644 --- a/examples/typescript/README.md +++ b/examples/typescript/README.md @@ -8,19 +8,4 @@ This is an example of a Minecraft mod made in TypeScript using ScriptCraft. ## Notes - This will also work with JavaScript if you set ```compilerOptions.allowJs``` and optionally ```compilerOptions.checkJs``` in ```src/main/ts/tsconfig.json``` to ```true``` - NPM dependencies are not bundled -- API JARs are not bundled - -## API JARs -An API JAR can be built with ```./gradlew apiJar```. - -### ```typescript``` Gradle Configuration -The ```typescript``` gradle configuration will extract the specified API JAR into ```src/main/ts/build/dependencies```. It will not be bundled with the mod. - -### File Structure -``` -- API JAR Root - - src/ - - Source Root - - types/ - - File structure of node_modules/@types -``` \ No newline at end of file +- API JARs are not bundled \ No newline at end of file diff --git a/examples/typescript/build.gradle.kts b/examples/typescript/build.gradle.kts index 4c206d9..318dc10 100644 --- a/examples/typescript/build.gradle.kts +++ b/examples/typescript/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("fabric-loom") version "0.2.7-SNAPSHOT" - id("com.thebrokenrail.scriptcraft") + id("com.thebrokenrail.scriptcraft") version "1.0.0-SNAPSHOT" } java { diff --git a/scriptcraft/build.gradle.kts b/scriptcraft/build.gradle.kts index fd95e9e..5567ac8 100644 --- a/scriptcraft/build.gradle.kts +++ b/scriptcraft/build.gradle.kts @@ -1,7 +1,7 @@ plugins { id("fabric-loom") version "0.2.7-SNAPSHOT" id("jni") - id("com.thebrokenrail.scriptcraft") + id("com.thebrokenrail.scriptcraft") version "1.0.0-SNAPSHOT" `maven-publish` }