@thenick775/mgba-wasm 2.3.2 → 2.3.4

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/dist/mgba.d.ts CHANGED
@@ -87,6 +87,7 @@ declare namespace mGBA {
87
87
  uploadPatch(file: File, callback?: () => void): void;
88
88
  uploadRom(file: File, callback?: () => void): void;
89
89
  uploadSaveOrSaveState(file: File, callback?: () => void): void;
90
+ uploadScreenshot(file: File, callback?: () => void): void;
90
91
  addCoreCallbacks(coreCallbacks: coreCallbacks): void;
91
92
  toggleRewind(enabled: boolean): void;
92
93
  setCoreSettings(coreSettings: coreSettings): void;
package/dist/mgba.js CHANGED
@@ -244,6 +244,33 @@ Module.uploadCheats = (file, callback) => {
244
244
  reader.readAsArrayBuffer(file);
245
245
  };
246
246
 
247
+ Module.uploadScreenshot = (file, callback) => {
248
+ const split = file.name.split('.');
249
+ if (split.length < 2) {
250
+ console.warn('unrecognized file extension: ' + file.name);
251
+ return;
252
+ }
253
+ const extension = split[split.length - 1].toLowerCase();
254
+
255
+ let dir = null;
256
+ if (extension == 'png') {
257
+ dir = '/data/screenshots/';
258
+ } else {
259
+ console.warn('unrecognized file extension: ' + extension);
260
+ return;
261
+ }
262
+
263
+ const reader = new FileReader();
264
+ reader.onload = (e) => {
265
+ FS.writeFile(dir + file.name, new Uint8Array(e.target.result));
266
+ if (callback) {
267
+ callback();
268
+ }
269
+ };
270
+
271
+ reader.readAsArrayBuffer(file);
272
+ };
273
+
247
274
  Module.uploadPatch = (file, callback) => {
248
275
  const split = file.name.split('.');
249
276
  if (split.length < 2) {
package/dist/mgba.wasm CHANGED
Binary file