@r2o3/rgskin-nodejs 0.0.1 → 0.0.2

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 CHANGED
@@ -27,7 +27,7 @@ A library for loading and creating skins for various rhythm games. It supports c
27
27
  Add this to your `Cargo.toml`:
28
28
  ```toml
29
29
  [dependencies]
30
- rgskin = "0.0.1"
30
+ rgskin = "0.0.2"
31
31
  ```
32
32
 
33
33
  Or run:
@@ -45,10 +45,12 @@ cargo add rgskin
45
45
  use rgskin::prelude::*;
46
46
 
47
47
  // importing a skin from a directory
48
- let osu_skin = import::osu::skin_from_dir("path/to/skin").expect("Failed to import skin!");
49
- let fluxis_skin = import::fluxis::skin_from_dir("path/to/skin").expect("Failed to import skin!");
48
+ let osu_skin = import::osu::skin_from_dir("path/to/skin").expect("Failed to import skin!", false);
49
+ let fluxis_skin = import::fluxis::skin_from_dir("path/to/skin").expect("Failed to import skin!", false);
50
50
  ```
51
51
 
52
+ The second argument is for if you want to import ALL assets for a skin, it will import all textures but leave the unrequired unloaded, usually recommended when merging skins of the same type as you might need all assets; otherwise if false it will only import and load the required assets.
53
+
52
54
  ##### Manually loading a skin
53
55
 
54
56
  ```rust
@@ -58,7 +60,7 @@ use rgskin::prelude::*;
58
60
  let mut textures = TextureStore::new();
59
61
 
60
62
  // you can import textures from a directory like this:
61
- textures = import::all_textures_from_dir("path/to/skin")?;
63
+ textures = import::all_textures_from_dir("path/to/skin", None)?;
62
64
 
63
65
  // or alternatively if you parse the skin config first, you can import only the textures you need like this:
64
66
  let raw_str = import::osu::ini_str_from_dir("path/to/skin");
@@ -84,7 +86,7 @@ Additionally all skins can be converting into a generic version of it.
84
86
  Examples:
85
87
  ```rust
86
88
  OsuSkin::from_generic_mania(&generic);
87
- OsuSkin.to_generic_mania();
89
+ OsuSkin.to_generic_mania(()); // yes, the extra parethesis is required.
88
90
  ```
