cyclops-infobook-html 5.0.0 → 5.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.
- package/README.md +23 -2
- package/bin/compress-icons.d.ts +2 -0
- package/bin/compress-icons.js +47 -0
- package/bin/generate-icons.d.ts +2 -0
- package/bin/generate-icons.js +68 -0
- package/bin/generate-infobook-html.js +15 -7
- package/bin/generate-mod-metadata.js +15 -7
- package/index.d.ts +2 -0
- package/index.js +39 -24
- package/lib/icon/IconsCompressor.d.ts +18 -0
- package/lib/icon/IconsCompressor.js +81 -0
- package/lib/icon/IconsGenerator.d.ts +128 -0
- package/lib/icon/IconsGenerator.js +597 -0
- package/lib/infobook/FileWriter.d.ts +0 -1
- package/lib/infobook/FileWriter.js +11 -3
- package/lib/infobook/IFileWriter.d.ts +0 -1
- package/lib/infobook/InfoBookInitializer.js +10 -2
- package/lib/infobook/appendix/InfoBookAppendixAd.js +11 -3
- package/lib/infobook/appendix/InfoBookAppendixHandlerAbstractRecipe.js +11 -3
- package/lib/infobook/appendix/InfoBookAppendixHandlerAdvancementRewards.js +11 -3
- package/lib/infobook/appendix/InfoBookAppendixHandlerCraftingRecipe.js +11 -3
- package/lib/infobook/appendix/InfoBookAppendixHandlerImage.js +12 -4
- package/lib/infobook/appendix/InfoBookAppendixHandlerKeybinding.js +11 -3
- package/lib/infobook/appendix/InfoBookAppendixHandlerSmeltingRecipe.js +11 -3
- package/lib/infobook/appendix/InfoBookAppendixHandlerTextfield.js +10 -2
- package/lib/infobook/appendix/InfoBookAppendixTagIndex.js +11 -3
- package/lib/modloader/ModLoader.d.ts +2 -3
- package/lib/modloader/ModLoader.js +56 -48
- package/lib/parse/XmlInfoBookParser.js +1 -1
- package/lib/resource/ResourceHandler.js +1 -1
- package/lib/resource/ResourceLoader.js +28 -20
- package/lib/serialize/HtmlInfoBookSerializer.js +39 -31
- package/package.json +10 -6
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.ResourceLoader = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
13
|
const fs_1 = require("fs");
|
|
6
14
|
const path_1 = require("path");
|
|
7
15
|
const ResourceHandler_1 = require("./ResourceHandler");
|
|
@@ -24,10 +32,10 @@ class ResourceLoader {
|
|
|
24
32
|
* @returns {Promise<void>} A promise resolving when loading is done.
|
|
25
33
|
*/
|
|
26
34
|
loadIcons(iconsPath) {
|
|
27
|
-
return
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
36
|
const iconNames = yield fs_1.promises.readdir(iconsPath);
|
|
29
37
|
for (const iconName of iconNames) {
|
|
30
|
-
const iconFile = path_1.join(iconsPath, iconName);
|
|
38
|
+
const iconFile = (0, path_1.join)(iconsPath, iconName);
|
|
31
39
|
if (iconName.startsWith('fluid__')) {
|
|
32
40
|
this.resourceHandler.addFluidIcon(iconName.substring(7, iconName.length - 4), iconFile);
|
|
33
41
|
}
|
|
@@ -54,8 +62,8 @@ class ResourceLoader {
|
|
|
54
62
|
* @returns {Promise<void>} A promise resolving when loading is done.
|
|
55
63
|
*/
|
|
56
64
|
loadItemTranslationKeys(registriesPath) {
|
|
57
|
-
return
|
|
58
|
-
const registry = JSON.parse(fs_1.readFileSync(path_1.join(registriesPath, 'item_translation_keys.json'), "utf8"));
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const registry = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(registriesPath, 'item_translation_keys.json'), "utf8"));
|
|
59
67
|
for (const entry of registry.items) {
|
|
60
68
|
this.resourceHandler.addItemTranslationKey(entry.item, entry.translationKey);
|
|
61
69
|
}
|
|
@@ -67,8 +75,8 @@ class ResourceLoader {
|
|
|
67
75
|
* @returns {Promise<void>} A promise resolving when loading is done.
|
|
68
76
|
*/
|
|
69
77
|
loadFluidTranslationKeys(registriesPath) {
|
|
70
|
-
return
|
|
71
|
-
const registry = JSON.parse(fs_1.readFileSync(path_1.join(registriesPath, 'fluid_translation_keys.json'), "utf8"));
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const registry = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(registriesPath, 'fluid_translation_keys.json'), "utf8"));
|
|
72
80
|
for (const entry of registry.fluids) {
|
|
73
81
|
this.resourceHandler.addFluidTranslationKey(entry.fluid, entry.translationKey);
|
|
74
82
|
}
|
|
@@ -81,8 +89,8 @@ class ResourceLoader {
|
|
|
81
89
|
* @returns {Promise<void>} A promise resolving when loading is done.
|
|
82
90
|
*/
|
|
83
91
|
loadAll(baseDir, path, excludedModLanguages) {
|
|
84
|
-
return
|
|
85
|
-
yield this.load(path_1.join(baseDir, path), excludedModLanguages);
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
yield this.load((0, path_1.join)(baseDir, path), excludedModLanguages);
|
|
86
94
|
});
|
|
87
95
|
}
|
|
88
96
|
/**
|
|
@@ -94,12 +102,12 @@ class ResourceLoader {
|
|
|
94
102
|
* @returns {Promise<void>} A promise resolving when loading is done.
|
|
95
103
|
*/
|
|
96
104
|
load(fullPath, excludedModLanguages) {
|
|
97
|
-
return
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
106
|
const entries = yield fs_1.promises.readdir(fullPath);
|
|
99
107
|
// Look for a valid pack
|
|
100
108
|
for (const modid of entries) {
|
|
101
109
|
const excludedModLanguage = excludedModLanguages.includes(modid);
|
|
102
|
-
const modPath = path_1.join(fullPath, modid);
|
|
110
|
+
const modPath = (0, path_1.join)(fullPath, modid);
|
|
103
111
|
if ((yield fs_1.promises.stat(modPath)).isDirectory()) {
|
|
104
112
|
yield this.loadAssets(modid, modPath, excludedModLanguage);
|
|
105
113
|
}
|
|
@@ -113,11 +121,11 @@ class ResourceLoader {
|
|
|
113
121
|
* @returns {Promise<void>} A promise resolving when loading is done.
|
|
114
122
|
*/
|
|
115
123
|
loadAssets(modid, fullPath, excludedModLanguage) {
|
|
116
|
-
return
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
125
|
// Set base path
|
|
118
126
|
this.resourceHandler.setResourcePackBasePath(modid, fullPath);
|
|
119
127
|
// Handle languages
|
|
120
|
-
const langDir = path_1.join(fullPath, 'lang');
|
|
128
|
+
const langDir = (0, path_1.join)(fullPath, 'lang');
|
|
121
129
|
try {
|
|
122
130
|
if ((yield fs_1.promises.stat(langDir)).isDirectory()) {
|
|
123
131
|
yield this.loadAssetsLang(modid, langDir, excludedModLanguage);
|
|
@@ -127,7 +135,7 @@ class ResourceLoader {
|
|
|
127
135
|
// Ignore mods without language files
|
|
128
136
|
}
|
|
129
137
|
// Handle advancements
|
|
130
|
-
const advancementsDir = path_1.join(fullPath, 'advancement');
|
|
138
|
+
const advancementsDir = (0, path_1.join)(fullPath, 'advancement');
|
|
131
139
|
try {
|
|
132
140
|
if ((yield fs_1.promises.stat(langDir)).isDirectory()) {
|
|
133
141
|
yield this.loadAssetsAdvancements(modid, advancementsDir, '');
|
|
@@ -145,11 +153,11 @@ class ResourceLoader {
|
|
|
145
153
|
* @returns {Promise<void>} A promise resolving when loading is done.
|
|
146
154
|
*/
|
|
147
155
|
loadAssetsLang(modid, langDir, excludedModLanguage) {
|
|
148
|
-
return
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
157
|
const entries = yield fs_1.promises.readdir(langDir);
|
|
150
158
|
for (const entry of entries) {
|
|
151
159
|
const language = entry.substring(0, entry.indexOf('.'));
|
|
152
|
-
yield this.loadAssetsLangFile(modid, language, path_1.join(langDir, entry), excludedModLanguage);
|
|
160
|
+
yield this.loadAssetsLangFile(modid, language, (0, path_1.join)(langDir, entry), excludedModLanguage);
|
|
153
161
|
}
|
|
154
162
|
});
|
|
155
163
|
}
|
|
@@ -161,7 +169,7 @@ class ResourceLoader {
|
|
|
161
169
|
* @returns {Promise<void>} A promise resolving when loading is done.
|
|
162
170
|
*/
|
|
163
171
|
loadAssetsLangFile(modid, language, fullFilePath, excludedModLanguage) {
|
|
164
|
-
return
|
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
173
|
const translations = JSON.parse((yield fs_1.promises.readFile(fullFilePath)).toString('utf8'));
|
|
166
174
|
this.resourceHandler.addTranslations(language, translations, excludedModLanguage);
|
|
167
175
|
});
|
|
@@ -173,10 +181,10 @@ class ResourceLoader {
|
|
|
173
181
|
* @param {string} idPrefix The prefix to use for advancement id.
|
|
174
182
|
*/
|
|
175
183
|
loadAssetsAdvancements(modid, advancementsDir, idPrefix) {
|
|
176
|
-
return
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
177
185
|
const entries = yield fs_1.promises.readdir(advancementsDir);
|
|
178
186
|
for (const entry of entries) {
|
|
179
|
-
const entryFullPath = path_1.join(advancementsDir, entry);
|
|
187
|
+
const entryFullPath = (0, path_1.join)(advancementsDir, entry);
|
|
180
188
|
const entryId = idPrefix + '/' + entry;
|
|
181
189
|
if ((yield fs_1.promises.stat(entryFullPath)).isDirectory()) {
|
|
182
190
|
yield this.loadAssetsAdvancements(modid, entryFullPath, entryId);
|
|
@@ -194,7 +202,7 @@ class ResourceLoader {
|
|
|
194
202
|
* @param {string} id The id of the advancement.
|
|
195
203
|
*/
|
|
196
204
|
loadAssetsAdvancement(modid, advancementsFile, id) {
|
|
197
|
-
return
|
|
205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
206
|
const contents = JSON.parse((yield fs_1.promises.readFile(advancementsFile)).toString('utf8'));
|
|
199
207
|
const itemIcon = contents.display.icon;
|
|
200
208
|
const title = contents.display.title.translate;
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.HtmlInfoBookSerializer = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
13
|
const fs_1 = require("fs");
|
|
6
14
|
const mkdirp = require("mkdirp");
|
|
7
15
|
const ncp_1 = require("ncp");
|
|
@@ -15,20 +23,20 @@ const FileWriter_1 = require("../infobook/FileWriter");
|
|
|
15
23
|
*/
|
|
16
24
|
class HtmlInfoBookSerializer {
|
|
17
25
|
constructor() {
|
|
18
|
-
this.templateIndex = pug_1.compileFile(__dirname + '/../../template/index.pug');
|
|
19
|
-
this.templateSection = pug_1.compileFile(__dirname + '/../../template/section.pug');
|
|
20
|
-
this.appendixWrapper = pug_1.compileFile(__dirname + '/../../template/appendix/appendix_base.pug');
|
|
21
|
-
this.templateItem = pug_1.compileFile(__dirname + '/../../template/appendix/item.pug');
|
|
26
|
+
this.templateIndex = (0, pug_1.compileFile)(__dirname + '/../../template/index.pug');
|
|
27
|
+
this.templateSection = (0, pug_1.compileFile)(__dirname + '/../../template/section.pug');
|
|
28
|
+
this.appendixWrapper = (0, pug_1.compileFile)(__dirname + '/../../template/appendix/appendix_base.pug');
|
|
29
|
+
this.templateItem = (0, pug_1.compileFile)(__dirname + '/../../template/appendix/item.pug');
|
|
22
30
|
}
|
|
23
31
|
serialize(infobook, context, assetsPaths) {
|
|
24
|
-
return
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
33
|
context = Object.assign(Object.assign({}, context), { basePath: context.path, breadcrumbs: [] });
|
|
26
34
|
this.fileWriter = new FileWriter_1.FileWriter(context);
|
|
27
35
|
yield this.ensureDirExists(context.path);
|
|
28
|
-
yield this.ensureDirExists(path_1.join(context.path, 'assets'));
|
|
29
|
-
yield this.ensureDirExists(path_1.join(context.path, 'assets', '
|
|
36
|
+
yield this.ensureDirExists((0, path_1.join)(context.path, 'assets'));
|
|
37
|
+
yield this.ensureDirExists((0, path_1.join)(context.path, 'assets', 'icon'));
|
|
30
38
|
// Create a .nojekyll file to ensure _lang directories are served via GitHub pages.
|
|
31
|
-
yield fs_1.promises.writeFile(path_1.join(context.path, '.nojekyll'), '');
|
|
39
|
+
yield fs_1.promises.writeFile((0, path_1.join)(context.path, '.nojekyll'), '');
|
|
32
40
|
// Serialize sections in all languages
|
|
33
41
|
for (const language of context.resourceHandler.getLanguages()) {
|
|
34
42
|
const langPath = this.getLanguagePath(language, context.path);
|
|
@@ -37,21 +45,21 @@ class HtmlInfoBookSerializer {
|
|
|
37
45
|
yield this.serializeSectionFiles(infobook, context, language, langPath, sectionIndex);
|
|
38
46
|
}
|
|
39
47
|
// Serialize assets
|
|
40
|
-
yield util_1.promisify(ncp_1.ncp)(__dirname + '/../../assets/', path_1.join(context.path, 'assets'));
|
|
48
|
+
yield (0, util_1.promisify)(ncp_1.ncp)(__dirname + '/../../assets/', (0, path_1.join)(context.path, 'assets'));
|
|
41
49
|
for (const assetsPath of assetsPaths) {
|
|
42
|
-
yield util_1.promisify(ncp_1.ncp)(assetsPath, path_1.join(context.path, 'assets'));
|
|
50
|
+
yield (0, util_1.promisify)(ncp_1.ncp)(assetsPath, (0, path_1.join)(context.path, 'assets'));
|
|
43
51
|
}
|
|
44
52
|
});
|
|
45
53
|
}
|
|
46
54
|
serializeSectionIndex(infobook, contextRoot, language, langPath) {
|
|
47
|
-
return
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
56
|
const sectionIndex = {
|
|
49
57
|
linkedPagesList: [],
|
|
50
58
|
tags: {},
|
|
51
59
|
urlIndex: {},
|
|
52
60
|
};
|
|
53
61
|
let pageIndex = 0;
|
|
54
|
-
yield this.serializeSection(infobook.rootSection, Object.assign(Object.assign({}, contextRoot), { language, path: langPath }), (
|
|
62
|
+
yield this.serializeSection(infobook.rootSection, Object.assign(Object.assign({}, contextRoot), { language, path: langPath }), (_a) => __awaiter(this, [_a], void 0, function* ({ index, section, sectionTitle, fileUrl, breadcrumbs }) {
|
|
55
63
|
if (!index) {
|
|
56
64
|
sectionIndex.urlIndex[fileUrl] = pageIndex++;
|
|
57
65
|
const name = breadcrumbs.slice(1).map((b) => b.name).join(' / ');
|
|
@@ -68,13 +76,13 @@ class HtmlInfoBookSerializer {
|
|
|
68
76
|
});
|
|
69
77
|
}
|
|
70
78
|
serializeSectionFiles(infobook, contextRoot, language, langPath, sectionIndex) {
|
|
71
|
-
return
|
|
72
|
-
yield this.serializeSection(infobook.rootSection, Object.assign(Object.assign({}, contextRoot), { language, path: langPath, sectionIndex }), ({ index, breadcrumbs, context, section, sectionTitle, subSectionDatas, filePath, fileUrl })
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
yield this.serializeSection(infobook.rootSection, Object.assign(Object.assign({}, contextRoot), { language, path: langPath, sectionIndex }), (_a) => __awaiter(this, [_a], void 0, function* ({ index, breadcrumbs, context, section, sectionTitle, subSectionDatas, filePath, fileUrl }) {
|
|
73
81
|
// Create links to this page in other languages
|
|
74
82
|
const languages = [];
|
|
75
83
|
for (const name of contextRoot.resourceHandler.getLanguages()) {
|
|
76
|
-
const baseFilePath = filePath.substr(path_1.join(contextRoot.basePath, this.getLanguagePath(language)).length);
|
|
77
|
-
const languageFilePath = path_1.join(contextRoot.basePath, this.getLanguagePath(name), baseFilePath);
|
|
84
|
+
const baseFilePath = filePath.substr((0, path_1.join)(contextRoot.basePath, this.getLanguagePath(language)).length);
|
|
85
|
+
const languageFilePath = (0, path_1.join)(contextRoot.basePath, this.getLanguagePath(name), baseFilePath);
|
|
78
86
|
const url = this.filePathToUrl(languageFilePath, contextRoot.basePath, context.baseUrl);
|
|
79
87
|
languages.push({ name, url });
|
|
80
88
|
}
|
|
@@ -125,14 +133,14 @@ class HtmlInfoBookSerializer {
|
|
|
125
133
|
});
|
|
126
134
|
}
|
|
127
135
|
serializeSection(section, context, onSection) {
|
|
128
|
-
return
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
137
|
const sectionTitle = this.formatString(context.resourceHandler
|
|
130
138
|
.getTranslation(section.nameTranslationKey, context.language));
|
|
131
139
|
const breadcrumbs = context.breadcrumbs.concat([{ name: sectionTitle }]);
|
|
132
140
|
// Go in a subfolder when we are handling a different mod
|
|
133
141
|
if (section.modId !== context.modId) {
|
|
134
|
-
yield this.ensureDirExists(path_1.join(context.path, section.modId));
|
|
135
|
-
context = Object.assign(Object.assign({}, context), { modId: section.modId, path: path_1.join(context.path, section.modId) });
|
|
142
|
+
yield this.ensureDirExists((0, path_1.join)(context.path, section.modId));
|
|
143
|
+
context = Object.assign(Object.assign({}, context), { modId: section.modId, path: (0, path_1.join)(context.path, section.modId) });
|
|
136
144
|
}
|
|
137
145
|
if (section.subSections && section.subSections.length > 0) {
|
|
138
146
|
// Navigation section
|
|
@@ -144,11 +152,11 @@ class HtmlInfoBookSerializer {
|
|
|
144
152
|
url: fileUrl,
|
|
145
153
|
}]);
|
|
146
154
|
for (const subSection of section.subSections) {
|
|
147
|
-
const subSectionData = yield this.serializeSection(subSection, Object.assign(Object.assign({}, context), { breadcrumbs: subBreadcrumbs, path: path_1.join(context.path, subSection.nameTranslationKey
|
|
155
|
+
const subSectionData = yield this.serializeSection(subSection, Object.assign(Object.assign({}, context), { breadcrumbs: subBreadcrumbs, path: (0, path_1.join)(context.path, subSection.nameTranslationKey
|
|
148
156
|
.substr(subSection.nameTranslationKey.lastIndexOf('.') + 1)), root: false }), onSection);
|
|
149
157
|
subSectionDatas.push(Object.assign(Object.assign({}, subSectionData), { url: this.filePathToUrl(subSectionData.filePath, context.basePath, context.baseUrl) }));
|
|
150
158
|
}
|
|
151
|
-
const filePath = path_1.join(context.path, 'index.html');
|
|
159
|
+
const filePath = (0, path_1.join)(context.path, 'index.html');
|
|
152
160
|
yield onSection({ index: true, breadcrumbs, context, sectionTitle, section, subSectionDatas, filePath, fileUrl });
|
|
153
161
|
return { filePath: context.path, sectionTitle };
|
|
154
162
|
}
|
|
@@ -176,8 +184,8 @@ class HtmlInfoBookSerializer {
|
|
|
176
184
|
}
|
|
177
185
|
return { link, linkTarget };
|
|
178
186
|
}
|
|
179
|
-
createItemDisplay(
|
|
180
|
-
return
|
|
187
|
+
createItemDisplay(resourceHandler_1, context_1, fileWriter_1, item_1, slot_1) {
|
|
188
|
+
return __awaiter(this, arguments, void 0, function* (resourceHandler, context, fileWriter, item, slot, annotation = '') {
|
|
181
189
|
if (item.item === 'minecraft:air') {
|
|
182
190
|
return slot ? '<div class="item item-slot"> </div>' : '<div class="item"> </div>';
|
|
183
191
|
}
|
|
@@ -185,7 +193,7 @@ class HtmlInfoBookSerializer {
|
|
|
185
193
|
if (!icon) {
|
|
186
194
|
throw new Error(`Could not find an icon for item ${JSON.stringify(item)}`);
|
|
187
195
|
}
|
|
188
|
-
const iconUrl = yield fileWriter.write('
|
|
196
|
+
const iconUrl = yield fileWriter.write('icon/' + (0, path_1.basename)(icon), () => (0, fs_1.createReadStream)(icon));
|
|
189
197
|
const key = resourceHandler.getItemTranslationKey(item);
|
|
190
198
|
if (!key) {
|
|
191
199
|
throw new Error(`Could not find translation key for item ${JSON.stringify(item)}`);
|
|
@@ -196,12 +204,12 @@ class HtmlInfoBookSerializer {
|
|
|
196
204
|
});
|
|
197
205
|
}
|
|
198
206
|
createFluidDisplay(resourceHandler, context, fileWriter, fluid, slot) {
|
|
199
|
-
return
|
|
207
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
208
|
const icon = resourceHandler.getFluidIconFile(fluid.fluid);
|
|
201
209
|
if (!icon) {
|
|
202
210
|
throw new Error(`Could not find an icon for fluid ${JSON.stringify(fluid)}`);
|
|
203
211
|
}
|
|
204
|
-
const iconUrl = yield fileWriter.write('
|
|
212
|
+
const iconUrl = yield fileWriter.write('icon/' + (0, path_1.basename)(icon), () => (0, fs_1.createReadStream)(icon));
|
|
205
213
|
const key = resourceHandler.getFluidTranslationKey(fluid);
|
|
206
214
|
if (!key) {
|
|
207
215
|
throw new Error(`Could not find translation key for fluid ${JSON.stringify(fluid)}`);
|
|
@@ -216,7 +224,7 @@ class HtmlInfoBookSerializer {
|
|
|
216
224
|
}
|
|
217
225
|
getLanguagePath(language, path) {
|
|
218
226
|
path = path || '';
|
|
219
|
-
return language === 'en_us' ? path : path_1.join(path, '_lang', language);
|
|
227
|
+
return language === 'en_us' ? path : (0, path_1.join)(path, '_lang', language);
|
|
220
228
|
}
|
|
221
229
|
/**
|
|
222
230
|
* Convert Minecraft formatting codes to HTML formats.
|
|
@@ -255,13 +263,13 @@ class HtmlInfoBookSerializer {
|
|
|
255
263
|
return value;
|
|
256
264
|
}
|
|
257
265
|
ensureDirExists(dirPath) {
|
|
258
|
-
return
|
|
266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
259
267
|
let fstat;
|
|
260
268
|
try {
|
|
261
269
|
fstat = yield fs_1.promises.stat(dirPath);
|
|
262
270
|
}
|
|
263
271
|
catch (e) {
|
|
264
|
-
yield util_1.promisify(mkdirp)(dirPath);
|
|
272
|
+
yield (0, util_1.promisify)(mkdirp)(dirPath);
|
|
265
273
|
}
|
|
266
274
|
if (fstat && !fstat.isDirectory() && fstat.isFile()) {
|
|
267
275
|
throw new Error(`Could not serialize to a file, must be a directory.`);
|
|
@@ -270,7 +278,7 @@ class HtmlInfoBookSerializer {
|
|
|
270
278
|
}
|
|
271
279
|
filePathToUrl(filePath, basePath, baseUrl) {
|
|
272
280
|
let url = filePath.replace(basePath, baseUrl);
|
|
273
|
-
const last = path_1.basename(url);
|
|
281
|
+
const last = (0, path_1.basename)(url);
|
|
274
282
|
if (!url.endsWith('/') && last.indexOf('.') < 0) {
|
|
275
283
|
url = url + '/';
|
|
276
284
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cyclops-infobook-html",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Output Cyclops infobooks as HTML",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "git@github.com:CyclopsMC/infobook-html.git",
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"bin": {
|
|
14
14
|
"generate-cyclops-infobook-html": "bin/generate-infobook-html.js",
|
|
15
|
-
"generate-mod-metadata": "bin/generate-mod-metadata.js"
|
|
15
|
+
"generate-mod-metadata": "bin/generate-mod-metadata.js",
|
|
16
|
+
"generate-icons": "bin/generate-icons.js",
|
|
17
|
+
"compress-icons": "bin/compress-icons.js"
|
|
16
18
|
},
|
|
17
19
|
"files": [
|
|
18
20
|
"bin/**/*.d.ts",
|
|
@@ -50,16 +52,16 @@
|
|
|
50
52
|
"testEnvironment": "node"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
|
-
"@types/jest": "^
|
|
55
|
+
"@types/jest": "^30.0.0",
|
|
54
56
|
"@types/minimist": "^1.2.0",
|
|
55
57
|
"coveralls": "^3.0.3",
|
|
56
|
-
"jest": "^
|
|
58
|
+
"jest": "^30.0.0",
|
|
57
59
|
"manual-git-changelog": "^1.0.1",
|
|
58
60
|
"pre-commit": "^1.2.2",
|
|
59
|
-
"ts-jest": "^
|
|
61
|
+
"ts-jest": "^29.0.0",
|
|
60
62
|
"tslint": "^6.0.0",
|
|
61
63
|
"tslint-eslint-rules": "^5.4.0",
|
|
62
|
-
"typescript": "^
|
|
64
|
+
"typescript": "^5.0.0"
|
|
63
65
|
},
|
|
64
66
|
"scripts": {
|
|
65
67
|
"test": "jest ${1}",
|
|
@@ -81,9 +83,11 @@
|
|
|
81
83
|
"@types/rimraf": "^3.0.0",
|
|
82
84
|
"@types/xml2js": "^0.4.4",
|
|
83
85
|
"@types/yauzl": "^2.9.1",
|
|
86
|
+
"@types/minimist": "^1.2.0",
|
|
84
87
|
"minimist": "^1.2.0",
|
|
85
88
|
"mkdirp": "^0.5.1",
|
|
86
89
|
"mvn-artifact-download": "^5.0.0",
|
|
90
|
+
"optipng-bin": "^9.0.0",
|
|
87
91
|
"ncp": "^2.0.0",
|
|
88
92
|
"node-fetch": "^2.6.0",
|
|
89
93
|
"pug": "^3.0.0",
|