- change from Kotlin multi-platform to two subprojects.
- set up ts->lua generation
This commit is contained in:
parent
18dfc3ebdb
commit
ec94c68187
11 changed files with 1699 additions and 0 deletions
151
modules/mod/build.gradle.kts
Normal file
151
modules/mod/build.gradle.kts
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs
|
||||
|
||||
plugins {
|
||||
// kotlin("js")
|
||||
id("com.github.node-gradle.node")
|
||||
}
|
||||
|
||||
group = "${rootProject.group}.mod"
|
||||
version = rootProject.version
|
||||
|
||||
node {
|
||||
download.set(true)
|
||||
version.set("14.18.0")
|
||||
// version.set("16.10.0")
|
||||
}
|
||||
// "@types/node": "ts4.4",
|
||||
// 16.10.3 = ts4.4, see https://www.npmjs.com/package/@types/node
|
||||
|
||||
|
||||
//repositories {
|
||||
// mavenCentral()
|
||||
// maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/")
|
||||
// maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
|
||||
//}
|
||||
|
||||
//kotlin {
|
||||
// js(IR) {
|
||||
//
|
||||
// binaries.executable()
|
||||
//
|
||||
// browser {
|
||||
// commonWebpackConfig {
|
||||
// cssSupport.enabled = true
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// useCommonJs()
|
||||
// nodejs()
|
||||
//
|
||||
// compilations["main"].apply {
|
||||
// packageJson {
|
||||
// customField(
|
||||
// "scripts",
|
||||
// mapOf(
|
||||
// "build" to "tstl",
|
||||
// "dev" to "tstl --watch",
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// sourceSets {
|
||||
// val main by getting {
|
||||
//// kotlin.srcDir("externals02")
|
||||
//// kotlin.srcDir("externals")
|
||||
//
|
||||
// dependencies {
|
||||
//
|
||||
// val kotlinWrappersVersion = "0.0.1-pre.254-kotlin-1.5.31"
|
||||
// implementation(
|
||||
// project.dependencies.enforcedPlatform(
|
||||
// "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${kotlinWrappersVersion}"
|
||||
// )
|
||||
// )
|
||||
//
|
||||
// implementation("org.jetbrains.kotlin-wrappers:kotlin-react")
|
||||
// implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom")
|
||||
// implementation(npm("react", "17.0.2"))
|
||||
// implementation(npm("react-dom", "17.0.2"))
|
||||
//
|
||||
//// implementation("org.jetbrains.kotlinx:kotlinx-nodejs:0.0.7") {
|
||||
//// because("https://github.com/Kotlin/kotlinx-nodejs")
|
||||
//// }
|
||||
//
|
||||
// val generateExternals = false
|
||||
// implementation(npm("typescript-to-lua", "1.0.1", generateExternals = generateExternals))
|
||||
// implementation(npm("typed-factorio", "0.7.1", generateExternals = generateExternals))
|
||||
// implementation(npm("lua-types", "2.11.0", generateExternals = generateExternals))
|
||||
// implementation(npm("typescript", "4.4.3", generateExternals = generateExternals))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// val test by getting {
|
||||
// dependencies {
|
||||
// implementation(kotlin("test-js"))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
val tstlTask = tasks.register<com.github.gradle.node.npm.task.NpmTask>("tstl") {
|
||||
description = "Typescript To Lua"
|
||||
group = "${rootProject.group}"
|
||||
dependsOn(tasks.npmInstall)
|
||||
|
||||
npmCommand.set(listOf("run", "build"))
|
||||
args.set(listOf("--", "--outDir", "$buildDir/npm-output"))
|
||||
// args.set(listOf("test"))
|
||||
ignoreExitValue.set(false)
|
||||
// environment.set(mapOf("MY_CUSTOM_VARIABLE" to "hello"))
|
||||
workingDir.set(projectDir)
|
||||
execOverrides {
|
||||
standardOutput = System.out
|
||||
}
|
||||
inputs.dir("node_modules")
|
||||
inputs.dir(fileTree("src/main/typescript"))
|
||||
inputs.files(
|
||||
"tsconfig.json",
|
||||
"package.json",
|
||||
)
|
||||
outputs.dir("$buildDir/factorio-web-map/")
|
||||
// outputs.dir("$buildDir/npm-output")
|
||||
// outputs.upToDateWhen { true }
|
||||
}
|
||||
|
||||
//sourceSets {
|
||||
// val typescript by creating {
|
||||
// setBuildDir("src/main/typescript")
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//dependencies {
|
||||
// val kotlinWrappersVersion = "0.0.1-pre.254-kotlin-1.5.31"
|
||||
// implementation(
|
||||
// project.dependencies.enforcedPlatform(
|
||||
// "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${kotlinWrappersVersion}"
|
||||
// )
|
||||
// )
|
||||
//
|
||||
// implementation("org.jetbrains.kotlin-wrappers:kotlin-react")
|
||||
// implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom")
|
||||
// implementation(npm("react", "17.0.2"))
|
||||
// implementation(npm("react-dom", "17.0.2"))
|
||||
//
|
||||
// // @types/node
|
||||
|
||||
//// implementation("org.jetbrains.kotlinx:kotlinx-nodejs:0.0.7") {
|
||||
//// because("https://github.com/Kotlin/kotlinx-nodejs")
|
||||
//// }
|
||||
//
|
||||
// val generateExternals = false
|
||||
// implementation(npm("typescript-to-lua", "1.0.1", generateExternals = generateExternals))
|
||||
// implementation(npm("typed-factorio", "0.7.1", generateExternals = generateExternals))
|
||||
// implementation(npm("lua-types", "2.11.0", generateExternals = generateExternals))
|
||||
// implementation(npm("typescript", "4.4.3", generateExternals = generateExternals))
|
||||
//
|
||||
// testImplementation(kotlin("test-js"))
|
||||
//}
|
||||
9
modules/mod/events.lua
Normal file
9
modules/mod/events.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
|
||||
script.on_event(
|
||||
{defines.events.on_pre_build, defines.events.on_player_dropped_item},
|
||||
function(e)
|
||||
log(
|
||||
(("player " .. tostring(e.player_index)) .. " dropped item, tick:") .. tostring(e.tick)
|
||||
)
|
||||
end
|
||||
)
|
||||
1329
modules/mod/package-lock.json
generated
Normal file
1329
modules/mod/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
28
modules/mod/package.json
Normal file
28
modules/mod/package.json
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"name": "factorio-web-map-mod",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "tstl",
|
||||
"dev": "tstl --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"webpack": "5.38.1",
|
||||
"webpack-cli": "4.7.1",
|
||||
"format-util": "1.0.5",
|
||||
"source-map-loader": "3.0.0",
|
||||
"css-loader": "5.2.6",
|
||||
"style-loader": "2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "17.0.2",
|
||||
"react-dom": "17.0.2",
|
||||
"typescript-to-lua": "1.0.1",
|
||||
"typed-factorio": "0.7.1",
|
||||
"lua-types": "2.11.0",
|
||||
"typescript": "4.4.3"
|
||||
},
|
||||
"peerDependencies": {},
|
||||
"optionalDependencies": {},
|
||||
"bundledDependencies": []
|
||||
}
|
||||
3
modules/mod/settings.gradle.kts
Normal file
3
modules/mod/settings.gradle.kts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
rootProject.name = "factorio-web-map-mod"
|
||||
|
||||
rootProject.description = "Factorio Web Map mod"
|
||||
6
modules/mod/src/main/typescript/events.ts
Normal file
6
modules/mod/src/main/typescript/events.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
script.on_event(
|
||||
[defines.events.on_pre_build, defines.events.on_player_dropped_item],
|
||||
(e: OnPreBuildEvent | OnPlayerDroppedItemEvent) => {
|
||||
log("player " + e.player_index + " dropped item, tick:" + e.tick)
|
||||
}
|
||||
)
|
||||
17
modules/mod/tsconfig.json
Normal file
17
modules/mod/tsconfig.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"lib": [
|
||||
"esnext"
|
||||
],
|
||||
"moduleResolution": "node",
|
||||
"types": [
|
||||
"typed-factorio/runtime"
|
||||
],
|
||||
"strict": true
|
||||
},
|
||||
"tstl": {
|
||||
"luaTarget": "JIT",
|
||||
"tstlVerbose": true
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue