Skip to content
This repository was archived by the owner on Apr 18, 2022. It is now read-only.

Commit 224222f

Browse files
committed
Core ready
1 parent ca692f2 commit 224222f

11 files changed

Lines changed: 1561 additions & 22 deletions

File tree

app/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ var manager = new PluginManager_1.PluginManager();
3535
Preloader.start();
3636
console.log("installing plugins...");
3737
SiteAPI.loadSite({ host: "raw.githubusercontent.com", path: '/MinimineLP/mcscriptStudioCode/master/plugins/core-plugins.json', protocoll: 'https' }, function (ret) {
38-
console.log(ret);
3938
for (var _i = 0, _a = JSON.parse(ret); _i < _a.length; _i++) {
4039
var url = _a[_i];
4140
manager.installPlugin(url, datafolder + "/plugins");

app/src/css/preloader.min.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/scripts/Config.js

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
"use strict";
2+
exports.__esModule = true;
3+
var YAML = require("js-yaml");
4+
var fs = require("fs");
5+
var Config = /** @class */ (function () {
6+
function Config(file, parser) {
7+
if (parser === void 0) { parser = FileFormatters.Json; }
8+
if (typeof parser === "string")
9+
parser = FileFormatters.fromString(parser);
10+
this.parser = parser;
11+
this.file = file;
12+
if (!fs.existsSync(file)) {
13+
file = file.replace("\\", "/");
14+
var parts = file.split("/");
15+
for (var i = 1; i < parts.length; i++) {
16+
var path = "";
17+
for (var c = 0; c < i; c++)
18+
path += parts[c] + "/";
19+
if (!fs.existsSync(path))
20+
fs.mkdirSync(path);
21+
}
22+
fs.writeFileSync(file, "");
23+
}
24+
this.load();
25+
}
26+
Config.prototype.load = function (file, parser) {
27+
if (file === void 0) { file = this.file; }
28+
if (parser === void 0) { parser = this.parser; }
29+
if (typeof parser === "string")
30+
parser = FileFormatters.fromString(parser);
31+
this.content = parser.parse(fs.readFileSync(file, "utf8"));
32+
if (this.content == null)
33+
this.content = {};
34+
};
35+
Config.prototype.save = function (file, parser) {
36+
if (file === void 0) { file = this.file; }
37+
if (parser === void 0) { parser = this.parser; }
38+
if (typeof parser === "string")
39+
parser = FileFormatters.fromString(parser);
40+
fs.writeFileSync(file, parser.stringify(this.content));
41+
};
42+
Config.prototype.stringify = function (parser) {
43+
if (parser === void 0) { parser = this.parser; }
44+
if (typeof parser === "string")
45+
parser = FileFormatters.fromString(parser);
46+
return parser.stringify(this.content);
47+
};
48+
Config.prototype.contains = function (path, obj) {
49+
if (obj === void 0) { obj = this.content; }
50+
var parts = path.split(/\./g);
51+
var subparts = [];
52+
if (obj.hasOwnProperty(parts[0])) {
53+
for (var i = 1; i < parts.length; i++)
54+
subparts[i - 1] = parts[i];
55+
if (obj[parts[0]] instanceof Object)
56+
return this.contains(subparts.join("."), obj[parts[0]]);
57+
return true;
58+
}
59+
return false;
60+
};
61+
Config.prototype.get = function (path, obj) {
62+
if (obj === void 0) { obj = this.content; }
63+
if (this.contains(path, obj)) {
64+
var parts = path.split(/\./g);
65+
for (var i = 0; i < parts.length; i++) {
66+
obj = obj[parts[i]];
67+
}
68+
return obj;
69+
}
70+
else {
71+
console.log("Ooups... Trying to get empty path from Yaml: \"" + path + "\" Returning null!");
72+
return null;
73+
}
74+
};
75+
Config.prototype.set = function (path, val) {
76+
var parts = path.split(".");
77+
var obj = this.content;
78+
for (var i = 0; i < parts.length - 1; i++) {
79+
if (!obj[parts[i]] || !(obj[parts[i]] instanceof Object))
80+
obj[parts[i]] = {};
81+
obj = obj[parts[i]];
82+
}
83+
var cmd = "this.content." + path + " = val;";
84+
eval(cmd);
85+
};
86+
Config.prototype.remove = function (path) {
87+
var parts = path.split(".");
88+
var obj = this.content;
89+
for (var i = 0; i < parts.length - 1; i++) {
90+
if (!obj[parts[i]] || !(obj[parts[i]] instanceof Object))
91+
obj[parts[i]] = {};
92+
obj = obj[parts[i]];
93+
}
94+
var cmd = 'delete this.content."' + path + ";";
95+
eval(cmd);
96+
};
97+
Config.prototype.setStandart = function (path, val) {
98+
if (!this.contains(path))
99+
this.set(path, val);
100+
};
101+
Config.prototype.concat = function (obj) {
102+
var _this = this;
103+
if (obj instanceof Config) {
104+
obj.list().forEach(function (e) {
105+
if (!_this.contains(e))
106+
_this.set(e, obj.get(e));
107+
});
108+
}
109+
else {
110+
this.list(obj).forEach(function (e) {
111+
if (!_this.contains(e))
112+
_this.set(e, _this.get(e, obj));
113+
});
114+
}
115+
};
116+
Config.prototype.apply = function (obj) {
117+
var _this = this;
118+
if (obj instanceof Config) {
119+
obj.list().forEach(function (e) {
120+
_this.set(e, obj.get(e));
121+
});
122+
}
123+
else {
124+
this.list(obj).forEach(function (e) {
125+
_this.set(e, _this.get(e, obj));
126+
});
127+
}
128+
};
129+
Config.prototype.list = function (obj) {
130+
var _this = this;
131+
if (obj === void 0) { obj = this.content; }
132+
var keys = Object.keys(obj);
133+
var ret = [];
134+
keys.forEach(function (e) {
135+
if (obj[e] instanceof Object) {
136+
_this.list(obj[e]).forEach(function (v) {
137+
ret.push(e + "." + v);
138+
});
139+
}
140+
else
141+
ret.push(e);
142+
});
143+
return ret;
144+
};
145+
return Config;
146+
}());
147+
exports.Config = Config;
148+
var FileFormatters;
149+
(function (FileFormatters) {
150+
var JSONFormatter = /** @class */ (function () {
151+
function JSONFormatter() {
152+
this.stringify = JSON.stringify;
153+
this.parse = JSON.parse;
154+
}
155+
return JSONFormatter;
156+
}());
157+
var YAMLFormatter = /** @class */ (function () {
158+
function YAMLFormatter() {
159+
this.stringify = YAML.safeDump;
160+
this.parse = YAML.safeLoad;
161+
}
162+
return YAMLFormatter;
163+
}());
164+
FileFormatters.Json = new JSONFormatter();
165+
FileFormatters.Yaml = new YAMLFormatter();
166+
function fromString(from) {
167+
from = from.toLowerCase();
168+
if (from == "json")
169+
return this.Json;
170+
else if (from == "yaml")
171+
return this.Yaml;
172+
else
173+
return null;
174+
}
175+
FileFormatters.fromString = fromString;
176+
})(FileFormatters || (FileFormatters = {}));
177+
exports.FileFormatters = FileFormatters;
178+
var config = new Config("config.yml", FileFormatters.Yaml);
179+
exports.config = config;
180+
loadConfig();
181+
function loadConfig() {
182+
config.load();
183+
config.save();
184+
}
185+
global.FileFormatters = FileFormatters;
186+
global.Config = Config;
187+
global.config = config;
188+
exports["default"] = config;

app/src/scripts/Console.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)