cyclops-infobook-html 5.1.0 → 5.2.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 (52) hide show
  1. package/README.md +12 -12
  2. package/bin/compress-icons.js +42 -7
  3. package/bin/convert-pom-to-modpack.d.ts +2 -0
  4. package/bin/convert-pom-to-modpack.js +96 -0
  5. package/bin/generate-icons.js +50 -15
  6. package/bin/generate-infobook-html.js +46 -10
  7. package/bin/generate-mod-metadata.js +52 -14
  8. package/index.d.ts +25 -25
  9. package/lib/icon/IconsCompressor.js +43 -12
  10. package/lib/icon/IconsGenerator.d.ts +42 -20
  11. package/lib/icon/IconsGenerator.js +156 -70
  12. package/lib/infobook/FileWriter.d.ts +3 -3
  13. package/lib/infobook/FileWriter.js +5 -5
  14. package/lib/infobook/IFileWriter.d.ts +2 -2
  15. package/lib/infobook/IInfoAppendix.d.ts +3 -3
  16. package/lib/infobook/IInfoBook.d.ts +2 -4
  17. package/lib/infobook/IInfoSection.d.ts +1 -1
  18. package/lib/infobook/IInfobookPlugin.d.ts +5 -5
  19. package/lib/infobook/InfoBookInitializer.d.ts +7 -9
  20. package/lib/infobook/InfoBookInitializer.js +1 -1
  21. package/lib/infobook/appendix/IInfoBookAppendixHandler.d.ts +2 -2
  22. package/lib/infobook/appendix/InfoBookAppendixAd.d.ts +3 -3
  23. package/lib/infobook/appendix/InfoBookAppendixAd.js +7 -2
  24. package/lib/infobook/appendix/InfoBookAppendixHandlerAbstractRecipe.d.ts +12 -14
  25. package/lib/infobook/appendix/InfoBookAppendixHandlerAbstractRecipe.js +41 -8
  26. package/lib/infobook/appendix/InfoBookAppendixHandlerAdvancementRewards.d.ts +3 -3
  27. package/lib/infobook/appendix/InfoBookAppendixHandlerAdvancementRewards.js +5 -4
  28. package/lib/infobook/appendix/InfoBookAppendixHandlerCraftingRecipe.d.ts +6 -5
  29. package/lib/infobook/appendix/InfoBookAppendixHandlerCraftingRecipe.js +4 -3
  30. package/lib/infobook/appendix/InfoBookAppendixHandlerImage.d.ts +3 -3
  31. package/lib/infobook/appendix/InfoBookAppendixHandlerImage.js +4 -4
  32. package/lib/infobook/appendix/InfoBookAppendixHandlerKeybinding.d.ts +3 -3
  33. package/lib/infobook/appendix/InfoBookAppendixHandlerKeybinding.js +3 -2
  34. package/lib/infobook/appendix/InfoBookAppendixHandlerSmeltingRecipe.d.ts +6 -5
  35. package/lib/infobook/appendix/InfoBookAppendixHandlerSmeltingRecipe.js +3 -2
  36. package/lib/infobook/appendix/InfoBookAppendixHandlerTextfield.d.ts +3 -3
  37. package/lib/infobook/appendix/InfoBookAppendixHandlerTextfield.js +4 -5
  38. package/lib/infobook/appendix/InfoBookAppendixTagIndex.d.ts +4 -4
  39. package/lib/infobook/appendix/InfoBookAppendixTagIndex.js +2 -1
  40. package/lib/modloader/ModLoader.d.ts +13 -2
  41. package/lib/modloader/ModLoader.js +164 -69
  42. package/lib/modloader/PomConverter.d.ts +19 -0
  43. package/lib/modloader/PomConverter.js +138 -0
  44. package/lib/parse/XmlInfoBookParser.d.ts +5 -7
  45. package/lib/parse/XmlInfoBookParser.js +42 -9
  46. package/lib/resource/ResourceHandler.d.ts +7 -13
  47. package/lib/resource/ResourceHandler.js +16 -11
  48. package/lib/resource/ResourceLoader.d.ts +4 -5
  49. package/lib/resource/ResourceLoader.js +35 -33
  50. package/lib/serialize/HtmlInfoBookSerializer.d.ts +10 -16
  51. package/lib/serialize/HtmlInfoBookSerializer.js +83 -80
  52. package/package.json +33 -27
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.FileWriter = void 0;
13
- const fs_1 = require("fs");
14
- const path_1 = require("path");
13
+ const node_fs_1 = require("node:fs");
14
+ const node_path_1 = require("node:path");
15
15
  /**
16
16
  * A context-based {@link IFileWriter}.
17
17
  */
