silphscope 1.4.4 → 1.4.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "silphscope",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "A firered/leafgreen ROM asset extractor for use in web applications",
5
5
  "main": "main.js",
6
6
  "exports": {
@@ -35,6 +35,7 @@ export async function renderAllMons(rom, options = {}) {
35
35
  const {
36
36
  mons: providedMons = mons,
37
37
  outputDir = "./out",
38
+ concurrency = 4,
38
39
  icon = true,
39
40
  footprint = true,
40
41
  } = options;
@@ -44,27 +45,29 @@ export async function renderAllMons(rom, options = {}) {
44
45
  const config = getRomConfig(rom);
45
46
  const reader = new RomReader(rom, config);
46
47
 
47
- await mapLimit(Object.keys(providedMons), 4, async (monName) => { // so in theory we should be running the function 4 times concurrently now...
48
- await renderMon(monName, providedMons, reader, rom, {
49
- variant: ["normal", "shiny"],
50
- icon,
51
- footprint,
52
- outputDir,
53
- });
54
- console.log(`Done: ${monName}`);
55
- });
56
- /* just going to leave this here for now in case I decide to make it so that you can toggle between concurrent usage and I suppose synchronous would be the correct term for this down here...
57
- for (const monName of Object.keys(providedMons)) {
58
- await renderMon(monName, providedMons, reader, rom, { // hopefully this is faster since we are no longer calling the function 4 times lol
59
- side: ["front", "back"],
60
- variant: ["normal", "shiny"],
61
- icon,
62
- footprint,
63
- outputDir,
48
+ if (concurrency > 1) {
49
+ await mapLimit(Object.keys(providedMons), 4, async (monName) => { // so in theory we should be running the function 4 times concurrently now...
50
+ await renderMon(monName, providedMons, reader, rom, {
51
+ side: ["front", "back"],
52
+ variant: ["normal", "shiny"],
53
+ icon,
54
+ footprint,
55
+ outputDir,
56
+ });
57
+ console.log(`Done: ${monName}`);
64
58
  });
65
- console.log(`Done: ${monName}`);
59
+ } else {
60
+ for (const monName of Object.keys(providedMons)) {
61
+ await renderMon(monName, providedMons, reader, rom, { // hopefully this is faster since we are no longer calling the function 4 times lol
62
+ side: ["front", "back"],
63
+ variant: ["normal", "shiny"],
64
+ icon,
65
+ footprint,
66
+ outputDir,
67
+ });
68
+ console.log(`Done: ${monName}`);
69
+ }
66
70
  }
67
- */
68
71
  }
69
72
 
70
73
  export async function renderAllIcons(rom, options = {}) {
@@ -92,7 +95,7 @@ export async function renderAllTrainers(rom, options = {}) {
92
95
  if (!rom || !(rom instanceof Uint8Array || Buffer.isBuffer(rom))) {
93
96
  throw new TypeError("renderAllTrainers(rom, options) requires rom Buffer/Uint8Array as first argument");
94
97
  }
95
-
98
+
96
99
  const {
97
100
  trainers: providedTrainers = trainers,
98
101
  trainersBack: providedBackTrainers = trainersBack,
@@ -107,8 +110,8 @@ export async function renderAllTrainers(rom, options = {}) {
107
110
 
108
111
  for (const trainerName of Object.keys(providedTrainers)) {
109
112
  await renderTrainer(trainerName, providedTrainers, providedBackTrainers, reader, rom, {
110
- trainerBackPics,
111
- outputDir
113
+ trainerBackPics,
114
+ outputDir
112
115
  });
113
116
  console.log(`Done: ${trainerName}`);
114
117
  }
@@ -128,7 +131,7 @@ export async function renderAllMoves(rom, options = {}) {
128
131
  const reader = new RomReader(rom, config);
129
132
 
130
133
  for (const moveName of Object.keys(providedMoves)) {
131
- await renderMove(moveName, providedMoves, reader, rom, {
134
+ await renderMove(moveName, providedMoves, reader, rom, {
132
135
  outputDir,
133
136
  renderMasterImage,
134
137
  sortUnused,
@@ -137,7 +140,7 @@ export async function renderAllMoves(rom, options = {}) {
137
140
  }
138
141
  }
139
142
 
140
- export async function renderAllBalls(rom, options= {}) {
143
+ export async function renderAllBalls(rom, options = {}) {
141
144
  const {
142
145
  balls: providedBalls = balls,
143
146
  outputDir = "./out",
@@ -152,9 +155,9 @@ export async function renderAllBalls(rom, options= {}) {
152
155
  const reader = new RomReader(rom, config);
153
156
 
154
157
  for (const ballName of Object.keys(providedBalls)) {
155
- await renderBall(ballName, providedBalls, reader, rom, {
158
+ await renderBall(ballName, providedBalls, reader, rom, {
156
159
  outputDir,
157
- ballParticles,
160
+ ballParticles,
158
161
  renderMasterBallImage,
159
162
  renderMasterBallParticleImage,
160
163
  });
@@ -168,6 +171,7 @@ export async function renderAllGraphics(rom, options = {}) { // eventually I wil
168
171
  }
169
172
 
170
173
  const {
174
+ concurrency = 4,
171
175
  outputMonDir = "./out/mons",
172
176
  outputIconDir = "./out/icons",
173
177
  outputTrainerDir = "./out/trainers",
@@ -177,11 +181,12 @@ export async function renderAllGraphics(rom, options = {}) { // eventually I wil
177
181
  } = options;
178
182
 
179
183
  await renderAllMons(rom, {
184
+ concurrency,
180
185
  outputDir: outputMonDir,
181
186
  icon: true,
182
187
  footprint: true,
183
188
  });
184
-
189
+
185
190
  await renderAllIcons(rom, {
186
191
  outputDir: outputIconDir,
187
192
  });
@@ -62,6 +62,7 @@ export async function renderMon(monName, mons, reader, rom, options = {}) {
62
62
  const width = 64;
63
63
  const height = 64;
64
64
  if (outputDir) {
65
+ const dir = `${outputDir}/${monName}`; // why do I forget the simplest things...
65
66
  await fs.promises.mkdir(dir, { recursive: true }); // why was I using existsSync... eh well "fixed?" now I guess... also I moved this out of the loop as you can see so it only has to run... 440 times now... instead of 4x that number :p
66
67
  }
67
68
  for (const side of sides) {