fix(core): 移除fflate依赖,修复TextEncoder兼容性问题 (#217)
* fix(core): 移除fflate依赖,修复TextEncoder兼容性问题 * fix(core): 移除fflate依赖,修复TextEncoder兼容性问题
This commit is contained in:
@@ -487,7 +487,7 @@ describe('Incremental Serialization System', () => {
|
||||
expect(prettyJson).toContain(' ');
|
||||
});
|
||||
|
||||
it('二进制格式应该比JSON格式更小', () => {
|
||||
it('二进制格式应该可以正常序列化', () => {
|
||||
const entities = [];
|
||||
for (let i = 0; i < 50; i++) {
|
||||
const entity = scene.createEntity(`Entity_${i}`);
|
||||
@@ -506,13 +506,10 @@ describe('Incremental Serialization System', () => {
|
||||
|
||||
const incremental = scene.serializeIncremental();
|
||||
|
||||
const jsonData = IncrementalSerializer.serializeIncremental(incremental, { format: 'json' });
|
||||
const binaryData = IncrementalSerializer.serializeIncremental(incremental, { format: 'binary' });
|
||||
|
||||
const jsonSize = Buffer.byteLength(jsonData as string);
|
||||
const binarySize = (binaryData as Buffer).length;
|
||||
|
||||
expect(binarySize).toBeLessThan(jsonSize);
|
||||
expect(binaryData).toBeInstanceOf(Uint8Array);
|
||||
expect(binaryData.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('二进制和JSON格式应该包含相同的数据', () => {
|
||||
|
||||
@@ -559,15 +559,7 @@ describe('ECS Serialization System', () => {
|
||||
|
||||
// 验证是Uint8Array类型
|
||||
expect(binaryData instanceof Uint8Array).toBe(true);
|
||||
|
||||
// JSON序列化对比
|
||||
const jsonData = scene1.serialize({ format: 'json', pretty: false });
|
||||
|
||||
// 二进制应该更小
|
||||
const binarySize = (binaryData as Uint8Array).length;
|
||||
const jsonSize = (jsonData as string).length;
|
||||
console.log(`Binary size: ${binarySize} bytes, JSON size: ${jsonSize} bytes`);
|
||||
expect(binarySize).toBeLessThan(jsonSize);
|
||||
expect((binaryData as Uint8Array).length).toBeGreaterThan(0);
|
||||
|
||||
// 新场景反序列化二进制数据
|
||||
const scene2 = new Scene({ name: 'LoadTest' });
|
||||
|
||||
Reference in New Issue
Block a user