@run-slicer/jdc 0.1.0

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.
Files changed (6) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE-JDC +675 -0
  3. package/README.md +35 -0
  4. package/jdc.d.ts +9 -0
  5. package/jdc.js +162793 -0
  6. package/package.json +16 -0
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # jdc
2
+
3
+ A JavaScript port of the [JD-Core](https://github.com/java-decompiler/jd-core) decompiler.
4
+
5
+ ## Example
6
+
7
+ ```js
8
+ const fs = require("fs");
9
+ const { decompile } = require("./jdc.js"); // get it from the dist/ directory or jsDelivr
10
+
11
+ const data = fs.readFileSync("./your/package/HelloWorld.class"); // read a class file
12
+ console.log(await decompile("your/package/HelloWorld", {
13
+ source: async (name) => {
14
+ /* provide classes for analysis here, including the one you want to decompile */
15
+
16
+ console.log(name); /* internal name, e.g. java/lang/Object */
17
+ return name === "your/package/HelloWorld" ? data : null /* class not available */;
18
+ },
19
+ resources: [
20
+ /* class names of supporting resources (libraries), which `source` can load */
21
+ // "java/lang/Object",
22
+ ],
23
+ indent: " ", // indentation string
24
+ }));
25
+ ```
26
+
27
+ Or see the browser-based proof-of-concept in the [docs](./docs) directory.
28
+
29
+ ## Licensing
30
+
31
+ The supporting code for this project is licensed under the MIT License
32
+ ([supporting code](./LICENSE). The JD-Core decompiler is licensed under the
33
+ [GNU General Public License, Version 3](./LICENSE-JDC).
34
+
35
+ _This project is not affiliated with, maintained or endorsed by the JD-Core project in any way. Do NOT report issues with this project to the JD-Core issue trackers._
package/jdc.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ declare module "@run-slicer/jdc" {
2
+ export interface Config {
3
+ source?: (name: string) => Promise<Uint8Array | null>;
4
+ resources?: string[];
5
+ indent?: string;
6
+ }
7
+
8
+ export function decompile(name: string, config?: Config): Promise<string>;
9
+ }