Forum Discussion
Storyline Suspend Data Compression
Well, hrmph! It does look like pako changed their API in v2.0.0:
## [2.0.0] - 2020-11-17
### Changed
- Removed binary strings and `Array` support.
So, that does mean the getDataChunk() and setDataChunk() do need some updates to deal with deflate now returning an Int8Array and inflate requiring an Int8Array as input.
Though your suggested changes do work, I have tuned them just a bit. Note: I chose to use String.prototype.split to turn a string into an array because it has the widest & oldest browser support and can still be done in one line. Plus the only real issue with using split is not a problem here since we would not be encountering any actual UTF-16 characters coming out of deflate nor going into inflate as they specifically are dealing with 8-bit integers (eg, an 8-bit integer would never produce a UTF-16 character that would then break using split).
So, here is my updated pako patch file that I am now using with pako > v2.0.0:
--- index_lms.html.orig 2020-09-16 11:15:29.634371759 -0700
+++ index_lms.html 2020-09-16 11:15:06.980645108 -0700
@@ -13,5 +13,6 @@
#app { height: 100%; width: 100%; }^M
</style>^M
<script src="lms/scormdriver.js" charset="utf-8"></script>^M
+ <script src="lms/pako.min.js"></script>^M
<script>window.THREE = { };</script>^M
</head>^M
--- lms/scormdriver.js.orig 2021-07-03 14:55:52.000000000 -0700
+++ lms/scormdriver.js 2022-05-02 13:08:13.100525415 -0800
@@ -32257,7 +32257,15 @@
return "";
}
- return objLMS.GetDataChunk();
+ try {
+ var strDataC=objLMS.GetDataChunk();
+ var strData=window.pako.inflate(atob(strDataC).split('').map(function(c){return c.charCodeAt(0)}), {to: 'string'});
+ WriteToDebug("GetDataChunk strData="+strData);
+ return strData;
+ } catch (err) {
+ SetErrorInfo(ERROR_INVALID_RESPONSE, "DataChunk Inflate error");
+ return "";
+ }
}
//public
@@ -32270,7 +32278,14 @@
return false;
}
- return objLMS.SetDataChunk(strData);
+ try {
+ WriteToDebug("SetDataChunk strData="+strData);
+ var strDataC=btoa(window.pako.deflate(strData).reduce(function(s,i){return s+String.fromCharCode(i)},''));
+ return objLMS.SetDataChunk(strDataC);
+ } catch (err) {
+ SetErrorInfo(ERROR_INVALID_RESPONSE, "DataChunk Deflate error");
+ return "";
+ }
}
//public