Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript Definitions for JS API #55

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,22 @@ dependencies {
compileOnly(libs.forgespi)
implementation(libs.nashorn)
compileOnly(libs.nulls)


annotationProcessor(implementation('org.bsc.processor:java2ts-processor:1.3.1'))

// there are here because for some reason, java2ts decides to load the classes directly
// instead of using the built-in AP feature to do proper checking
annotationProcessor(libs.bundles.asm)
annotationProcessor('org.ow2.asm:asm-util:7.3.1') // for processor
// TODO automate moving files from build/generated/sources/annotationProcessor/java/main/j2ts to resources out
// also automate doing ASMAPI class. you can't exactly load the class while compiling the class
// and also the `declare namespace Java { export function type(s: "class.name"): class.name; }` stuff, I just used some regex

}



jar {
manifest {
attributes([
Expand Down
70 changes: 70 additions & 0 deletions src/main/java/net/minecraftforge/coremod/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) Forge Development LLC
* SPDX-License-Identifier: LGPL-2.1-only
*/
@Java2TS(
name = "asm", declare = {
@Type(value = org.objectweb.asm.tree.AbstractInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.FieldInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.FrameNode.class, export = true),
@Type(value = org.objectweb.asm.tree.IincInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.InsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.IntInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.InsnList.class, export = true),
@Type(value = org.objectweb.asm.tree.InvokeDynamicInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.JumpInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.LabelNode.class, export = true),
@Type(value = org.objectweb.asm.tree.LdcInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.LineNumberNode.class, export = true),
@Type(value = org.objectweb.asm.tree.LocalVariableAnnotationNode.class, export = true),
@Type(value = org.objectweb.asm.tree.LocalVariableNode.class, export = true),
@Type(value = org.objectweb.asm.tree.LookupSwitchInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.MethodInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.MultiANewArrayInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.TableSwitchInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.TryCatchBlockNode.class, export = true),
@Type(value = org.objectweb.asm.tree.TypeAnnotationNode.class, export = true),
@Type(value = org.objectweb.asm.tree.TypeInsnNode.class, export = true),
@Type(value = org.objectweb.asm.tree.VarInsnNode.class, export = true),

// Adding new fields to classes
@Type(value = org.objectweb.asm.tree.FieldNode.class, export = true),

// Adding new methods to classes
@Type(value = org.objectweb.asm.tree.MethodNode.class, export = true),
@Type(value = org.objectweb.asm.tree.ClassNode.class, export = true),
@Type(value = org.objectweb.asm.tree.ParameterNode.class, export = true),

@Type(value = org.objectweb.asm.Attribute.class, export = true),
@Type(value = org.objectweb.asm.Handle.class, export = true),
@Type(value = org.objectweb.asm.Label.class, export = true),
@Type(value = org.objectweb.asm.Type.class, export = true),
@Type(value = org.objectweb.asm.TypePath.class, export = true),
@Type(value = org.objectweb.asm.TypeReference.class, export = true),


@Type(value = org.objectweb.asm.util.ASMifier.class, export = true),
@Type(value = org.objectweb.asm.util.ASMifierSupport.class, export = true),
@Type(value = org.objectweb.asm.util.CheckAnnotationAdapter.class, export = true),
@Type(value = org.objectweb.asm.util.CheckClassAdapter.class, export = true),
@Type(value = org.objectweb.asm.util.CheckFieldAdapter.class, export = true),
@Type(value = org.objectweb.asm.util.CheckMethodAdapter.class, export = true),
@Type(value = org.objectweb.asm.util.CheckModuleAdapter.class, export = true),
@Type(value = org.objectweb.asm.util.CheckRecordComponentAdapter.class, export = true),
@Type(value = org.objectweb.asm.util.CheckSignatureAdapter.class, export = true),
@Type(value = org.objectweb.asm.util.Printer.class, export = true),
@Type(value = org.objectweb.asm.util.Textifier.class, export = true),
@Type(value = org.objectweb.asm.util.TextifierSupport.class, export = true),
@Type(value = org.objectweb.asm.util.TraceAnnotationVisitor.class, export = true),
@Type(value = org.objectweb.asm.util.TraceClassVisitor.class, export = true),
@Type(value = org.objectweb.asm.util.TraceFieldVisitor.class, export = true),
@Type(value = org.objectweb.asm.util.TraceMethodVisitor.class, export = true),
@Type(value = org.objectweb.asm.util.TraceModuleVisitor.class, export = true),
// @Type(value=org.objectweb.asm.util.TraceRecordComponentVisitor.class, export=true),
@Type(value = org.objectweb.asm.util.TraceSignatureVisitor.class, export = true),
}
)
package net.minecraftforge.coremod;

import org.bsc.processor.annotation.Java2TS;
import org.bsc.processor.annotation.Type;
Loading