com.wallstop-studios.unity-helpers 2.0.0-rc78.9 → 2.0.0-rc79.1

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.
Files changed (49) hide show
  1. package/Runtime/Protobuf-Net/System.Collections.Immutable.dll +0 -0
  2. package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  3. package/Runtime/Protobuf-Net/protobuf-net.Core.dll +0 -0
  4. package/Runtime/Protobuf-Net/protobuf-net.dll +0 -0
  5. package/Runtime/Utils/Ascii85.cs +115 -0
  6. package/Runtime/Utils/Ascii85.cs.meta +3 -0
  7. package/Runtime/Utils/LZMA.cs +53 -0
  8. package/Runtime/Utils/LZMA.cs.meta +3 -0
  9. package/Runtime/Utils/SevenZip/Common/CRC.cs +61 -0
  10. package/Runtime/Utils/SevenZip/Common/CRC.cs.meta +11 -0
  11. package/Runtime/Utils/SevenZip/Common/InBuffer.cs +71 -0
  12. package/Runtime/Utils/SevenZip/Common/InBuffer.cs.meta +11 -0
  13. package/Runtime/Utils/SevenZip/Common/OutBuffer.cs +65 -0
  14. package/Runtime/Utils/SevenZip/Common/OutBuffer.cs.meta +11 -0
  15. package/Runtime/Utils/SevenZip/Common.meta +3 -0
  16. package/Runtime/Utils/SevenZip/Compress/LZ/IMatchFinder.cs +28 -0
  17. package/Runtime/Utils/SevenZip/Compress/LZ/IMatchFinder.cs.meta +11 -0
  18. package/Runtime/Utils/SevenZip/Compress/LZ/LzBinTree.cs +404 -0
  19. package/Runtime/Utils/SevenZip/Compress/LZ/LzBinTree.cs.meta +11 -0
  20. package/Runtime/Utils/SevenZip/Compress/LZ/LzInWindow.cs +153 -0
  21. package/Runtime/Utils/SevenZip/Compress/LZ/LzInWindow.cs.meta +11 -0
  22. package/Runtime/Utils/SevenZip/Compress/LZ/LzOutWindow.cs +110 -0
  23. package/Runtime/Utils/SevenZip/Compress/LZ/LzOutWindow.cs.meta +11 -0
  24. package/Runtime/{Protobuf-Net/System.Collections.Immutable.xml.meta → Utils/SevenZip/Compress/LZ.meta} +3 -2
  25. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaBase.cs +101 -0
  26. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaBase.cs.meta +11 -0
  27. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaDecoder.cs +464 -0
  28. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaDecoder.cs.meta +11 -0
  29. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaEncoder.cs +1669 -0
  30. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaEncoder.cs.meta +11 -0
  31. package/Runtime/Utils/SevenZip/Compress/LZMA.meta +8 -0
  32. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoder.cs +233 -0
  33. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoder.cs.meta +11 -0
  34. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBit.cs +137 -0
  35. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBit.cs.meta +11 -0
  36. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBitTree.cs +170 -0
  37. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBitTree.cs.meta +11 -0
  38. package/Runtime/Utils/SevenZip/Compress/RangeCoder.meta +8 -0
  39. package/Runtime/{Protobuf-Net/System.Runtime.CompilerServices.Unsafe.xml.meta → Utils/SevenZip/Compress.meta} +3 -2
  40. package/Runtime/Utils/SevenZip/ICoder.cs +177 -0
  41. package/Runtime/Utils/SevenZip/ICoder.cs.meta +11 -0
  42. package/Runtime/Utils/SevenZip.meta +3 -0
  43. package/package.json +3 -1
  44. package/Runtime/Protobuf-Net/System.Buffers.dll +0 -0
  45. package/Runtime/Protobuf-Net/System.Buffers.dll.meta +0 -33
  46. package/Runtime/Protobuf-Net/System.Collections.Immutable.xml +0 -6812
  47. package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll +0 -0
  48. package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll.meta +0 -33
  49. package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.xml +0 -342
