UNPKG

asajs

Version:

Make your Minecraft JsonUI with ScriptingAPI

139 lines (138 loc) 4.17 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); var Config_exports = {}; __export(Config_exports, { Configs: () => Configs, config: () => config, readObject: () => readObject }); module.exports = __toCommonJS(Config_exports); var import_Save = require("./generator/Save"); var import_Object = require("./reader/Object"); var import_Template = require("./generator/Template"); (0, import_Template.firstRun)(); const defaultConfig = { compiler: { encodeJson: false, autoCompress: false, fileExtension: "json", UI: { nameLength: 32, namespaceAmount: 16, namespaceLength: 32, obfuscateName: false, obfuscateType: false } }, installer: { autoInstall: true, developEvironment: true, previewVersion: false, customPath: false, installPath: void 0 }, manifest: { name: "AsaJS", description: "Build with AsaJS <3", uuid: import_Save.Save.uuid()[0], version: [1, 0, 0], baseGameVersion: [1, 21, 80] } }; function readObject(obj, defaultObjValue) { if (Array.isArray(defaultObjValue)) { if (!obj) obj = []; defaultObjValue.forEach((value, index) => { var _a; obj[index] = (_a = obj[index]) != null ? _a : value; }); return obj; } else { if (!obj) obj = {}; import_Object.Obj.forEach(defaultObjValue || {}, (key, value) => { var _a; if (typeof value === "object") { obj[key] = readObject(obj[key], defaultObjValue[key]); } else { obj[key] = (_a = obj[key]) != null ? _a : defaultObjValue[key]; } }); return obj; } } const _Configs = class _Configs { /** * Loads the configuration file and parses it into the `save` property. */ constructor() { /** * The current loaded configuration saved to disk. */ __publicField(this, "save"); this.save = require("".concat(process.cwd(), "/asakiyuki.config.cjs")).config; } /** * Retrieves the current configuration, either from the saved configuration or the default values. * * @returns {Config} - The configuration object. */ static getConfig() { if (_Configs.config === void 0) { const defaultConfig2 = _Configs.getDefaultConfig(); const saveConfig = new _Configs().save; return readObject(saveConfig, defaultConfig2); } else return _Configs.config; } /** * Retrieves the default configuration values. * * @returns {Config} - The default configuration object. */ static getDefaultConfig() { return defaultConfig; } // Static helper methods not directly related to config loading/handling. static apply() { } static bind() { } static call() { } static toString() { } }; /** * The statically cached configuration. */ __publicField(_Configs, "config"); __publicField(_Configs, "arguments", ""); __publicField(_Configs, "caller", ""); __publicField(_Configs, "length", ""); __publicField(_Configs, "name", ""); let Configs = _Configs; const config = Configs; Configs.getConfig(); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Configs, config, readObject });