-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bump up version * Create core module * Move files * Add some JsExport * Add: Support analysis for lyrics with suffix * Add functions for TS library (#164) * Change: Use Array for better typing * Add: Add generate functions * Add: Add ability to build minimum core * Add: Add wrapper * Add: Add test * Improve: gradlew test will run deno test * Add: Add missing keys * Change: Create documentToUfData / ufDataToDocument * Fix: Fix name shadowing * Add: Add 10 tracks test * Change: Create project data * Add: add parseFile and toFile * Add: Add fromAny * Add: Add convertJapaneseLyrics * Add: Add ust * Delete: Delete deno things * Delete: Delete unused gitignore# * Change: DocumentContainer -> ProjectContainer * Change: Use KDoc * Change: Use internal to hide error * Change: Rename convertJapaneseLyrics * Change: Change visibility * Revert: webpack.config.d was required * Fix resources resolve * Use midi-file instead of midi-parser-js (#165) * Change: Use midi-file * Fix: Fix importing assets * Fix: Run kotlinUpgradeYarnLock * Fix: Fix resolver * Change: Make ESModule conditional * Delete: Delete workaround * Delete: Delete unused dependency * Revert: Re-add workaround * Revert: Revert unrelated changes * Update: Update yarn.lock * Change: Re-throw error * Fix: Fix error * Fix: It throws string, not an Error * Fix tasks about resources copy --------- Co-authored-by: colin.weng <[email protected]> * Export exceptions to JS (#167) * Update Russian translation (#168) * Change: Don't remove "っ" by default (#169) * Change: Don't remove "っ" by default * Delete: Why is there a new line? * Allow specifying default lyrics via ImportParams (#170) * Add: Allow specifying default lyrics via ImportParams * Code: gradlew ktlintFormat * Update: Update Format.kt * Allow specifying ImportParams from JS, and export pitches (#171) * Add: Support tssln (#172) * Add: Support importing tssln * Add: Add basic export * Code: gradlew ktlintFormat * Change: Use yarn * Update: Update texts for tssln (#174) * Update: Update texts * Update: kotlinUpgradeYarnLock * Fix: Fix around esm import * Code: Format * Export tssln to JS (#175) * Add: Export tssln * Change: Use val * Fix some issues (#176) * Fix: Fix some minor issues * Add: Add comment * Fix: Fix loading tssln from VST (#177) * Fix: Fix loading tssln from VST * Code: gradlew ktlintFormat --------- Co-authored-by: sevenc-nanashi <[email protected]> Co-authored-by: colin.weng <[email protected]> Co-authored-by: Dmitry Kiryanov <[email protected]>
- Loading branch information
1 parent
baee542
commit 724bee6
Showing
156 changed files
with
1,763 additions
and
997 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@jsr:registry=https://npm.jsr.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@jsr:registry=https://npm.jsr.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
plugins { | ||
kotlin("js") | ||
kotlin("plugin.serialization") | ||
} | ||
|
||
group = "com.sdercolin.utaformatix" | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
kotlin { | ||
js(IR) { | ||
binaries.library() | ||
browser() | ||
generateTypeScriptDefinitions() | ||
useEsModules() | ||
dependencies { | ||
implementation("com.sdercolin.utaformatix:utaformatix-data:1.0.0") | ||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.6.4") | ||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0") | ||
implementation(npm("jszip", "3.5.0")) | ||
implementation(npm("encoding-japanese", "1.0.30")) | ||
implementation(npm("uuid", "8.3.2")) | ||
implementation(npm("midi-file", "1.2.4")) | ||
implementation(npm("js-yaml", "4.1.0")) | ||
implementation( | ||
npm("@sevenc-nanashi/valuetree-ts", "npm:@jsr/[email protected]"), | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
@file:OptIn(DelicateCoroutinesApi::class, ExperimentalJsExport::class, ExperimentalSerializationApi::class) | ||
|
||
import com.sdercolin.utaformatix.data.Document | ||
import core.io.UfData | ||
import core.model.ConversionParams | ||
import core.model.ExportResult | ||
import core.model.FeatureConfig | ||
import core.model.Format | ||
import core.model.ImportParams | ||
import core.model.JapaneseLyricsType | ||
import core.model.ProjectContainer | ||
import core.process.lyrics.japanese.analyseJapaneseLyricsTypeForProject | ||
import kotlinx.coroutines.DelicateCoroutinesApi | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.promise | ||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlinx.serialization.decodeFromString | ||
import kotlinx.serialization.json.Json | ||
import org.w3c.files.File | ||
import kotlin.js.Promise | ||
import core.process.lyrics.japanese.convertJapaneseLyrics as convertJapaneseLyricsBase | ||
|
||
@JsExport | ||
fun parseVsqx(file: File, params: ImportParams): Promise<ProjectContainer> = parse(listOf(file), params, Format.Vsqx) | ||
|
||
@JsExport | ||
fun parseVpr(file: File, params: ImportParams): Promise<ProjectContainer> = parse(listOf(file), params, Format.Vpr) | ||
|
||
@JsExport | ||
fun parseUst( | ||
files: Array<File>, | ||
params: ImportParams, | ||
): Promise<ProjectContainer> = parse(files.toList(), params, Format.Ust) | ||
|
||
@JsExport | ||
fun parseUstx(file: File, params: ImportParams): Promise<ProjectContainer> = parse(listOf(file), params, Format.Ustx) | ||
|
||
@JsExport | ||
fun parseCcs(file: File, params: ImportParams): Promise<ProjectContainer> = parse(listOf(file), params, Format.Ccs) | ||
|
||
@JsExport | ||
fun parseSvp(file: File, params: ImportParams): Promise<ProjectContainer> = parse(listOf(file), params, Format.Svp) | ||
|
||
@JsExport | ||
fun parseS5p(file: File, params: ImportParams): Promise<ProjectContainer> = parse(listOf(file), params, Format.S5p) | ||
|
||
@JsExport | ||
fun parseMusicXml(file: File, params: ImportParams): Promise<ProjectContainer> = | ||
parse(listOf(file), params, Format.MusicXml) | ||
|
||
@JsExport | ||
fun parseDv(file: File, params: ImportParams): Promise<ProjectContainer> = parse(listOf(file), params, Format.Dv) | ||
|
||
@JsExport | ||
fun parseVsq(file: File, params: ImportParams): Promise<ProjectContainer> = parse(listOf(file), params, Format.Vsq) | ||
|
||
@JsExport | ||
fun parseVocaloidMid(file: File, params: ImportParams): Promise<ProjectContainer> = | ||
parse(listOf(file), params, Format.VocaloidMid) | ||
|
||
@JsExport | ||
fun parseStandardMid(file: File, params: ImportParams): Promise<ProjectContainer> = | ||
parse(listOf(file), params, Format.StandardMid) | ||
|
||
@JsExport | ||
fun parsePpsf(file: File, params: ImportParams): Promise<ProjectContainer> = parse(listOf(file), params, Format.Ppsf) | ||
|
||
@JsExport | ||
fun parseTssln(file: File, params: ImportParams): Promise<ProjectContainer> = parse(listOf(file), params, Format.Tssln) | ||
|
||
@JsExport | ||
fun parseUfData(file: File, params: ImportParams): Promise<ProjectContainer> = | ||
parse(listOf(file), params, Format.UfData) | ||
|
||
private fun parse(files: List<File>, params: ImportParams, format: Format): Promise<ProjectContainer> = | ||
GlobalScope.promise { | ||
val project = format.parser(files, params) | ||
ProjectContainer(project) | ||
} | ||
|
||
@JsExport | ||
fun generateVsqx(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.Vsqx) | ||
|
||
@JsExport | ||
fun generateVpr(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.Vpr) | ||
|
||
@JsExport | ||
fun generateUstZip(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.Ust) | ||
|
||
@JsExport | ||
fun generateUstx(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.Ustx) | ||
|
||
@JsExport | ||
fun generateCcs(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.Ccs) | ||
|
||
@JsExport | ||
fun generateSvp(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.Svp) | ||
|
||
@JsExport | ||
fun generateS5p(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.S5p) | ||
|
||
@JsExport | ||
fun generateMusicXmlZip(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.MusicXml) | ||
|
||
@JsExport | ||
fun generateDv(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.Dv) | ||
|
||
@JsExport | ||
fun generateVsq(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.Vsq) | ||
|
||
@JsExport | ||
fun generateVocaloidMid(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.VocaloidMid) | ||
|
||
@JsExport | ||
fun generateStandardMid(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.StandardMid) | ||
|
||
@JsExport | ||
fun generateTssln(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.Tssln) | ||
|
||
@JsExport | ||
fun generateUfData(project: ProjectContainer, params: ConversionParams): Promise<ExportResult> = | ||
generate(project, params, Format.UfData) | ||
|
||
private fun generate(project: ProjectContainer, params: ConversionParams, format: Format): Promise<ExportResult> { | ||
val features = mutableListOf<FeatureConfig>() | ||
if (params.convertPitch) { | ||
features.add(FeatureConfig.ConvertPitch) | ||
} | ||
|
||
return GlobalScope.promise { | ||
format.generator( | ||
project.project, | ||
features, | ||
) | ||
} | ||
} | ||
|
||
@JsExport | ||
fun projectToUfData(project: ProjectContainer): String { | ||
return jsonSerializer.encodeToString( | ||
Document.serializer(), | ||
UfData.generateDocument( | ||
project.project, | ||
listOf( | ||
FeatureConfig.ConvertPitch, | ||
), | ||
), | ||
) | ||
} | ||
|
||
@JsExport | ||
fun ufDataToProject(documentJson: String): ProjectContainer { | ||
val document: Document = jsonSerializer.decodeFromString(documentJson) | ||
return ProjectContainer( | ||
UfData.parseDocument( | ||
document, | ||
listOf(), | ||
ImportParams(), | ||
), | ||
) | ||
} | ||
|
||
@JsExport | ||
fun convertJapaneseLyrics( | ||
project: ProjectContainer, | ||
fromType: JapaneseLyricsType, | ||
targetType: JapaneseLyricsType, | ||
convertVowelConnections: Boolean, | ||
): ProjectContainer { | ||
val baseProject = project.project | ||
val newProject = core.model.Project( | ||
format = Format.UfData, | ||
inputFiles = listOf(), | ||
name = baseProject.name, | ||
tracks = baseProject.tracks, | ||
timeSignatures = baseProject.timeSignatures, | ||
tempos = baseProject.tempos, | ||
measurePrefix = baseProject.measurePrefix, | ||
importWarnings = baseProject.importWarnings, | ||
japaneseLyricsType = fromType, | ||
) | ||
val converted = convertJapaneseLyricsBase( | ||
newProject, | ||
targetType, | ||
if (convertVowelConnections) { | ||
Format.Ust | ||
} else { | ||
Format.UfData | ||
}, | ||
) | ||
return ProjectContainer(converted) | ||
} | ||
|
||
@JsExport | ||
fun analyzeJapaneseLyricsType(project: ProjectContainer): JapaneseLyricsType { | ||
return analyseJapaneseLyricsTypeForProject(project.project) | ||
} | ||
|
||
@OptIn(ExperimentalSerializationApi::class) | ||
val jsonSerializer = Json { | ||
isLenient = true | ||
ignoreUnknownKeys = true | ||
encodeDefaults = true | ||
explicitNulls = false | ||
} |
5 changes: 5 additions & 0 deletions
5
core/src/main/kotlin/core/exception/CannotReadFileException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package core.exception | ||
|
||
@OptIn(ExperimentalJsExport::class) | ||
@JsExport | ||
class CannotReadFileException : Throwable() |
4 changes: 3 additions & 1 deletion
4
...kotlin/exception/EmptyProjectException.kt → ...n/core/exception/EmptyProjectException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package exception | ||
package core.exception | ||
|
||
@OptIn(ExperimentalJsExport::class) | ||
@JsExport | ||
class EmptyProjectException : Throwable("This format could not take en empty project.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.