@wunk/lb-script-api-types 0.38.3 → 0.38.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -60,6 +60,30 @@ import { AttackEntityEvent } from "@wunk/lb-script-api-types/types/net/ccbluex/l
60
60
  The package ships one `.d.ts` per class (mirroring the JVM package layout), so
61
61
  `tsc` only parses the types a script actually imports.
62
62
 
63
+ ### Typed `Java.type` (opt-in registry)
64
+
65
+ By default `Java.type(...)` returns `any` (or takes an explicit generic).
66
+ Opt into the string-literal registry and it is fully typed from the class
67
+ name alone — autocomplete on the string, typed statics/constructors on the
68
+ result. Works in plain JS too (the editor language service picks it up from
69
+ jsconfig):
70
+
71
+ ```jsonc
72
+ "types": [
73
+ "@wunk/lb-script-api-types/ambient",
74
+ "@wunk/lb-script-api-types/registry-lb" // net.ccbluex.* (~2.6k classes, ~+1s tsc)
75
+ ]
76
+ ```
77
+
78
+ ```ts
79
+ const SilentHotbar = Java.type("net.ccbluex.liquidbounce.utils.client.SilentHotbar");
80
+ SilentHotbar.INSTANCE.serversideSlot; // typed — no generic, no import
81
+ ```
82
+
83
+ `registry-full` covers every generated class (~49k) — great for editor use,
84
+ but it adds tens of seconds to batch `tsc` runs, so prefer `registry-lb` in
85
+ CI. Unknown class names fall back to the generic `any` overload either way.
86
+
63
87
  LiquidBounce internals that have a generated type but are **not** runtime
64
88
  globals (e.g. `SilentHotbar`) are reached via `Java.type`, typed with the
65
89
  matching import:
@@ -32,9 +32,16 @@ declare global {
32
32
  // script but invisible to `Object.entries(globalThis)`. See:
33
33
  // https://www.graalvm.org/jdk25/reference-manual/js/JavaInteroperability/
34
34
  // https://www.graalvm.org/jdk25/reference-manual/polyglot-programming/
35
+ /** Merge target for the optional Java.type string-literal registry —
36
+ * add "@wunk/lb-script-api-types/registry-lb" (or registry-full) to your
37
+ * tsconfig "types" to populate it. Empty by default: zero compile cost,
38
+ * Java.type falls back to the generic overload. */
39
+ interface JavaTypeRegistry {}
40
+
35
41
  interface JavaIntrinsic {
36
42
  /** Resolve a Java class by FQN. Returns a "type" handle: callable as
37
43
  * a constructor and indexable for static members. */
44
+ type<K extends keyof JavaTypeRegistry>(className: K): JavaTypeRegistry[K];
38
45
  type<T = any>(className: string): T;
39
46
  /** Convert a Java array (or Iterable) to a JS array. */
40
47
  from<T = unknown>(javaArray: any): T[];
package/package.json CHANGED
@@ -1,56 +1,64 @@
1
1
  {
2
- "name": "@wunk/lb-script-api-types",
3
- "version": "0.38.3",
4
- "description": "TypeScript types for the LiquidBounce (nextgen, MC 1.21+) GraalJS script API — a heavily-refined fork of CCBlueX's @ccbluex/liquidbounce-script-api with typed per-event on() overloads, KDoc→TSDoc docs, binding fixes, and ambient globals.",
5
- "license": "GPL-3.0-or-later",
6
- "author": "obus-globus",
7
- "homepage": "https://github.com/obus-globus/lb-script-api-types#readme",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/obus-globus/lb-script-api-types.git",
11
- "directory": "typings"
12
- },
13
- "bugs": {
14
- "url": "https://github.com/obus-globus/lb-script-api-types/issues"
15
- },
16
- "keywords": [
17
- "liquidbounce",
18
- "minecraft",
19
- "graaljs",
20
- "graalvm",
21
- "script-api",
22
- "scripting",
23
- "types",
24
- "typescript",
25
- "ccbluex"
26
- ],
27
- "types": "ambient/ambient.d.ts",
28
- "files": [
29
- "types/**/*.d.ts",
30
- "augmentations/**/*.d.ts",
31
- "ambient/ambient.d.ts"
32
- ],
33
- "typesVersions": {
34
- "*": {
35
- "types/*": [
36
- "./types/*"
37
- ],
38
- "augmentations/*": [
39
- "./augmentations/*"
40
- ],
41
- "ambient": [
42
- "./ambient/ambient.d.ts"
43
- ]
2
+ "name": "@wunk/lb-script-api-types",
3
+ "version": "0.38.4",
4
+ "description": "TypeScript types for the LiquidBounce (nextgen, MC 1.21+) GraalJS script API — a heavily-refined fork of CCBlueX's @ccbluex/liquidbounce-script-api with typed per-event on() overloads, KDoc→TSDoc docs, binding fixes, and ambient globals.",
5
+ "license": "GPL-3.0-or-later",
6
+ "author": "obus-globus",
7
+ "homepage": "https://github.com/obus-globus/lb-script-api-types#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/obus-globus/lb-script-api-types.git",
11
+ "directory": "typings"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/obus-globus/lb-script-api-types/issues"
15
+ },
16
+ "keywords": [
17
+ "liquidbounce",
18
+ "minecraft",
19
+ "graaljs",
20
+ "graalvm",
21
+ "script-api",
22
+ "scripting",
23
+ "types",
24
+ "typescript",
25
+ "ccbluex"
26
+ ],
27
+ "types": "ambient/ambient.d.ts",
28
+ "files": [
29
+ "types/**/*.d.ts",
30
+ "augmentations/**/*.d.ts",
31
+ "ambient/ambient.d.ts",
32
+ "registry-lb/index.d.ts",
33
+ "registry-full/index.d.ts"
34
+ ],
35
+ "typesVersions": {
36
+ "*": {
37
+ "types/*": [
38
+ "./types/*"
39
+ ],
40
+ "augmentations/*": [
41
+ "./augmentations/*"
42
+ ],
43
+ "ambient": [
44
+ "./ambient/ambient.d.ts"
45
+ ],
46
+ "registry-lb": [
47
+ "./registry-lb/index.d.ts"
48
+ ],
49
+ "registry-full": [
50
+ "./registry-full/index.d.ts"
51
+ ]
52
+ }
53
+ },
54
+ "sideEffects": false,
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "liquidbounce": {
59
+ "version": "0.38.1",
60
+ "minecraft": "26.1.2",
61
+ "commit": "b759cac57b26e54694d8c4d48af024a8fb598f62",
62
+ "ref": "v0.38.0-33-gb759cac57"
44
63
  }
45
- },
46
- "sideEffects": false,
47
- "publishConfig": {
48
- "access": "public"
49
- },
50
- "liquidbounce": {
51
- "version": "0.38.1",
52
- "minecraft": "26.1.2",
53
- "commit": "b759cac57b26e54694d8c4d48af024a8fb598f62",
54
- "ref": "v0.38.0-33-gb759cac57"
55
- }
56
64
  }