@@ -24,14 +24,14 @@ class FileWriter {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  // Don't write the file if it has been written before
26
26
  if (!this.writtenFiles[baseName]) {
27
- const eventEmitter = contents().pipe((0, fs_1.createWriteStream)((0, path_1.join)(this.context.basePath, 'assets', baseName)));
27
+ const eventEmitter = contents().pipe((0, node_fs_1.createWriteStream)((0, node_path_1.join)(this.context.basePath, 'assets', baseName)));
28
28
  this.writtenFiles[baseName] = true;
29
29
  yield new Promise((resolve, reject) => {
30
- eventEmitter.on('finish', resolve);
30
+ eventEmitter.on('finish', () => resolve());
31
31
  eventEmitter.on('error', reject);
32
32
  });
33
33
  }
34
- return this.context.baseUrl + 'assets/' + baseName;
34
+ return `${this.context.baseUrl}assets/${baseName}`;
35
35
  });
36
36
  }
37
37
  }
@@ -1,4 +1,4 @@
1
- import { Readable } from "stream";
1
+ import type { Readable } from 'node:stream';
2
2
  /**
3
3
  * Allows auxiliary files to be written to the output.
4
4
  */
@@ -9,5 +9,5 @@ export interface IFileWriter {
9
9
  * @param {"stream".internal.Readable} contents A stream of contents to write.
10
10
  * @returns {string} The file path in the output, relative to the output root.
11
11
  */
12
- write(baseName: string, contents: () => Readable): Promise<string>;
12
+ write: (baseName: string, contents: () => Readable) => Promise<string>;
13
13
  }
@@ -1,5 +1,5 @@
1
- import { HtmlInfoBookSerializer, ISerializeContext } from "../serialize/HtmlInfoBookSerializer";
2
- import { IFileWriter } from "./IFileWriter";
1
+ import type { HtmlInfoBookSerializer, ISerializeContext } from '../serialize/HtmlInfoBookSerializer';
2
+ import type { IFileWriter } from './IFileWriter';
3
3
  /**
4
4
  * Datastructure for an info book appendix.
5
5
  */
@@ -19,5 +19,5 @@ export interface IInfoAppendix {
19
19
  * @param serializer The HTML serializer.
20
20
  * @returns {string} The HTML representation of this appendix.
21
21
  */
22
- toHtml(context: ISerializeContext, fileWriter: IFileWriter, serializer: HtmlInfoBookSerializer): Promise<string>;
22
+ toHtml: (context: ISerializeContext, fileWriter: IFileWriter, serializer: HtmlInfoBookSerializer) => Promise<string>;
23
23
  }
@@ -1,7 +1,5 @@
1
- import { IInfoSection } from "./IInfoSection";
1
+ import type { IInfoSection } from './IInfoSection';
2
2
  export interface IInfoBook {
3
3
  rootSection: IInfoSection;
4
- sections: {
5
- [id: string]: IInfoSection;
6
- };
4
+ sections: Record<string, IInfoSection>;
7
5
  }
@@ -1,4 +1,4 @@
1
- import { IInfoAppendix } from "./IInfoAppendix";
1
+ import type { IInfoAppendix } from './IInfoAppendix';
2
2
  /**
3
3
  * Datastructure for an info book section.
4
4
  */
@@ -1,6 +1,6 @@
1
- import { ResourceLoader } from "../resource/ResourceLoader";
2
- import { ISerializeContext } from "../serialize/HtmlInfoBookSerializer";
3
- import { InfoBookInitializer } from "./InfoBookInitializer";
1
+ import type { ResourceLoader } from '../resource/ResourceLoader';
2
+ import type { ISerializeContext } from '../serialize/HtmlInfoBookSerializer';
3
+ import type { InfoBookInitializer } from './InfoBookInitializer';
4
4
  /**
5
5
  * A plugin for infobook loading.
6
6
  */
@@ -15,10 +15,10 @@ export interface IInfobookPlugin {
15
15
  * @param {ResourceLoader} resourceLoader The resource loader,
16
16
  * @param config The config object that was loaded.
17
17
  */
18
- load(infoBookInitializer: InfoBookInitializer, resourceLoader: ResourceLoader, config: any): void;
18
+ load: (infoBookInitializer: InfoBookInitializer, resourceLoader: ResourceLoader, config: any) => void;
19
19
  /**
20
20
  * An optional method for adding a string to the <head> tag.
21
21
  * @param {ISerializeContext} context The serialization context.
22
22
  */
23
- getHeadSuffix?(context: ISerializeContext): string;
23
+ getHeadSuffix?: (context: ISerializeContext) => string;
24
24
  }
