Add initial support for LZMA decompression on HTML5 target

This commit is contained in:
Joshua Granick
2024-05-31 08:09:16 -07:00
parent c0ca857fa6
commit d0678156dd
4 changed files with 27 additions and 0 deletions

View File

@@ -104,6 +104,9 @@ This product bundles FileSaver.js 1.3.3, which is available under an
This product bundles pako 1.0.2, which is available under an
"MIT" license. For details, see [dependencies/pako.min.js](dependencies/pako.min.js).
This product bundles LZMA-JS 2.3.2, which is available under an
"MIT" license. For details, see [dependencies/lzma_worker-min.js](dependencies/lzma_worker-min.js).
This product bundles stats.js r16, which is available under an
"MIT" license. For details, see [dependencies/stats.min.js](dependencies/stats.min.js).

2
dependencies/lzma_worker-min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -92,6 +92,7 @@
<dependency path="dependencies/howler.min.js" if="html5 howlerjs" embed="true" />
<dependency path="dependencies/pako.min.js" if="html5" embed="true" web-worker="true" />
<dependency path="dependencies/lzma_worker-min.js" if="html5" embed="true" web-worker="true" />
<dependency path="dependencies/FileSaver.min.js" if="html5" embed="true" />
<dependency path="dependencies/webgl-debug.js" if="html5 webgl-debug" embed="true" />
<dependency path="dependencies/stats.min.js" if="html5 stats" embed="true" />

View File

@@ -2,6 +2,7 @@ package lime._internal.format;
import haxe.io.Bytes;
import lime._internal.backend.native.NativeCFFI;
import lime.utils.UInt8Array;
#if flash
import flash.utils.CompressionAlgorithm;
import flash.utils.ByteArray;
@@ -24,6 +25,16 @@ class LZMA
if (data == null) return null;
return @:privateAccess new Bytes(data.length, data.b);
#end
#elseif js
var data = untyped #if haxe4 js.Syntax.code #else __js__ #end ("LZMA.compress")(new UInt8Array(bytes.getData()), 5);
if (data is String)
{
return Bytes.ofString(data);
}
else
{
return Bytes.ofData(cast data);
}
#elseif flash
var byteArray:ByteArray = cast bytes.getData();
@@ -47,6 +58,16 @@ class LZMA
if (data == null) return null;
return @:privateAccess new Bytes(data.length, data.b);
#end
#elseif js
var data = untyped #if haxe4 js.Syntax.code #else __js__ #end ("LZMA.decompress")(new UInt8Array(bytes.getData()));
if (data is String)
{
return Bytes.ofString(data);
}
else
{
return Bytes.ofData(cast data);
}
#elseif flash
var byteArray:ByteArray = cast bytes.getData();