miijs 2.1.1 → 2.1.3
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/fflWrapper.js +41 -0
- package/index.js +1103 -427
- package/package.json +5 -3
- package/patch-ffl.js +48 -0
- package/out.txt +0 -178
- package/stuff.js +0 -208
package/fflWrapper.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Compatibility layer for ffl.js
|
|
2
|
+
const structFu = require('struct-fu');
|
|
3
|
+
|
|
4
|
+
// Monkey-patch struct-fu BEFORE ffl.js loads
|
|
5
|
+
const originalStruct = structFu.struct;
|
|
6
|
+
structFu.struct = function(...args) {
|
|
7
|
+
const result = originalStruct.apply(this, args);
|
|
8
|
+
const originalUnpack = result.unpack;
|
|
9
|
+
const originalPack = result.pack;
|
|
10
|
+
|
|
11
|
+
result.unpack = function(data) {
|
|
12
|
+
if (data && !(data instanceof Buffer) && data.buffer) {
|
|
13
|
+
data = Buffer.from(data);
|
|
14
|
+
}
|
|
15
|
+
return originalUnpack.call(this, data);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
result.pack = function(obj) {
|
|
19
|
+
if (obj && typeof obj === 'object') {
|
|
20
|
+
for (let key in obj) {
|
|
21
|
+
if (key.startsWith('_padding') && Array.isArray(obj[key])) {
|
|
22
|
+
obj[key] = Buffer.from(obj[key]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return originalPack.call(this, obj);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Set up globals
|
|
33
|
+
global._ = structFu;
|
|
34
|
+
global.THREE = require('three');
|
|
35
|
+
|
|
36
|
+
// Load ffl.js - it will use the patched struct-fu
|
|
37
|
+
const fflPath = require.resolve('ffl.js/ffl.js');
|
|
38
|
+
delete require.cache[fflPath]; // Clear cache
|
|
39
|
+
const fflModule = require('ffl.js/ffl.js');
|
|
40
|
+
|
|
41
|
+
module.exports = fflModule;
|