Skip to content

Commit

Permalink
fix(watermarker): add missing @JsExport annotations (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
hnorkowski authored Jun 6, 2024
1 parent 751197b commit 498449f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions watermarker/src/commonMain/kotlin/helper/Compression.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package de.fraunhofer.isst.trend.watermarker.helper

import de.fraunhofer.isst.trend.watermarker.returnTypes.Event
import de.fraunhofer.isst.trend.watermarker.returnTypes.Result
import kotlin.js.JsExport

const val COMPRESSION_LEVEL: Int = 9

Expand All @@ -19,6 +20,7 @@ expect object Compression {
fun inflate(data: List<Byte>): Result<List<Byte>>
}

@JsExport
class InflationError(val reason: String) : Event.Error("Compression.inflate") {
/** Returns a String explaining the event */
override fun getMessage() = "Error inflating bytes: $reason."
Expand Down
23 changes: 18 additions & 5 deletions watermarker/src/commonMain/kotlin/watermarks/Trendmark.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.kotlincrypto.hash.sha3.SHA3_256
import kotlin.collections.ArrayList
import kotlin.js.JsExport

@JsExport
sealed interface TrendmarkInterface {
companion object {
/** Number of bytes used as tag representing the type of the watermark */
Expand Down Expand Up @@ -83,14 +84,14 @@ sealed interface TrendmarkInterface {
}

/**
* Trendmark defines a list of Watermarks with specific format. The format is encoded in the first
* byte of the watermark, which allows to parse unknown types of Trendmarks. The implemented
* variants of Trendmark allow to encode addition information like the size or a hash into the
* watermark. For detailed information about the different formats see
* Trendmark defines a list of Watermarks with specific formats. The format is encoded in the first
* byte of the watermark, which allows parsing unknown types of Trendmarks. The implemented
* variants of Trendmark allow encoding additional information like the size or a hash into the
* watermark. For detailed information about the different formats, see
* [Trendmark.md](https://github.com/FraunhoferISST/TREND/blob/main/docs/Trendmark.md)
*
* The constructor expects bytes that represent the given type.
* To create a new watermark with arbitrary content the companion function `new` of that type must
* To create a new watermark with arbitrary content, the companion function `new` of that type must
* be used.
*
* @param content: expects bytes that represent a Trendmark.
Expand Down Expand Up @@ -598,6 +599,7 @@ fun Result<List<Watermark>>.toTrendmarks(source: String = "Trendmark"): Result<L
}
}

@JsExport
class RawWatermark(content: List<Byte>) : Trendmark(content) {
companion object {
const val SOURCE = "Trendmark.RawWatermark"
Expand Down Expand Up @@ -625,6 +627,7 @@ class RawWatermark(content: List<Byte>) : Trendmark(content) {
override fun getContent() = Result.success(watermarkContent.drop(TAG_SIZE))
}

@JsExport
class SizedWatermark(content: List<Byte>) : Trendmark(content), Trendmark.Sized {
companion object {
const val SOURCE = "Trendmark.SizedWatermark"
Expand Down Expand Up @@ -676,6 +679,7 @@ class SizedWatermark(content: List<Byte>) : Trendmark(content), Trendmark.Sized
override fun getSizeRange(): IntRange = SIZE_START_INDEX..SIZE_END_INDEX
}

@JsExport
class CRC32Watermark(content: List<Byte>) : Trendmark(content), Trendmark.Checksum {
companion object {
const val SOURCE = "Trendmark.CRC32Watermark"
Expand Down Expand Up @@ -743,6 +747,7 @@ class CRC32Watermark(content: List<Byte>) : Trendmark(content), Trendmark.Checks
}
}

@JsExport
class SizedCRC32Watermark(content: List<Byte>) :
Trendmark(content), Trendmark.Sized, Trendmark.Checksum {
companion object {
Expand Down Expand Up @@ -817,6 +822,7 @@ class SizedCRC32Watermark(content: List<Byte>) :
}
}

@JsExport
class SHA3256Watermark(content: List<Byte>) : Trendmark(content), Trendmark.Hash {
companion object {
const val SOURCE = "Trendmark.SHA3256Watermark"
Expand Down Expand Up @@ -887,6 +893,7 @@ class SHA3256Watermark(content: List<Byte>) : Trendmark(content), Trendmark.Hash
}
}

@JsExport
class SizedSHA3256Watermark(content: List<Byte>) :
Trendmark(content), Trendmark.Sized, Trendmark.Hash {
companion object {
Expand Down Expand Up @@ -963,6 +970,7 @@ class SizedSHA3256Watermark(content: List<Byte>) :
}
}

@JsExport
class CompressedRawWatermark(content: List<Byte>) : Trendmark(content), Trendmark.Compressed {
companion object {
const val SOURCE = "Trendmark.CompressedRawWatermark"
Expand Down Expand Up @@ -991,6 +999,7 @@ class CompressedRawWatermark(content: List<Byte>) : Trendmark(content), Trendmar
}
}

@JsExport
class CompressedSizedWatermark(content: List<Byte>) :
Trendmark(content), Trendmark.Sized, Trendmark.Compressed {
companion object {
Expand Down Expand Up @@ -1024,6 +1033,7 @@ class CompressedSizedWatermark(content: List<Byte>) :
SizedWatermark.SIZE_START_INDEX..SizedWatermark.SIZE_END_INDEX
}

@JsExport
class CompressedCRC32Watermark(content: List<Byte>) :
Trendmark(content), Trendmark.Compressed, Trendmark.Checksum {
companion object {
Expand Down Expand Up @@ -1075,6 +1085,7 @@ class CompressedCRC32Watermark(content: List<Byte>) :
}
}

@JsExport
class CompressedSizedCRC32Watermark(content: List<Byte>) :
Trendmark(content), Trendmark.Sized, Trendmark.Checksum {
companion object {
Expand Down Expand Up @@ -1136,6 +1147,7 @@ class CompressedSizedCRC32Watermark(content: List<Byte>) :
}
}

@JsExport
class CompressedSHA3256Watermark(content: List<Byte>) :
Trendmark(content), Trendmark.Compressed, Trendmark.Hash {
companion object {
Expand Down Expand Up @@ -1190,6 +1202,7 @@ class CompressedSHA3256Watermark(content: List<Byte>) :
}
}

@JsExport
class CompressedSizedSHA3256Watermark(content: List<Byte>) :
Trendmark(content), Trendmark.Compressed, Trendmark.Sized, Trendmark.Hash {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
*/
package de.fraunhofer.isst.trend.watermarker.watermarks

import kotlin.js.JsExport

/**
* The TrendmarkBuilder interface is designed to create classes for generating a Trendmark from
* various types of data. Implementing classes will provide the specific logic to convert different
* data types, such as text or other formats, into a list of bytes which will make up the
* Trendmark's content. This interface ensures that all types of Trendmarks maintain a consistent
* structure and can be processed in a standardized way by the watermarking library.
*/
@JsExport
interface TrendmarkBuilder {
/** Generates a Trendmark with the specific content */
fun finish(): Trendmark
Expand Down

0 comments on commit 498449f

Please sign in to comment.