@@ -0,0 +1,115 @@
1
+ namespace WallstopStudios.UnityHelpers.Utils
2
+ {
3
+ using System;
4
+ using System.Collections.Generic;
5
+ using System.Text;
6
+ using System.Threading;
7
+
8
+ public static class Ascii85
9
+ {
10
+ private static readonly ThreadLocal<StringBuilder> StringBuilderCache = new(() =>
11
+ new StringBuilder()
12
+ );
13
+
14
+ private static readonly ThreadLocal<byte[]> ChunkCache = new(() => new byte[4]);
15
+ private static readonly ThreadLocal<char[]> EncodedCache = new(() => new char[5]);
16
+ private static readonly ThreadLocal<List<byte>> ByteListCache = new(() => new List<byte>());
17
+
18
+ private static readonly uint[] Pow85 = { 85 * 85 * 85 * 85, 85 * 85 * 85, 85 * 85, 85, 1 };
19
+
20
+ public static string Encode(byte[] data)
21
+ {
22
+ if (data == null)
23
+ {
24
+ return null;
25
+ }
26
+
27
+ StringBuilder stringBuilder = StringBuilderCache.Value;
28
+ stringBuilder.Clear();
29
+ int index = 0;
30
+
31
+ byte[] chunk = ChunkCache.Value;
32
+ char[] encoded = EncodedCache.Value;
33
+ while (index < data.Length)
34
+ {
35
+ Array.Clear(chunk, 0, chunk.Length);
36
+ int chunkLength = 0;
37
+
38
+ for (int i = 0; i < 4 && index < data.Length; ++i)
39
+ {
40
+ chunk[i] = data[index++];
41
+ chunkLength++;
42
+ }
43
+
44
+ uint val =
45
+ ((uint)chunk[0] << 24)
46
+ | ((uint)chunk[1] << 16)
47
+ | ((uint)chunk[2] << 8)
48
+ | chunk[3];
49
+
50
+ if (val == 0 && chunkLength == 4)
51
+ {
52
+ stringBuilder.Append('z');
53
+ continue;
54
+ }
55
+
56
+ Array.Clear(encoded, 0, encoded.Length);
57
+ for (int i = 0; i < encoded.Length; ++i)
58
+ {
59
+ encoded[i] = (char)(val / Pow85[i] + '!');
60
+ val %= Pow85[i];
61
+ }
62
+
63
+ for (int i = 0; i < chunkLength + 1; ++i)
64
+ {
65
+ stringBuilder.Append(encoded[i]);
66
+ }
67
+ }
68
+ return stringBuilder.ToString();
69
+ }
70
+
71
+ public static byte[] Decode(string encoded)
72
+ {
73
+ if (string.IsNullOrEmpty(encoded))
74
+ {
75
+ return Array.Empty<byte>();
76
+ }
77
+
78
+ encoded = encoded.Replace("z", "!!!!!");
79
+
80
+ List<byte> result = ByteListCache.Value;
81
+ result.Clear();
82
+ int index = 0;
83
+ char[] chunk = EncodedCache.Value;
84
+ byte[] decodedBytes = ChunkCache.Value;
85
+ while (index < encoded.Length)
86
+ {
87
+ Array.Fill(chunk, (char)117);
88
+ int chunkLen = 0;
89
+
90
+ for (int i = 0; i < 5 && index < encoded.Length; ++i)
91
+ {
92
+ chunk[i] = encoded[index++];
93
+ chunkLen++;
94
+ }
95
+
96
+ uint val = 0;
97
+ for (int i = 0; i < 5; ++i)
98
+ {
99
+ val += (uint)(chunk[i] - '!') * Pow85[i];
100
+ }
101
+
102
+ decodedBytes[0] = (byte)(val >> 24);
103
+ decodedBytes[1] = (byte)(val >> 16);
104
+ decodedBytes[2] = (byte)(val >> 8);
105
+ decodedBytes[3] = (byte)val;
106
+
107
+ for (int i = 0; i < chunkLen - 1; ++i)
108
+ {
109
+ result.Add(decodedBytes[i]);
110
+ }
111
+ }
112
+ return result.ToArray();
113
+ }
114
+ }
115
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 852c7e2a84f64cfc9e5e44b0f5d1f597
3
+ timeCreated: 1756399903
@@ -0,0 +1,53 @@
1
+ namespace WallstopStudios.UnityHelpers.Utils
2
+ {
3
+ // LzmaHelper.cs - A wrapper for the LZMA SDK
4
+ using System;
5
+ using System.IO;
6
+ using System.Threading;
7
+ using SevenZip.Compression.LZMA;
8
+
9
+ public static class LZMA
10
+ {
11
+ private static readonly ThreadLocal<Decoder> Decoders = new(() => new Decoder());
12
+ private static readonly ThreadLocal<Encoder> Encoders = new(() => new Encoder());
13
+ private static readonly ThreadLocal<byte[]> Properties = new(() => new byte[5]);
14
+ private static readonly ThreadLocal<byte[]> FileLengths = new(() => new byte[8]);
15
+
16
+ public static byte[] Compress(byte[] input)
17
+ {
18
+ Encoder encoder = Encoders.Value;
19
+ using MemoryStream inStream = new(input, writable: false);
20
+ using MemoryStream outStream = new();
21
+ encoder.WriteCoderProperties(outStream);
22
+
23
+ // Write original file size
24
+ outStream.Write(BitConverter.GetBytes(inStream.Length), 0, 8);
25
+
26
+ // Compress the data
27
+ encoder.Code(inStream, outStream, inStream.Length, -1, null);
28
+ return outStream.ToArray();
29
+ }
30
+
31
+ public static byte[] Decompress(byte[] input)
32
+ {
33
+ Decoder decoder = Decoders.Value;
34
+ using MemoryStream inStream = new(input, writable: false);
35
+ using MemoryStream outStream = new();
36
+ // Read decoder properties
37
+ byte[] properties = Properties.Value;
38
+ Array.Clear(properties, 0, properties.Length);
39
+ inStream.Read(properties, 0, properties.Length);
40
+ decoder.SetDecoderProperties(properties);
41
+
42
+ // Read original file size
43
+ byte[] fileLengthBytes = FileLengths.Value;
44
+ Array.Clear(fileLengthBytes, 0, fileLengthBytes.Length);
45
+ inStream.Read(fileLengthBytes, 0, 8);
46
+ long fileLength = BitConverter.ToInt64(fileLengthBytes, 0);
47
+
48
+ // Decompress the data
49
+ decoder.Code(inStream, outStream, inStream.Length, fileLength, null);
50
+ return outStream.ToArray();
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: a40192abcf3c407080bcba2fc551e225
3
+ timeCreated: 1756402526
@@ -0,0 +1,61 @@
1
+ // Common/CRC.cs
2
+
3
+ namespace SevenZip
4
+ {
5
+ class CRC
6
+ {
7
+ public static readonly uint[] Table;
8
+
9
+ static CRC()
10
+ {
11
+ Table = new uint[256];
12
+ const uint kPoly = 0xEDB88320;
13
+ for (uint i = 0; i < 256; i++)
14
+ {
15
+ uint r = i;
16
+ for (int j = 0; j < 8; j++)
17
+ if ((r & 1) != 0)
18
+ r = (r >> 1) ^ kPoly;
19
+ else
20
+ r >>= 1;
21
+ Table[i] = r;
22
+ }
23
+ }
24
+
25
+ uint _value = 0xFFFFFFFF;
26
+
27
+ public void Init()
28
+ {
29
+ _value = 0xFFFFFFFF;
30
+ }
31
+
32
+ public void UpdateByte(byte b)
33
+ {
34
+ _value = Table[(((byte)(_value)) ^ b)] ^ (_value >> 8);
35
+ }
36
+
37
+ public void Update(byte[] data, uint offset, uint size)
38
+ {
39
+ for (uint i = 0; i < size; i++)
40
+ _value = Table[(((byte)(_value)) ^ data[offset + i])] ^ (_value >> 8);
41
+ }
42
+
43
+ public uint GetDigest()
44
+ {
45
+ return _value ^ 0xFFFFFFFF;
46
+ }
47
+
48
+ static uint CalculateDigest(byte[] data, uint offset, uint size)
49
+ {
50
+ CRC crc = new CRC();
51
+ // crc.Init();
52
+ crc.Update(data, offset, size);
53
+ return crc.GetDigest();
54
+ }
55
+
56
+ static bool VerifyDigest(uint digest, byte[] data, uint offset, uint size)
57
+ {
58
+ return (CalculateDigest(data, offset, size) == digest);
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 3dc8670f79b8cc04ebf2dc9503c3b212
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,71 @@
1
+ // InBuffer.cs
2
+
3
+ namespace SevenZip.Buffer
4
+ {
5
+ public class InBuffer
6
+ {
7
+ byte[] m_Buffer;
8
+ uint m_Pos;
9
+ uint m_Limit;
10
+ uint m_BufferSize;
11
+ System.IO.Stream m_Stream;
12
+ bool m_StreamWasExhausted;
13
+ ulong m_ProcessedSize;
14
+
15
+ public InBuffer(uint bufferSize)
16
+ {
17
+ m_Buffer = new byte[bufferSize];
18
+ m_BufferSize = bufferSize;
19
+ }
20
+
21
+ public void Init(System.IO.Stream stream)
22
+ {
23
+ m_Stream = stream;
24
+ m_ProcessedSize = 0;
25
+ m_Limit = 0;
26
+ m_Pos = 0;
27
+ m_StreamWasExhausted = false;
28
+ }
29
+
30
+ public bool ReadBlock()
31
+ {
32
+ if (m_StreamWasExhausted)
33
+ return false;
34
+ m_ProcessedSize += m_Pos;
35
+ int aNumProcessedBytes = m_Stream.Read(m_Buffer, 0, (int)m_BufferSize);
36
+ m_Pos = 0;
37
+ m_Limit = (uint)aNumProcessedBytes;
38
+ m_StreamWasExhausted = (aNumProcessedBytes == 0);
39
+ return (!m_StreamWasExhausted);
40
+ }
41
+
42
+ public void ReleaseStream()
43
+ {
44
+ // m_Stream.Close();
45
+ m_Stream = null;
46
+ }
47
+
48
+ public bool ReadByte(byte b) // check it
49
+ {
50
+ if (m_Pos >= m_Limit)
51
+ if (!ReadBlock())
52
+ return false;
53
+ b = m_Buffer[m_Pos++];
54
+ return true;
55
+ }
56
+
57
+ public byte ReadByte()
58
+ {
59
+ // return (byte)m_Stream.ReadByte();
60
+ if (m_Pos >= m_Limit)
61
+ if (!ReadBlock())
62
+ return 0xFF;
63
+ return m_Buffer[m_Pos++];
64
+ }
65
+
66
+ public ulong GetProcessedSize()
67
+ {
68
+ return m_ProcessedSize + m_Pos;
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: d9ac1800f49f3ef49b15cedc6801f985
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,65 @@
1
+ // OutBuffer.cs
2
+
3
+ namespace SevenZip.Buffer
4
+ {
5
+ public class OutBuffer
6
+ {
7
+ byte[] m_Buffer;
8
+ uint m_Pos;
9
+ uint m_BufferSize;
10
+ System.IO.Stream m_Stream;
11
+ ulong m_ProcessedSize;
12
+
13
+ public OutBuffer(uint bufferSize)
14
+ {
15
+ m_Buffer = new byte[bufferSize];
16
+ m_BufferSize = bufferSize;
17
+ }
18
+
19
+ public void SetStream(System.IO.Stream stream)
20
+ {
21
+ m_Stream = stream;
22
+ }
23
+
24
+ public void FlushStream()
25
+ {
26
+ m_Stream.Flush();
27
+ }
28
+
29
+ public void CloseStream()
30
+ {
31
+ m_Stream.Close();
32
+ }
33
+
34
+ public void ReleaseStream()
35
+ {
36
+ m_Stream = null;
37
+ }
38
+
39
+ public void Init()
40
+ {
41
+ m_ProcessedSize = 0;
42
+ m_Pos = 0;
43
+ }
44
+
45
+ public void WriteByte(byte b)
46
+ {
47
+ m_Buffer[m_Pos++] = b;
48
+ if (m_Pos >= m_BufferSize)
49
+ FlushData();
50
+ }
51
+
52
+ public void FlushData()
53
+ {
54
+ if (m_Pos == 0)
55
+ return;
56
+ m_Stream.Write(m_Buffer, 0, (int)m_Pos);
57
+ m_Pos = 0;
58
+ }
59
+
60
+ public ulong GetProcessedSize()
61
+ {
62
+ return m_ProcessedSize + m_Pos;
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 694fae53bf0755f4daf26b34bc69017c
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 1aabbf2e9b0c44cab7a350196de304ee
3
+ timeCreated: 1756403037
@@ -0,0 +1,28 @@
1
+ // IMatchFinder.cs
2
+
3
+ using System;
4
+
5
+ namespace SevenZip.Compression.LZ
6
+ {
7
+ interface IInWindowStream
8
+ {
9
+ void SetStream(System.IO.Stream inStream);
10
+ void Init();
11
+ void ReleaseStream();
12
+ Byte GetIndexByte(Int32 index);
13
+ UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit);
14
+ UInt32 GetNumAvailableBytes();
15
+ }
16
+
17
+ interface IMatchFinder : IInWindowStream
18
+ {
19
+ void Create(
20
+ UInt32 historySize,
21
+ UInt32 keepAddBufferBefore,
22
+ UInt32 matchMaxLen,
23
+ UInt32 keepAddBufferAfter
24
+ );
25
+ UInt32 GetMatches(UInt32[] distances);
26
+ void Skip(UInt32 num);
27
+ }
28
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: faf30c7802a24124cb5e5942544e622c
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: