Package-level declarations

Types

Link copied to clipboard

Runtime access-widening requests from TypeScript (ratph6.tessera.api.AccessWidener). Like Fabric's static access widener, but applied live by MixinTransformer when a class is (re)loaded — so scripts can open up private/final Minecraft members on demand.

Link copied to clipboard
class BytecodeModule(val manifest: TesseraManifest, val directory: Path, val runner: ByteCodeRunner) : TesseraModule

A module compiled to JVM bytecode by swc4j. Exported functions live on defaultClass as static methods; Tessera looks them up (and caches a MethodHandle) when a trigger needs to call one.

Link copied to clipboard
object Callbacks
Link copied to clipboard
object Engines

The execution engine a module runs on (see TesseraManifest.engine).

Link copied to clipboard
class GraalCallback(fn: Value) : TesseraCallback

A raw GraalJS guest function. JavaScript tolerates arity mismatches (extra args ignored, missing ones become undefined), so every provided arg is passed through as-is. Must be called on the JS thread (the GraalJS org.graalvm.polyglot.Context is single-threaded) — which is where dispatch already runs.

Link copied to clipboard
class GraalModule(val manifest: TesseraManifest, val directory: Path) : TesseraModule

A module evaluated as an ES module by GraalJS. Its top-level code already ran on load (so top-level Tessera.register(...) calls are live); namespace is the module's export namespace, from which named exported functions (for the main/init entry and trigger-name conventions) are read.

Link copied to clipboard

The GraalJS execution engine — the "real JavaScript" path. A Tessera module's TypeScript is first transpiled to JavaScript by swc4j (here used as a plain TS→JS transpiler, not its bytecode compiler) and then evaluated as an ES module on a GraalJS Context. Scripts get full ECMAScript: real arrays with .map/.filter, closures over reassigned lets, objects, JSON, etc. — none of the bytecode path's "half-Java" workarounds (Store/Num/Args).

Link copied to clipboard
class HandleCallback(handle: MethodHandle, val paramCount: Int) : TesseraCallback

A JVM-side callable invoked through a MethodHandle, padded/truncated to paramCount.

Link copied to clipboard

Obtains a live Instrumentation for the running JVM by loading a tiny java agent (see ratph6.tessera.agent.TesseraAgent). This is what lets TypeScript mixins rewrite Minecraft classes that are already loaded by the time a script runs — a static .mixins.json only gets a shot during early class loading.

Link copied to clipboard
object MixinAt

Where in a target method an injection runs.

Link copied to clipboard
object MixinHooks

Static entry points that the bytecode injected by MixinTransformer calls into. The signatures here are an ABI — MixinTransformer emits INVOKESTATIC calls against these exact names/descriptors, so changing them means changing the transformer too.

Link copied to clipboard

Front door for TypeScript mixins. Lazily self-attaches the instrumentation agent and installs MixinTransformer on the first injection, registers each hook in MixinRegistry, and triggers a retransform so the change takes effect immediately — even for Minecraft classes that are already loaded. Reverting (on /te reload or module unload) retransforms the affected classes back to their original bytes.

Link copied to clipboard

The set of TypeScript-defined injections currently active. Indexed two ways: by the internal class name (net/minecraft/...) so MixinTransformer can find what to inject when a class is (re)loaded, and by a small integer Hook.id that the injected bytecode passes back to MixinHooks to identify which callback to run.

Link copied to clipboard

The single retransform-capable ClassFileTransformer behind TypeScript mixins. For any class that has registered MixinRegistry hooks, it rewrites the matching methods to call MixinHooks — at HEAD (with the option to cancel or substitute the return value) and/or at every RETURN site.

Link copied to clipboard

Reflection-backed member access for scripts — the part of "access widening" that works on classes that are already loaded (where bytecode modifier-flipping is illegal). Mod code runs with full Java access and net.minecraft lives in the unnamed module, so setAccessible(true) succeeds; GraalJS can't reach java.lang.reflect itself, so these helpers are the bridge.

Link copied to clipboard
sealed interface TesseraCallback

A script callback, normalized so the engine can invoke it the same way regardless of which engine produced it:

Link copied to clipboard

Compiles a Tessera script (TypeScript / modern JS) straight to JVM bytecode using swc4j's ByteCodeCompiler. Scripts run as native JVM classes — every export function becomes a static method on the default $ class, and scripts reach the Tessera API by importing our Kotlin objects by package, e.g. import { Tessera, Event } from 'ratph6.tessera.api'.

Link copied to clipboard

The heart of Tessera. Compiles each module's TypeScript to JVM bytecode (via TesseraCompiler), invokes its main() entry point, and dispatches triggers by invoking the named exported function through a cached MethodHandle. No V8, no JNI on the dispatch path.

Link copied to clipboard
data class TesseraError(val where: String, val detail: String, val tick: Long, val stack: String? = null)

A captured script error, surfaced by /te errors and the console. stack is the full chain.

Link copied to clipboard

Static entry points that mixins (Java) call into. Kept dependency-light so the mixin classes don't need to know about Kotlin object instances.

Link copied to clipboard

Discovers and compiles modules under <gameDir>/tessera/modules/<moduleName>/.

Link copied to clipboard
data class TesseraLogLine(val level: String, val where: String, val message: String, val detail: String?, val tick: Long)

One line for the Tessera console: a level (info/warn/error/debug), origin, message and optional detail.

Link copied to clipboard
data class TesseraManifest(val name: String, val version: String = "1.0.0", val author: String = "unknown", val description: String = "", val dependencies: List<String> = emptyList(), val priority: Int = 0, val entry: String = "index.ts", val engine: String = Engines.DEFAULT)

Parsed tessera.json manifest.

Link copied to clipboard
sealed interface TesseraModule

A compiled, loaded module. Engine-agnostic surface: its manifest/dir, the names of its exported functions, and a uniform TesseraCallback for any one of them. Two implementations:

Link copied to clipboard

Bridge between the entity-render mixin and the engine. Called on the render thread (which is the JS thread), once before and once after each entity model is submitted, with the live PoseStack.

Link copied to clipboard
Duck-typing interface mixed into EntityRenderState so Tessera can recover the live Entity behind a render state.