89
91
  ```rust
90
92
  FluXisSkin::from_generic_mania(&generic);
@@ -208,8 +210,8 @@ let osuSkin = new rgskin.OsuSkin(skin_config, textures, null); // last parameter
208
210
 
209
211
  ##### Preparing the filesMap
210
212
 
211
- The `filesMap` parameter is a JavaScript `Map` object where:
212
- - Keys are filenames (strings)
213
+ The `filesMap` parameter is a `Map` object where:
214
+ - Keys are relative paths (strings)
213
215
  - Values are file contents as `Uint8Array`
214
216
 
215
217
  Example: Reading files from an HTML file input
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "menvae"
5
5
  ],
6
6
  "description": "A library for converting rhythm game skins.",
7
- "version": "0.0.1",
7
+ "version": "0.0.2",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",
package/rgskin.d.ts CHANGED
@@ -24,6 +24,7 @@ export class BinaryStore {
24
24
  clear(): void;
25
25
  copy(original_path: string, new_path: string): string | undefined;
26
26
  makeUniqueCopy(original_path: string, new_base_path: string): string | undefined;
27
+ extend(other: BinaryStore): void;
27
28
  }
28
29
 
29
30
  export class FluXisKeymode {
@@ -151,12 +152,12 @@ export class OsuKeymode {
151
152
  set combo_position(value: number | null | undefined);
152
153
  column_start: number;
153
154
  column_right: number;
154
- column_line_width: Uint32Array;
155
- column_width: Uint32Array;
156
- column_spacing: Uint32Array;
155
+ column_line_width: Float32Array;
156
+ column_width: Float32Array;
157
+ column_spacing: Float32Array;
157
158
  barline_height: number;
158
- lighting_n_width: Uint32Array;
159
- lighting_l_width: Uint32Array;
159
+ lighting_n_width: Float32Array;
160
+ lighting_l_width: Float32Array;
160
161
  get width_for_note_height_scale(): number | undefined;
161
162
  set width_for_note_height_scale(value: number | null | undefined);
162
163
  light_frame_per_second: number;
@@ -283,6 +284,7 @@ export class TextureStore {
283
284
  clear(): void;
284
285
  copy(original_path: string, new_path: string): string | undefined;
285
286
  makeUniqueCopy(original_path: string, new_base_path: string): string | undefined;
287
+ extend(other: TextureStore): void;
286
288
  }
287
289
 
288
290
  export function allSamplesFromDir(path: string): BinaryStore;
package/rgskin.js CHANGED
@@ -2,7 +2,7 @@
2
2
  let imports = {};
3
3
  imports['__wbindgen_placeholder__'] = module.exports;
4
4
 
5
- const { createDirAll, isDirectory, joinPath, readDir, readFileBytes, readFileString, writeFile } = require(String.raw`./snippets/rgskin-ddf01b385d257895/inline0.js`);
5
+ const { createDirAll, isDirectory, joinPath, readDir, readFileBytes, readFileString, writeFile } = require(String.raw`./snippets/rgskin-65f1492efda13f32/inline0.js`);
6
6
 
7
7
  function addToExternrefTable0(obj) {
8
8
  const idx = wasm.__externref_table_alloc();
@@ -81,6 +81,11 @@ function debugString(val) {
81
81
  return className;
82
82
  }
83
83
 
84
+ function getArrayF32FromWasm0(ptr, len) {
85
+ ptr = ptr >>> 0;
86
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
87
+ }
88
+
84
89
  function getArrayJsValueFromWasm0(ptr, len) {
85
90
  ptr = ptr >>> 0;
86
91
  const mem = getDataViewMemory0();
@@ -97,11 +102,6 @@ function getArrayU16FromWasm0(ptr, len) {
97
102
  return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
98
103
  }
99
104
 
100
- function getArrayU32FromWasm0(ptr, len) {
101
- ptr = ptr >>> 0;
102
- return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
103
- }
104
-
105
105
  function getArrayU8FromWasm0(ptr, len) {
106
106
  ptr = ptr >>> 0;
107
107
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -115,6 +115,14 @@ function getDataViewMemory0() {
115
115
  return cachedDataViewMemory0;
116
116
  }
117
117
 
118
+ let cachedFloat32ArrayMemory0 = null;
119
+ function getFloat32ArrayMemory0() {
120
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
121
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
122
+ }
123
+ return cachedFloat32ArrayMemory0;
124
+ }
125
+
118
126
  function getStringFromWasm0(ptr, len) {
119
127
  ptr = ptr >>> 0;
120
128
  return decodeText(ptr, len);
@@ -128,14 +136,6 @@ function getUint16ArrayMemory0() {
128
136
  return cachedUint16ArrayMemory0;
129
137
  }
130
138
 
131
- let cachedUint32ArrayMemory0 = null;
132
- function getUint32ArrayMemory0() {
133
- if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
134
- cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
135
- }
136
- return cachedUint32ArrayMemory0;
137
- }
138
-
139
139
  let cachedUint8ArrayMemory0 = null;
140
140
  function getUint8ArrayMemory0() {
141
141
  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
@@ -164,16 +164,16 @@ function passArray16ToWasm0(arg, malloc) {
164
164
  return ptr;
165
165
  }
166
166
 
167
- function passArray32ToWasm0(arg, malloc) {
168
- const ptr = malloc(arg.length * 4, 4) >>> 0;
169
- getUint32ArrayMemory0().set(arg, ptr / 4);
167
+ function passArray8ToWasm0(arg, malloc) {
168
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
169
+ getUint8ArrayMemory0().set(arg, ptr / 1);
170
170
  WASM_VECTOR_LEN = arg.length;
171
171
  return ptr;
172
172
  }
173
173
 
174
- function passArray8ToWasm0(arg, malloc) {
175
- const ptr = malloc(arg.length * 1, 1) >>> 0;
176
- getUint8ArrayMemory0().set(arg, ptr / 1);
174
+ function passArrayF32ToWasm0(arg, malloc) {
175
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
176
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
177
177
  WASM_VECTOR_LEN = arg.length;
178
178
  return ptr;
179
179
  }
@@ -539,6 +539,13 @@ class BinaryStore {
539
539
  }
540
540
  return v3;
541
541
  }
542
+ /**
543
+ * @param {BinaryStore} other
544
+ */
545
+ extend(other) {
546
+ _assertClass(other, BinaryStore);
547
+ wasm.binarystore_extend(this.__wbg_ptr, other.__wbg_ptr);
548
+ }
542
549
  }
543
550
  if (Symbol.dispose) BinaryStore.prototype[Symbol.dispose] = BinaryStore.prototype.free;
544
551
  exports.BinaryStore = BinaryStore;
@@ -1728,7 +1735,7 @@ class OsuKeymode {
1728
1735
  */
1729
1736
  get column_start() {
1730
1737
  const ret = wasm.__wbg_get_osukeymode_column_start(this.__wbg_ptr);
1731
- return ret >>> 0;
1738
+ return ret;
1732
1739
  }
1733
1740
  /**
1734
1741
  * @param {number} arg0
@@ -1741,7 +1748,7 @@ class OsuKeymode {
1741
1748
  */
1742
1749
  get column_right() {
1743
1750
  const ret = wasm.__wbg_get_osukeymode_column_right(this.__wbg_ptr);
1744
- return ret >>> 0;
1751
+ return ret;
1745
1752
  }
1746
1753
  /**
1747
1754
  * @param {number} arg0
@@ -1750,53 +1757,53 @@ class OsuKeymode {
1750
1757
  wasm.__wbg_set_osukeymode_column_right(this.__wbg_ptr, arg0);
1751
1758
  }
1752
1759
  /**
1753
- * @returns {Uint32Array}
1760
+ * @returns {Float32Array}
1754
1761
  */
1755
1762
  get column_line_width() {
1756
1763
  const ret = wasm.__wbg_get_osukeymode_column_line_width(this.__wbg_ptr);
1757
- var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
1764
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
1758
1765
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1759
1766
  return v1;
1760
1767
  }
1761
1768
  /**
1762
- * @param {Uint32Array} arg0
1769
+ * @param {Float32Array} arg0
1763
1770
  */
1764
1771
  set column_line_width(arg0) {
1765
- const ptr0 = passArray32ToWasm0(arg0, wasm.__wbindgen_malloc);
1772
+ const ptr0 = passArrayF32ToWasm0(arg0, wasm.__wbindgen_malloc);
1766
1773
  const len0 = WASM_VECTOR_LEN;
1767
1774
  wasm.__wbg_set_osukeymode_column_line_width(this.__wbg_ptr, ptr0, len0);
1768
1775
  }
1769
1776
  /**
1770
- * @returns {Uint32Array}
1777
+ * @returns {Float32Array}
1771
1778
  */
1772
1779
  get column_width() {
1773
1780
  const ret = wasm.__wbg_get_osukeymode_column_width(this.__wbg_ptr);
1774
- var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
1781
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
1775
1782
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1776
1783
  return v1;
1777
1784
  }
1778
1785
  /**
1779
- * @param {Uint32Array} arg0
1786
+ * @param {Float32Array} arg0
1780
1787
  */
1781
1788
  set column_width(arg0) {
1782
- const ptr0 = passArray32ToWasm0(arg0, wasm.__wbindgen_malloc);
1789
+ const ptr0 = passArrayF32ToWasm0(arg0, wasm.__wbindgen_malloc);
1783
1790
  const len0 = WASM_VECTOR_LEN;
1784
1791
  wasm.__wbg_set_osukeymode_column_width(this.__wbg_ptr, ptr0, len0);
1785
1792
  }
1786
1793
  /**
1787
- * @returns {Uint32Array}
1794
+ * @returns {Float32Array}
1788
1795
  */
1789
1796
  get column_spacing() {
1790
1797
  const ret = wasm.__wbg_get_osukeymode_column_spacing(this.__wbg_ptr);
1791
- var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
1798
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
1792
1799
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1793
1800
  return v1;
1794
1801
  }
1795
1802
  /**
1796
- * @param {Uint32Array} arg0
1803
+ * @param {Float32Array} arg0
1797
1804
  */
1798
1805
  set column_spacing(arg0) {
1799
- const ptr0 = passArray32ToWasm0(arg0, wasm.__wbindgen_malloc);
1806
+ const ptr0 = passArrayF32ToWasm0(arg0, wasm.__wbindgen_malloc);
1800
1807
  const len0 = WASM_VECTOR_LEN;
1801
1808
  wasm.__wbg_set_osukeymode_column_spacing(this.__wbg_ptr, ptr0, len0);
1802
1809
  }
@@ -1814,36 +1821,36 @@ class OsuKeymode {
1814
1821
  wasm.__wbg_set_osukeymode_barline_height(this.__wbg_ptr, arg0);
1815
1822
  }
1816
1823
  /**
1817
- * @returns {Uint32Array}
1824
+ * @returns {Float32Array}
1818
1825
  */
1819
1826
  get lighting_n_width() {
1820
1827
  const ret = wasm.__wbg_get_osukeymode_lighting_n_width(this.__wbg_ptr);
1821
- var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
1828
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
1822
1829
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1823
1830
  return v1;
1824
1831
  }
1825
1832
  /**
1826
- * @param {Uint32Array} arg0
1833
+ * @param {Float32Array} arg0
1827
1834
  */
1828
1835
  set lighting_n_width(arg0) {
1829
- const ptr0 = passArray32ToWasm0(arg0, wasm.__wbindgen_malloc);
1836
+ const ptr0 = passArrayF32ToWasm0(arg0, wasm.__wbindgen_malloc);
1830
1837
  const len0 = WASM_VECTOR_LEN;
1831
1838
  wasm.__wbg_set_osukeymode_lighting_n_width(this.__wbg_ptr, ptr0, len0);
1832
1839
  }
1833
1840
  /**
1834
- * @returns {Uint32Array}
1841
+ * @returns {Float32Array}
1835
1842
  */
1836
1843
  get lighting_l_width() {
1837
1844
  const ret = wasm.__wbg_get_osukeymode_lighting_l_width(this.__wbg_ptr);
1838
- var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
1845
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
1839
1846
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1840
1847
  return v1;
1841
1848
  }
1842
1849
  /**
1843
- * @param {Uint32Array} arg0
1850
+ * @param {Float32Array} arg0
1844
1851
  */
1845
1852
  set lighting_l_width(arg0) {
1846
- const ptr0 = passArray32ToWasm0(arg0, wasm.__wbindgen_malloc);
1853
+ const ptr0 = passArrayF32ToWasm0(arg0, wasm.__wbindgen_malloc);
1847
1854
  const len0 = WASM_VECTOR_LEN;
1848
1855
  wasm.__wbg_set_osukeymode_lighting_l_width(this.__wbg_ptr, ptr0, len0);
1849
1856
  }
@@ -1858,7 +1865,7 @@ class OsuKeymode {
1858
1865
  * @param {number | null} [arg0]
1859
1866
  */
1860
1867
  set width_for_note_height_scale(arg0) {
1861
- wasm.__wbg_set_osukeymode_width_for_note_height_scale(this.__wbg_ptr, isLikeNone(arg0) ? 0x100000001 : (arg0) >>> 0);
1868
+ wasm.__wbg_set_osukeymode_width_for_note_height_scale(this.__wbg_ptr, isLikeNone(arg0) ? 0x100000001 : Math.fround(arg0));
1862
1869
  }
1863
1870
  /**
1864
1871
  * @returns {number}
@@ -2381,7 +2388,7 @@ class OsuSkin {
2381
2388
  * @returns {TextureStore}
2382
2389
  */
2383
2390
  get textures() {
2384
- const ret = wasm.__wbg_get_osuskin_textures(this.__wbg_ptr);
2391
+ const ret = wasm.__wbg_get_genericmaniaskin_textures(this.__wbg_ptr);
2385
2392
  return TextureStore.__wrap(ret);
2386
2393
  }
2387
2394
  /**
@@ -2390,13 +2397,13 @@ class OsuSkin {
2390
2397
  set textures(arg0) {
2391
2398
  _assertClass(arg0, TextureStore);
2392
2399
  var ptr0 = arg0.__destroy_into_raw();
2393
- wasm.__wbg_set_osuskin_textures(this.__wbg_ptr, ptr0);
2400
+ wasm.__wbg_set_genericmaniaskin_textures(this.__wbg_ptr, ptr0);
2394
2401
  }
2395
2402
  /**
2396
2403
  * @returns {BinaryStore}
2397
2404
  */
2398
2405
  get samples() {
2399
- const ret = wasm.__wbg_get_osuskin_samples(this.__wbg_ptr);
2406
+ const ret = wasm.__wbg_get_genericmaniaskin_samples(this.__wbg_ptr);
2400
2407
  return BinaryStore.__wrap(ret);
2401
2408
  }
2402
2409
  /**
@@ -2405,7 +2412,7 @@ class OsuSkin {
2405
2412
  set samples(arg0) {
2406
2413
  _assertClass(arg0, BinaryStore);
2407
2414
  var ptr0 = arg0.__destroy_into_raw();
2408
- wasm.__wbg_set_osuskin_samples(this.__wbg_ptr, ptr0);
2415
+ wasm.__wbg_set_genericmaniaskin_samples(this.__wbg_ptr, ptr0);
2409
2416
  }
2410
2417
  /**
2411
2418
  * @param {OsuSkinIni} skin_ini
@@ -3261,6 +3268,13 @@ class TextureStore {
3261
3268
  }
3262
3269
  return v3;
3263
3270
  }
3271
+ /**
3272
+ * @param {TextureStore} other
3273
+ */
3274
+ extend(other) {
3275
+ _assertClass(other, TextureStore);
3276
+ wasm.texturestore_extend(this.__wbg_ptr, other.__wbg_ptr);
3277
+ }
3264
3278
  }
3265
3279
  if (Symbol.dispose) TextureStore.prototype[Symbol.dispose] = TextureStore.prototype.free;
3266
3280
  exports.TextureStore = TextureStore;
@@ -3528,7 +3542,7 @@ exports.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
3528
3542
  throw new Error(getStringFromWasm0(arg0, arg1));
3529
3543
  };
3530
3544
 
3531
- exports.__wbg_createDirAll_3fa17ad31f0b67eb = function() { return handleError(function (arg0, arg1) {
3545
+ exports.__wbg_createDirAll_ed59516d327d16d7 = function() { return handleError(function (arg0, arg1) {
3532
3546
  createDirAll(getStringFromWasm0(arg0, arg1));
3533
3547
  }, arguments) };
3534
3548
 
@@ -3547,12 +3561,12 @@ exports.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
3547
3561
  return ret;
3548
3562
  };
3549
3563
 
3550
- exports.__wbg_isDirectory_dc61910333390a70 = function() { return handleError(function (arg0, arg1) {
3564
+ exports.__wbg_isDirectory_d9447fc59d890759 = function() { return handleError(function (arg0, arg1) {
3551
3565
  const ret = isDirectory(getStringFromWasm0(arg0, arg1));
3552
3566
  return ret;
3553
3567
  }, arguments) };
3554
3568
 
3555
- exports.__wbg_joinPath_f4200fd11e4bf2e2 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
3569
+ exports.__wbg_joinPath_09e3f297160d67ae = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
3556
3570
  const ret = joinPath(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
3557
3571
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3558
3572
  const len1 = WASM_VECTOR_LEN;
@@ -3604,17 +3618,17 @@ exports.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) {
3604
3618
  return ret;
3605
3619
  };
3606
3620
 
3607
- exports.__wbg_readDir_f8fed9ecdf7010ee = function() { return handleError(function (arg0, arg1) {
3621
+ exports.__wbg_readDir_d68d219c55b1d4c0 = function() { return handleError(function (arg0, arg1) {
3608
3622
  const ret = readDir(getStringFromWasm0(arg0, arg1));
3609
3623
  return ret;
3610
3624
  }, arguments) };
3611
3625
 
3612
- exports.__wbg_readFileBytes_933ada0a0e8a93d5 = function() { return handleError(function (arg0, arg1) {
3626
+ exports.__wbg_readFileBytes_2c1b7dda2708a44c = function() { return handleError(function (arg0, arg1) {
3613
3627
  const ret = readFileBytes(getStringFromWasm0(arg0, arg1));
3614
3628
  return ret;
3615
3629
  }, arguments) };
3616
3630
 
3617
- exports.__wbg_readFileString_a187767bff213fb1 = function() { return handleError(function (arg0, arg1, arg2) {
3631
+ exports.__wbg_readFileString_fecdefcb119365ed = function() { return handleError(function (arg0, arg1, arg2) {
3618
3632
  const ret = readFileString(getStringFromWasm0(arg1, arg2));
3619
3633
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3620
3634
  const len1 = WASM_VECTOR_LEN;
@@ -3622,7 +3636,7 @@ exports.__wbg_readFileString_a187767bff213fb1 = function() { return handleError(
3622
3636
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
3623
3637
  }, arguments) };
3624
3638
 
3625
- exports.__wbg_writeFile_ec1852732052ad12 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
3639
+ exports.__wbg_writeFile_be43d94d078ac294 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
3626
3640
  writeFile(getStringFromWasm0(arg0, arg1), getArrayU8FromWasm0(arg2, arg3));
3627
3641
  }, arguments) };
3628
3642
 
package/rgskin_bg.wasm CHANGED
Binary file