asajs 4.0.9 → 4.0.11-indev
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/config.d.ts +2 -1
- package/dist/js/compilers/Configuration.js +1 -0
- package/dist/js/compilers/PreCompile.js +2 -0
- package/dist/js/compilers/ui/buildcache.js +9 -6
- package/dist/js/compilers/ui/builder.js +13 -9
- package/dist/js/components/API.js +8 -0
- package/dist/js/index.js +1 -0
- package/dist/types/compilers/Configuration.d.ts +1 -0
- package/dist/types/compilers/PreCompile.d.ts +1 -1
- package/dist/types/components/API.d.ts +7 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +2 -2
package/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Variable } from "./src/types/properties/value.ts"
|
|
2
2
|
|
|
3
3
|
export interface RetBindingValue {
|
|
4
4
|
generate_bindings?: Array<{ source_property_name: string; target_property_name: string }>
|
|
@@ -13,6 +13,7 @@ export interface Config {
|
|
|
13
13
|
autoEnable?: boolean
|
|
14
14
|
gdkUserId?: string
|
|
15
15
|
fixInventoryItemRenderer?: boolean
|
|
16
|
+
buildFolder?: string
|
|
16
17
|
}
|
|
17
18
|
packinfo?: {
|
|
18
19
|
name?: string
|
|
@@ -49,6 +49,7 @@ export const config = createRequire(import.meta.url)(path.resolve(process.cwd(),
|
|
|
49
49
|
export const isBuildMode = options["build"] ?? config.compiler?.enabled ?? false;
|
|
50
50
|
export const isLinkMode = options["link"] ?? config.compiler?.autoImport ?? false;
|
|
51
51
|
export const unLinked = options["unlink"] ?? !(config.compiler?.autoImport ?? true);
|
|
52
|
+
export const buildFolder = config.compiler?.buildFolder || "build";
|
|
52
53
|
export const bindingFuntions = config.binding_functions;
|
|
53
54
|
if (!fs.existsSync(".gitignore")) {
|
|
54
55
|
fs.writeFileSync(".gitignore", `node_modules`, "utf-8");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "fs/promises";
|
|
2
|
+
import { buildFolder } from "../Configuration.js";
|
|
2
3
|
export class BuildCache {
|
|
3
4
|
static queue = Promise.resolve();
|
|
4
5
|
static async enqueue(task) {
|
|
@@ -11,7 +12,9 @@ export class BuildCache {
|
|
|
11
12
|
static async get(key) {
|
|
12
13
|
return this.enqueue(async () => {
|
|
13
14
|
try {
|
|
14
|
-
return await fs
|
|
15
|
+
return await fs
|
|
16
|
+
.readFile(`${buildFolder}/cache.json`, "utf-8")
|
|
17
|
+
.then(data => JSON.parse(data)[key] ?? null);
|
|
15
18
|
}
|
|
16
19
|
catch (error) {
|
|
17
20
|
return null;
|
|
@@ -27,26 +30,26 @@ export class BuildCache {
|
|
|
27
30
|
return this.enqueue(async () => {
|
|
28
31
|
let data = {};
|
|
29
32
|
try {
|
|
30
|
-
data = JSON.parse(await fs.readFile(
|
|
33
|
+
data = JSON.parse(await fs.readFile(`${buildFolder}/cache.json`, "utf-8"));
|
|
31
34
|
}
|
|
32
35
|
catch { }
|
|
33
36
|
if (key in data)
|
|
34
37
|
return data[key];
|
|
35
38
|
data[key] = outVal;
|
|
36
|
-
await fs.writeFile(
|
|
39
|
+
await fs.writeFile(`${buildFolder}/cache.json`, JSON.stringify(data), "utf-8");
|
|
37
40
|
return outVal;
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
43
|
static async set(key, value) {
|
|
41
44
|
return this.enqueue(async () => {
|
|
42
45
|
try {
|
|
43
|
-
return fs.writeFile(
|
|
44
|
-
...(await fs.readFile(
|
|
46
|
+
return fs.writeFile(`${buildFolder}/cache.json`, JSON.stringify({
|
|
47
|
+
...(await fs.readFile(`${buildFolder}/cache.json`, "utf-8").then(data => JSON.parse(data))),
|
|
45
48
|
[key]: value,
|
|
46
49
|
}), "utf-8");
|
|
47
50
|
}
|
|
48
51
|
catch (error) {
|
|
49
|
-
return fs.writeFile(
|
|
52
|
+
return fs.writeFile(`${buildFolder}/cache.json`, JSON.stringify({ [key]: value }), "utf-8");
|
|
50
53
|
}
|
|
51
54
|
});
|
|
52
55
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { config, isBuildMode, isLinkMode, isTestMode, unLinked } from "../Configuration.js";
|
|
1
|
+
import { buildFolder, config, isBuildMode, isLinkMode, isTestMode, unLinked } from "../Configuration.js";
|
|
2
2
|
import { Memory } from "../Memory.js";
|
|
3
3
|
import { createBuildFolder, gamePath, getBuildFolderName, linkToGame, unlink } from "./linker.js";
|
|
4
4
|
import { genManifest, version } from "./manifest.js";
|
|
@@ -7,6 +7,7 @@ import { BuildCache } from "./buildcache.js";
|
|
|
7
7
|
import { disableRSP, enableRSP } from "./installer.js";
|
|
8
8
|
import { Log } from "../PreCompile.js";
|
|
9
9
|
import path from "path";
|
|
10
|
+
import { API_events } from "../../components/API.js";
|
|
10
11
|
async function buildUI() {
|
|
11
12
|
const build = Memory.build();
|
|
12
13
|
build.set("ui/_ui_defs.json", {
|
|
@@ -15,7 +16,7 @@ async function buildUI() {
|
|
|
15
16
|
if (config.global_variables)
|
|
16
17
|
build.set("ui/_global_variables.json", config.global_variables);
|
|
17
18
|
const out = await Promise.all(Array.from(build.entries()).map(async ([file, value]) => {
|
|
18
|
-
const outFile =
|
|
19
|
+
const outFile = `${buildFolder}/${file}`;
|
|
19
20
|
await fs
|
|
20
21
|
.stat(outFile.split(/\\|\//g).slice(0, -1).join("/"))
|
|
21
22
|
.catch(async () => await fs.mkdir(outFile.split(/\\|\//g).slice(0, -1).join("/"), { recursive: true }));
|
|
@@ -30,17 +31,18 @@ async function buildUI() {
|
|
|
30
31
|
}));
|
|
31
32
|
await Promise.all([
|
|
32
33
|
fs
|
|
33
|
-
.writeFile(
|
|
34
|
-
.then(() => Log("INFO",
|
|
34
|
+
.writeFile(`${buildFolder}/manifest.json`, await genManifest(), "utf-8")
|
|
35
|
+
.then(() => Log("INFO", `${buildFolder}/manifest.json created!`)),
|
|
35
36
|
fs
|
|
36
|
-
.writeFile(
|
|
37
|
-
.then(() => Log("INFO",
|
|
37
|
+
.writeFile(`${buildFolder}/.gitignore`, [...out, "manifest.json"].join("\n"), "utf-8")
|
|
38
|
+
.then(() => Log("INFO", `${buildFolder}/.gitignore created!`)),
|
|
38
39
|
BuildCache.set("build-files", [...out, "manifest.json"]).then(() => Log("INFO", "build-files set!")),
|
|
39
40
|
BuildCache.set("version", version).then(() => Log("INFO", "version set!")),
|
|
40
41
|
fs
|
|
41
|
-
.stat(
|
|
42
|
-
.catch(() => fs.copyFile(isTestMode ? "resources/pack_icon.png" : "node_modules/asajs/resources/pack_icon.png",
|
|
43
|
-
.then(() => Log("INFO",
|
|
42
|
+
.stat(`${buildFolder}/pack_icon.png`)
|
|
43
|
+
.catch(() => fs.copyFile(isTestMode ? "resources/pack_icon.png" : "node_modules/asajs/resources/pack_icon.png", `${buildFolder}/pack_icon.png`))
|
|
44
|
+
.then(() => Log("INFO", `${buildFolder}/pack_icon.png copied!`))
|
|
45
|
+
.catch(() => Log("WARN", `cannot copy ${buildFolder}/pack_icon.png!`)),
|
|
44
46
|
]).catch(error => console.error(error));
|
|
45
47
|
return out.length;
|
|
46
48
|
}
|
|
@@ -66,6 +68,8 @@ if (isBuildMode) {
|
|
|
66
68
|
if (gamePath)
|
|
67
69
|
console.log("Install Path:", `\x1b[32m"${path.join(gamePath, "development_resource_packs", await getBuildFolderName())}"\x1b[0m`);
|
|
68
70
|
console.log("=============================================================");
|
|
71
|
+
// API events
|
|
72
|
+
API_events.onBuildFinish.forEach(v => v(config));
|
|
69
73
|
}
|
|
70
74
|
});
|
|
71
75
|
}
|
package/dist/js/index.js
CHANGED
|
@@ -11,3 +11,4 @@ export * as Properties from "./types/properties/index.js";
|
|
|
11
11
|
export { ItemAuxID } from "./types/enums/Items.js";
|
|
12
12
|
export { ArrayName, Operation } from "./types/properties/index.js";
|
|
13
13
|
export * from "./compilers/bindings/Binary.js";
|
|
14
|
+
export { API } from "./components/API.js";
|
|
@@ -4,4 +4,5 @@ export declare const config: Config;
|
|
|
4
4
|
export declare const isBuildMode: {};
|
|
5
5
|
export declare const isLinkMode: {};
|
|
6
6
|
export declare const unLinked: {};
|
|
7
|
+
export declare const buildFolder: string;
|
|
7
8
|
export declare const bindingFuntions: Record<string, (...args: string[]) => RetBindingValue> | undefined;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export * as Properties from "./types/properties/index.js";
|
|
|
11
11
|
export { ItemAuxID } from "./types/enums/Items.js";
|
|
12
12
|
export { ArrayName, Operation } from "./types/properties/index.js";
|
|
13
13
|
export * from "./compilers/bindings/Binary.js";
|
|
14
|
+
export { API } from "./components/API.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asajs",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.11-indev",
|
|
4
4
|
"description": "Create your Minecraft JSON-UI resource packs using JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Minecraft",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/asakiyuki/asajs.git"
|
|
16
16
|
},
|
|
17
|
-
"license": "
|
|
17
|
+
"license": "GPL-3.0-only",
|
|
18
18
|
"author": "Asaki Yuki",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"main": "dist/js/index.js",
|