@@ -1,6 +1,6 @@
1
- import { ResourceHandler } from "../resource/ResourceHandler";
2
- import { IInfoBookAppendixHandler } from "./appendix/IInfoBookAppendixHandler";
3
- import { IInfoBook } from "./IInfoBook";
1
+ import type { ResourceHandler } from '../resource/ResourceHandler';
2
+ import type { IInfoBookAppendixHandler } from './appendix/IInfoBookAppendixHandler';
3
+ import type { IInfoBook } from './IInfoBook';
4
4
  /**
5
5
  * InfoBookInitializer is a datastructure for holding information on an info book so that it can be constructed.
6
6
  */
@@ -22,10 +22,8 @@ export interface IInfoBookArgs {
22
22
  modId: string;
23
23
  sectionsFile: string;
24
24
  resources: string[];
25
- injectSections?: {
26
- [targetSection: string]: {
27
- sectionsFile: string;
28
- modId: string;
29
- }[];
30
- };
25
+ injectSections?: Record<string, {
26
+ sectionsFile: string;
27
+ modId: string;
28
+ }[]>;
31
29
  }
@@ -47,7 +47,7 @@ class InfoBookInitializer {
47
47
  }
48
48
  }
49
49
  // Create tag index section
50
- const nameTranslationKey = 'info_book.' + this.modId + '.tag_index';
50
+ const nameTranslationKey = `info_book.${this.modId}.tag_index`;
51
51
  const indexSection = {
52
52
  appendix: [new InfoBookAppendixTagIndex_1.InfoBookAppendixTagIndex(resourceHandler)],
53
53
  modId: this.modId,
@@ -1,4 +1,4 @@
1
- import { IInfoAppendix } from "../IInfoAppendix";
1
+ import type { IInfoAppendix } from '../IInfoAppendix';
2
2
  /**
3
3
  * Creates appendices of a specific type.
4
4
  */
@@ -9,5 +9,5 @@ export interface IInfoBookAppendixHandler {
9
9
  * @param {string} modId The owning mod.
10
10
  * @returns {IInfoAppendix} A new appendix instance.
11
11
  */
12
- createAppendix(data: any, modId: string): IInfoAppendix;
12
+ createAppendix: (data: any, modId: string) => IInfoAppendix;
13
13
  }
@@ -1,6 +1,6 @@
1
- import { HtmlInfoBookSerializer, ISerializeContext } from "../../serialize/HtmlInfoBookSerializer";
2
- import { IFileWriter } from "../IFileWriter";
3
- import { IInfoAppendix } from "../IInfoAppendix";
1
+ import type { HtmlInfoBookSerializer, ISerializeContext } from '../../serialize/HtmlInfoBookSerializer';
2
+ import type { IFileWriter } from '../IFileWriter';
3
+ import type { IInfoAppendix } from '../IInfoAppendix';
4
4
  /**
5
5
  * An appendix with an add
6
6
  */
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.InfoBookAppendixAd = void 0;
13
+ const node_path_1 = require("node:path");
13
14
  const pug_1 = require("pug");
14
15
  /**
15
16
  * An appendix with an add
@@ -17,9 +18,13 @@ const pug_1 = require("pug");
17
18
  class InfoBookAppendixAd {
18
19
  constructor() {
19
20
  this.skipWrapper = true;
20
- this.templateTagIndex = (0, pug_1.compileFile)(__dirname + '/../../../template/appendix/ad.pug');
21
+ this.templateTagIndex = (0, pug_1.compileFile)((0, node_path_1.join)(__dirname, '..', '..', '..', 'template', 'appendix', 'ad.pug'));
21
22
  }
22
- toHtml(context, fileWriter, serializer) {
23
+ toHtml(context,
24
+ // eslint-disable-next-line unused-imports/no-unused-vars
25
+ fileWriter,
26
+ // eslint-disable-next-line unused-imports/no-unused-vars
27
+ serializer) {
23
28
  return __awaiter(this, void 0, void 0, function* () {
24
29
  return this.templateTagIndex(context.googleAdsense);
25
30
  });
@@ -1,27 +1,25 @@
1
- import { ResourceHandler } from "../../resource/ResourceHandler";
2
- import { HtmlInfoBookSerializer, ISerializeContext } from "../../serialize/HtmlInfoBookSerializer";
3
- import { IFileWriter } from "../IFileWriter";
4
- import { IInfoAppendix } from "../IInfoAppendix";
5
- import { IInfoBookAppendixHandler } from "./IInfoBookAppendixHandler";
1
+ import type { ResourceHandler } from '../../resource/ResourceHandler';
2
+ import type { HtmlInfoBookSerializer, ISerializeContext } from '../../serialize/HtmlInfoBookSerializer';
3
+ import type { IFileWriter } from '../IFileWriter';
4
+ import type { IInfoAppendix } from '../IInfoAppendix';
5
+ import type { IInfoBookAppendixHandler } from './IInfoBookAppendixHandler';
6
6
  /**
7
7
  * Handles abstract recipe appendices.
8
8
  */
9
- export declare abstract class InfoBookAppendixHandlerAbstractRecipe<R extends IRecipe> implements IInfoBookAppendixHandler {
9
+ export declare abstract class InfoBookAppendixHandlerAbstractRecipe<TR extends IRecipe> implements IInfoBookAppendixHandler {
10
10
  protected readonly id: string;
11
11
  protected readonly resourceHandler: ResourceHandler;
12
- protected readonly registry: IRecipeRegistryIndexed<R>;
12
+ protected readonly registry: IRecipeRegistryIndexed<TR>;
13
13
  constructor(id: string, resourceHandler: ResourceHandler, registriesPath: string, recipeOverrides: any);
14
- static indexRegistry<R extends IRecipe>(registryRead: IRecipeRegistryRead<R>): IRecipeRegistryIndexed<R>;
14
+ static indexRegistry<TR extends IRecipe>(registryRead: IRecipeRegistryRead<TR>): IRecipeRegistryIndexed<TR>;
15
15
  createAppendix(data: any): IInfoAppendix;
16
16
  protected abstract getRecipeNameUnlocalized(): string;
17
- protected abstract serializeRecipe(recipe: R, context: ISerializeContext, fileWriter: IFileWriter, serializer: HtmlInfoBookSerializer): Promise<string>;
17
+ protected abstract serializeRecipe(recipe: TR, context: ISerializeContext, fileWriter: IFileWriter, serializer: HtmlInfoBookSerializer): Promise<string>;
18
18
  }
19
- export interface IRecipeRegistryRead<R extends IRecipe> {
20
- recipes: [R];
21
- }
22
- export interface IRecipeRegistryIndexed<R extends IRecipe> {
23
- [id: string]: R;
19
+ export interface IRecipeRegistryRead<TR extends IRecipe> {
20
+ recipes: [TR];
24
21
  }
22
+ export type IRecipeRegistryIndexed<TR extends IRecipe> = Record<string, TR>;
25
23
  export interface IRecipe {
26
24
  id: string;
27
25
  }
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -10,8 +43,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
43
  };
11
44
  Object.defineProperty(exports, "__esModule", { value: true });
12
45
  exports.InfoBookAppendixHandlerAbstractRecipe = void 0;
13
- const fs = require("fs");
14
- const path_1 = require("path");
46
+ const fs = __importStar(require("node:fs"));
47
+ const node_path_1 = require("node:path");
15
48
  /**
16
49
  * Handles abstract recipe appendices.
17
50
  */
@@ -19,9 +52,9 @@ class InfoBookAppendixHandlerAbstractRecipe {
19
52
  constructor(id, resourceHandler, registriesPath, recipeOverrides) {
20
53
  this.id = id;
21
54
  this.resourceHandler = resourceHandler;
22
- this.registry = InfoBookAppendixHandlerAbstractRecipe.indexRegistry(JSON.parse(fs.readFileSync((0, path_1.join)(registriesPath, id.replace(/:/g, '__') + '.json'), "utf8")));
55
+ this.registry = InfoBookAppendixHandlerAbstractRecipe.indexRegistry(JSON.parse(fs.readFileSync((0, node_path_1.join)(registriesPath, `${id.replaceAll(':', '__')}.json`), 'utf8')));
23
56
  if (recipeOverrides) {
24
- this.registry = Object.assign(Object.assign({}, this.registry), (recipeOverrides[id] || {}));
57
+ this.registry = Object.assign(Object.assign({}, this.registry), recipeOverrides[id]);
25
58
  }
26
59
  }
27
60
  static indexRegistry(registryRead) {
@@ -35,9 +68,9 @@ class InfoBookAppendixHandlerAbstractRecipe {
35
68
  const recipeId = data._;
36
69
  let recipes = [];
37
70
  if (recipeId.includes('*')) {
38
- const recipeRegex = new RegExp(recipeId);
71
+ const recipeRegex = new RegExp(recipeId, 'u');
39
72
  for (const [k, v] of Object.entries(this.registry)) {
40
- if (recipeRegex.exec(k)) {
73
+ if (recipeRegex.test(k)) {
41
74
  recipes.push(v);
42
75
  }
43
76
  }
@@ -49,9 +82,9 @@ class InfoBookAppendixHandlerAbstractRecipe {
49
82
  throw new Error(`Could not find ${this.id} recipe for ${recipeId}`);
50
83
  }
51
84
  return {
52
- getName: (context) => this.resourceHandler.getTranslation(this.getRecipeNameUnlocalized(), context.language),
85
+ getName: context => this.resourceHandler.getTranslation(this.getRecipeNameUnlocalized(), context.language),
53
86
  toHtml: (context, fileWriter, serializer) => __awaiter(this, void 0, void 0, function* () {
54
- return (yield Promise.all(recipes.map((recipe) => this.serializeRecipe(recipe, context, fileWriter, serializer)))).join('<hr />');
87
+ return (yield Promise.all(recipes.map(recipe => this.serializeRecipe(recipe, context, fileWriter, serializer)))).join('<hr />');
55
88
  }),
56
89
  };
57
90
  }
@@ -1,6 +1,6 @@
1
- import { ResourceHandler } from "../../resource/ResourceHandler";
2
- import { IInfoAppendix } from "../IInfoAppendix";
3
- import { IInfoBookAppendixHandler } from "./IInfoBookAppendixHandler";
1
+ import type { ResourceHandler } from '../../resource/ResourceHandler';
2
+ import type { IInfoAppendix } from '../IInfoAppendix';
3
+ import type { IInfoBookAppendixHandler } from './IInfoBookAppendixHandler';
4
4
  /**
5
5
  * Handles advancement rewards appendices.
6
6
  */
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.InfoBookAppendixHandlerAdvancementRewards = void 0;
13
+ const node_path_1 = require("node:path");
13
14
  const pug_1 = require("pug");
14
15
  /**
15
16
  * Handles advancement rewards appendices.
@@ -17,7 +18,7 @@ const pug_1 = require("pug");
17
18
  class InfoBookAppendixHandlerAdvancementRewards {
18
19
  constructor(resourceHandler) {
19
20
  this.resourceHandler = resourceHandler;
20
- this.templateAdvancementRewards = (0, pug_1.compileFile)(__dirname + '/../../../template/appendix/advancement_rewards.pug');
21
+ this.templateAdvancementRewards = (0, pug_1.compileFile)((0, node_path_1.join)(__dirname, '..', '..', '..', 'template', 'appendix', 'advancement_rewards.pug'));
21
22
  }
22
23
  createAppendix(data) {
23
24
  const advancementsData = [];
@@ -34,15 +35,15 @@ class InfoBookAppendixHandlerAdvancementRewards {
34
35
  rewardsData.push({ item: rewardTag._, count });
35
36
  }
36
37
  return {
37
- getName: (context) => this.resourceHandler.getTranslation('gui.advancements', context.language),
38
+ getName: context => this.resourceHandler.getTranslation('gui.advancements', context.language),
38
39
  toHtml: (context, fileWriter, serializer) => __awaiter(this, void 0, void 0, function* () {
39
40
  const advancements = advancementsData
40
- .map((advancement) => ({
41
+ .map(advancement => ({
41
42
  description: this.resourceHandler.getTranslation(advancement.description, context.language),
42
43
  title: this.resourceHandler.getTranslation(advancement.title, context.language),
43
44
  }));
44
45
  const rewards = yield Promise.all(rewardsData
45
- .map((reward) => serializer.createItemDisplay(this.resourceHandler, context, fileWriter, reward, true)));
46
+ .map(reward => serializer.createItemDisplay(this.resourceHandler, context, fileWriter, reward, true)));
46
47
  const rewardsString = this.resourceHandler.getTranslation(`gui.cyclopscore.rewards`, context.language);
47
48
  return this.templateAdvancementRewards({ advancements, rewards, rewardsString });
48
49
  }),
@@ -1,8 +1,9 @@
1
- import { ResourceHandler } from "../../resource/ResourceHandler";
2
- import { HtmlInfoBookSerializer, ISerializeContext } from "../../serialize/HtmlInfoBookSerializer";
3
- import { IFileWriter } from "../IFileWriter";
4
- import { IItem } from "../IItem";
5
- import { InfoBookAppendixHandlerAbstractRecipe, IRecipe } from "./InfoBookAppendixHandlerAbstractRecipe";
1
+ import type { ResourceHandler } from '../../resource/ResourceHandler';
2
+ import type { HtmlInfoBookSerializer, ISerializeContext } from '../../serialize/HtmlInfoBookSerializer';
3
+ import type { IFileWriter } from '../IFileWriter';
4
+ import type { IItem } from '../IItem';
5
+ import type { IRecipe } from './InfoBookAppendixHandlerAbstractRecipe';
6
+ import { InfoBookAppendixHandlerAbstractRecipe } from './InfoBookAppendixHandlerAbstractRecipe';
6
7
  /**
7
8
  * Handles crafting recipe appendices.
8
9
  */
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.InfoBookAppendixHandlerCraftingRecipe = void 0;
13
+ const node_path_1 = require("node:path");
13
14
  const pug_1 = require("pug");
14
15
  const InfoBookAppendixHandlerAbstractRecipe_1 = require("./InfoBookAppendixHandlerAbstractRecipe");
15
16
  /**
@@ -18,7 +19,7 @@ const InfoBookAppendixHandlerAbstractRecipe_1 = require("./InfoBookAppendixHandl
18
19
  class InfoBookAppendixHandlerCraftingRecipe extends InfoBookAppendixHandlerAbstractRecipe_1.InfoBookAppendixHandlerAbstractRecipe {
19
20
  constructor(resourceHandler, registriesPath, recipeOverrides) {
20
21
  super('minecraft:crafting', resourceHandler, registriesPath, recipeOverrides);
21
- this.templateCraftingRecipe = (0, pug_1.compileFile)(__dirname + '/../../../template/appendix/crafting_recipe.pug');
22
+ this.templateCraftingRecipe = (0, pug_1.compileFile)((0, node_path_1.join)(__dirname, '..', '..', '..', 'template', 'appendix', 'crafting_recipe.pug'));
22
23
  }
23
24
  getRecipeNameUnlocalized() {
24
25
  return 'block.minecraft.crafting_table';
@@ -26,7 +27,7 @@ class InfoBookAppendixHandlerCraftingRecipe extends InfoBookAppendixHandlerAbstr
26
27
  serializeRecipe(recipe, context, fileWriter, serializer) {
27
28
  return __awaiter(this, void 0, void 0, function* () {
28
29
  // Prepare input array
29
- const inputs = "|".repeat(9).split("|").map(() => []);
30
+ const inputs = '|'.repeat(9).split('|').map(() => []);
30
31
  // Define custom dimensions for shapeless recipes
31
32
  if (!recipe.width || !recipe.height) {
32
33
  recipe.width = recipe.height = Math.sqrt(recipe.input.length);
@@ -42,7 +43,7 @@ class InfoBookAppendixHandlerCraftingRecipe extends InfoBookAppendixHandlerAbstr
42
43
  else {
43
44
  items = [];
44
45
  }
45
- if (!items.length) {
46
+ if (items.length === 0) {
46
47
  items.push({ item: 'minecraft:air' });
47
48
  }
48
49
  const outputIndex = y * 3 + x;
@@ -1,6 +1,6 @@
1
- import { ResourceHandler } from "../../resource/ResourceHandler";
2
- import { IInfoAppendix } from "../IInfoAppendix";
3
- import { IInfoBookAppendixHandler } from "./IInfoBookAppendixHandler";
1
+ import type { ResourceHandler } from '../../resource/ResourceHandler';
2
+ import type { IInfoAppendix } from '../IInfoAppendix';
3
+ import type { IInfoBookAppendixHandler } from './IInfoBookAppendixHandler';
4
4
  /**
5
5
  * Handles image appendices.
6
6
  */
@@ -10,8 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.InfoBookAppendixHandlerImage = void 0;
13
- const fs_1 = require("fs");
14
- const path_1 = require("path");
13
+ const node_fs_1 = require("node:fs");
14
+ const node_path_1 = require("node:path");
15
15
  /**
16
16
  * Handles image appendices.
17
17
  */
@@ -21,11 +21,11 @@ class InfoBookAppendixHandlerImage {
21
21
  }
22
22
  createAppendix(data) {
23
23
  const fullPath = this.resourceHandler.expandResourcePath(data._);
24
- const fileName = (0, path_1.basename)(data._);
24
+ const fileName = (0, node_path_1.basename)(data._);
25
25
  const { width, height } = data.$;
26
26
  return {
27
27
  toHtml: (context, fileWriter) => __awaiter(this, void 0, void 0, function* () {
28
- const writtenPath = yield fileWriter.write(fileName, () => (0, fs_1.createReadStream)(fullPath));
28
+ const writtenPath = yield fileWriter.write(fileName, () => (0, node_fs_1.createReadStream)(fullPath));
29
29
  return `<canvas class="appendix-image" style="background: url(${writtenPath}); width: ${width * 2}px; height: ${height * 2}px; background-size: 512px 512px;"></canvas>`;
30
30
  }),
31
31
  };
@@ -1,6 +1,6 @@
1
- import { ResourceHandler } from "../../resource/ResourceHandler";
2
- import { IInfoAppendix } from "../IInfoAppendix";
3
- import { IInfoBookAppendixHandler } from "./IInfoBookAppendixHandler";
1
+ import type { ResourceHandler } from '../../resource/ResourceHandler';
2
+ import type { IInfoAppendix } from '../IInfoAppendix';
3
+ import type { IInfoBookAppendixHandler } from './IInfoBookAppendixHandler';
4
4
  /**
5
5
  * Handles keybindings appendices.
6
6
  */
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.InfoBookAppendixHandlerKeybinding = void 0;
13
+ const node_path_1 = require("node:path");
13
14
  const pug_1 = require("pug");
14
15
  /**
15
16
  * Handles keybindings appendices.
@@ -17,13 +18,13 @@ const pug_1 = require("pug");
17
18
  class InfoBookAppendixHandlerKeybinding {
18
19
  constructor(resourceHandler) {
19
20
  this.resourceHandler = resourceHandler;
20
- this.templateKeybinding = (0, pug_1.compileFile)(__dirname + '/../../../template/appendix/keybinding.pug');
21
+ this.templateKeybinding = (0, pug_1.compileFile)((0, node_path_1.join)(__dirname, '..', '..', '..', 'template', 'appendix', 'keybinding.pug'));
21
22
  }
22
23
  createAppendix(data) {
23
24
  const id = data._;
24
25
  const key = this.resourceHandler.getKeybinding(id);
25
26
  return {
26
- getName: (context) => this.resourceHandler.getTranslation(`infobook.cyclopscore.keybinding`, context.language),
27
+ getName: context => this.resourceHandler.getTranslation(`infobook.cyclopscore.keybinding`, context.language),
27
28
  toHtml: (context) => __awaiter(this, void 0, void 0, function* () {
28
29
  const name = this.resourceHandler.getTranslation(id, context.language);
29
30
  return this.templateKeybinding({ name, key });
@@ -1,8 +1,9 @@
1
- import { ResourceHandler } from "../../resource/ResourceHandler";
2
- import { HtmlInfoBookSerializer, ISerializeContext } from "../../serialize/HtmlInfoBookSerializer";
3
- import { IFileWriter } from "../IFileWriter";
4
- import { IItem } from "../IItem";
5
- import { InfoBookAppendixHandlerAbstractRecipe, IRecipe } from "./InfoBookAppendixHandlerAbstractRecipe";
1
+ import type { ResourceHandler } from '../../resource/ResourceHandler';
2
+ import type { HtmlInfoBookSerializer, ISerializeContext } from '../../serialize/HtmlInfoBookSerializer';
3
+ import type { IFileWriter } from '../IFileWriter';
4
+ import type { IItem } from '../IItem';
5
+ import type { IRecipe } from './InfoBookAppendixHandlerAbstractRecipe';
6
+ import { InfoBookAppendixHandlerAbstractRecipe } from './InfoBookAppendixHandlerAbstractRecipe';
6
7
  /**
7
8
  * Handles furnace recipe appendices.
8
9
  */
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.InfoBookAppendixHandlerSmeltingRecipe = void 0;
13
+ const node_path_1 = require("node:path");
13
14
  const pug_1 = require("pug");
14
15
  const InfoBookAppendixHandlerAbstractRecipe_1 = require("./InfoBookAppendixHandlerAbstractRecipe");
15
16
  /**
@@ -18,14 +19,14 @@ const InfoBookAppendixHandlerAbstractRecipe_1 = require("./InfoBookAppendixHandl
18
19
  class InfoBookAppendixHandlerSmeltingRecipe extends InfoBookAppendixHandlerAbstractRecipe_1.InfoBookAppendixHandlerAbstractRecipe {
19
20
  constructor(resourceHandler, registriesPath, recipeOverrides) {
20
21
  super('minecraft:smelting', resourceHandler, registriesPath, recipeOverrides);
21
- this.templateFurnaceRecipe = (0, pug_1.compileFile)(__dirname + '/../../../template/appendix/furnace_recipe.pug');
22
+ this.templateFurnaceRecipe = (0, pug_1.compileFile)((0, node_path_1.join)(__dirname, '..', '..', '..', 'template', 'appendix', 'furnace_recipe.pug'));
22
23
  }
23
24
  getRecipeNameUnlocalized() {
24
25
  return 'block.minecraft.furnace';
25
26
  }
26
27
  serializeRecipe(recipe, context, fileWriter, serializer) {
27
28
  return __awaiter(this, void 0, void 0, function* () {
28
- const input = yield Promise.all(recipe.input.map((item) => serializer.createItemDisplay(this.resourceHandler, context, fileWriter, item, true)));
29
+ const input = yield Promise.all(recipe.input.map(item => serializer.createItemDisplay(this.resourceHandler, context, fileWriter, item, true)));
29
30
  const output = yield serializer.createItemDisplay(this.resourceHandler, context, fileWriter, recipe.output, true);
30
31
  const appendixIcon = yield serializer.createItemDisplay(this.resourceHandler, context, fileWriter, { item: 'minecraft:furnace' }, false);
31
32
  return this.templateFurnaceRecipe({ input, output, appendixIcon });
@@ -1,6 +1,6 @@
1
- import { ResourceHandler } from "../../resource/ResourceHandler";
2
- import { IInfoAppendix } from "../IInfoAppendix";
3
- import { IInfoBookAppendixHandler } from "./IInfoBookAppendixHandler";
1
+ import type { ResourceHandler } from '../../resource/ResourceHandler';
2
+ import type { IInfoAppendix } from '../IInfoAppendix';
3
+ import type { IInfoBookAppendixHandler } from './IInfoBookAppendixHandler';
4
4
  /**
5
5
  * Handles text field appendices.
6
6
  */
@@ -19,13 +19,12 @@ class InfoBookAppendixHandlerTextfield {
19
19
  }
20
20
  createAppendix(data) {
21
21
  const contents = data._
22
- .replace(/ /g, '&nbsp;')
23
- .replace(/\n/g, '<br \>');
22
+ .replaceAll(' ', '&nbsp;')
23
+ .replaceAll('\n', '<br >');
24
24
  const scale = data.$.scale || 1;
25
25
  return {
26
- toHtml: (context, fileWriter) => __awaiter(this, void 0, void 0, function* () {
27
- return `<div class="appendix-textfield" style="font-size: ${scale}em">${contents}</div>`;
28
- }),
26
+ // eslint-disable-next-line unused-imports/no-unused-vars
27
+ toHtml: (context, fileWriter) => __awaiter(this, void 0, void 0, function* () { return `<div class="appendix-textfield" style="font-size: ${scale}em">${contents}</div>`; }),
29
28
  };
30
29
  }
31
30
  }
@@ -1,7 +1,7 @@
1
- import { ResourceHandler } from "../../resource/ResourceHandler";
2
- import { HtmlInfoBookSerializer, ISerializeContext } from "../../serialize/HtmlInfoBookSerializer";
3
- import { IFileWriter } from "../IFileWriter";
4
- import { IInfoAppendix } from "../IInfoAppendix";
1
+ import type { ResourceHandler } from '../../resource/ResourceHandler';
2
+ import type { HtmlInfoBookSerializer, ISerializeContext } from '../../serialize/HtmlInfoBookSerializer';
3
+ import type { IFileWriter } from '../IFileWriter';
4
+ import type { IInfoAppendix } from '../IInfoAppendix';
5
5
  /**
6
6
  * An appendix that lists all tags with links to them
7
7
  */
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.InfoBookAppendixTagIndex = void 0;
13
+ const node_path_1 = require("node:path");
13
14
  const pug_1 = require("pug");
14
15
  /**
15
16
  * An appendix that lists all tags with links to them
@@ -17,7 +18,7 @@ const pug_1 = require("pug");
17
18
  class InfoBookAppendixTagIndex {
18
19
  constructor(resourceHandler) {
19
20
  this.resourceHandler = resourceHandler;
20
- this.templateTagIndex = (0, pug_1.compileFile)(__dirname + '/../../../template/appendix/tag_index.pug');
21
+ this.templateTagIndex = (0, pug_1.compileFile)((0, node_path_1.join)(__dirname, '..', '..', '..', 'template', 'appendix', 'tag_index.pug'));
21
22
  }
22
23
  toHtml(context, fileWriter, serializer) {
23
24
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,4 +1,4 @@
1
- import { ChildProcess } from "child_process";
1
+ import type { ChildProcess } from 'node:child_process';
2
2
  /**
3
3
  * Takes care of installing Forge, installing mods, starting a Forge server, and fetching metadata.
4
4
  */
@@ -28,7 +28,17 @@ export declare class ModLoader {
28
28
  * Download and install mods.
29
29
  */
30
30
  installMods(): Promise<void>;
31
- downloadFile(url: string, fileName: string, modsDir: string): Promise<void>;
31
+ downloadFile(url: string, fileName: string, modsDir: string, headers?: Record<string, string>): Promise<void>;
32
+ /**
33
+ * Download a Maven artifact by constructing the repository URL manually.
34
+ * This is used for authenticated repositories where custom headers are needed.
35
+ * @param artifact The Maven artifact coordinates (groupId:artifactId:version[:classifier]).
36
+ * @param repoUrl The base URL of the Maven repository.
37
+ * @param modsDir The directory to save the downloaded file.
38
+ * @param headers Optional HTTP headers (e.g., Authorization).
39
+ * @returns The full path to the downloaded file.
40
+ */
41
+ downloadMavenArtifact(artifact: string, repoUrl: string, modsDir: string, headers?: Record<string, string>): Promise<string>;
32
42
  /**
33
43
  * Start the server and execute a command to dump all registries
34
44
  */
@@ -89,6 +99,7 @@ export interface IModMaven {
89
99
  artifact: string;
90
100
  repo: string;
91
101
  name?: string;
102
+ headers?: Record<string, string>;
92
103
  }
93
104
  export interface IModCurseforge {
94
105
  type: 'curseforge';