Skip to content

Commit cf7b7d8

Browse files
authored
feat: GZIP (#109)
* Pus * gzip * Push * Buffer.from * Format * Add changeset * Push * Remove deps * Rvert back to original lib.rs * Push * Refactor decompress function * Autogenerate * Format * deferred * Fix tests * Remove blob coments * Message queue. Untested * Fix test * Chunked decompress
1 parent 221ac62 commit cf7b7d8

33 files changed

+953
-903
lines changed

.changeset/dull-mangos-appear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clockworklabs/spacetimedb-sdk': patch
3+
---
4+
5+
fix: websocket message handling, Buffer, onConnect

packages/sdk/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@
4343
},
4444
"devDependencies": {
4545
"@clockworklabs/test-app": "file:../test-app",
46-
"@types/brotli": "1.3.3",
47-
"brotli": "1.3.3",
48-
"buffer": "^6.0.3",
4946
"tsup": "^8.1.0",
5047
"undici": "^6.19.2"
5148
}

packages/sdk/src/client_api/bsatn_row_list_type.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ import {
3434
SumTypeVariant,
3535
// @ts-ignore
3636
TableCache,
37-
} from '../index';
37+
// @ts-ignore
38+
deepEqual,
39+
} from '..';
3840
// @ts-ignore
3941
import { RowSizeHint as __RowSizeHint } from './row_size_hint_type';
4042

packages/sdk/src/client_api/call_reducer_type.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ import {
3434
SumTypeVariant,
3535
// @ts-ignore
3636
TableCache,
37-
} from '../index';
37+
// @ts-ignore
38+
deepEqual,
39+
} from '..';
3840
export type CallReducer = {
3941
reducer: string;
4042
args: Uint8Array;

packages/sdk/src/client_api/client_message_type.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ import {
3434
SumTypeVariant,
3535
// @ts-ignore
3636
TableCache,
37-
} from '../index';
37+
// @ts-ignore
38+
deepEqual,
39+
} from '..';
3840
// @ts-ignore
3941
import { CallReducer as __CallReducer } from './call_reducer_type';
4042
// @ts-ignore

packages/sdk/src/client_api/compressable_query_update_type.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ import {
3434
SumTypeVariant,
3535
// @ts-ignore
3636
TableCache,
37-
} from '../index';
37+
// @ts-ignore
38+
deepEqual,
39+
} from '..';
3840
// @ts-ignore
3941
import { QueryUpdate as __QueryUpdate } from './query_update_type';
4042

@@ -45,6 +47,7 @@ export namespace CompressableQueryUpdate {
4547
// the tagged union.
4648
export type Uncompressed = { tag: 'Uncompressed'; value: __QueryUpdate };
4749
export type Brotli = { tag: 'Brotli'; value: Uint8Array };
50+
export type Gzip = { tag: 'Gzip'; value: Uint8Array };
4851

4952
// Helper functions for constructing each variant of the tagged union.
5053
// ```
@@ -59,6 +62,10 @@ export namespace CompressableQueryUpdate {
5962
tag: 'Brotli',
6063
value,
6164
});
65+
export const Gzip = (value: Uint8Array): CompressableQueryUpdate => ({
66+
tag: 'Gzip',
67+
value,
68+
});
6269

6370
export function getTypeScriptAlgebraicType(): AlgebraicType {
6471
return AlgebraicType.createSumType([
@@ -70,6 +77,10 @@ export namespace CompressableQueryUpdate {
7077
'Brotli',
7178
AlgebraicType.createArrayType(AlgebraicType.createU8Type())
7279
),
80+
new SumTypeVariant(
81+
'Gzip',
82+
AlgebraicType.createArrayType(AlgebraicType.createU8Type())
83+
),
7384
]);
7485
}
7586

@@ -93,6 +104,7 @@ export namespace CompressableQueryUpdate {
93104
// The tagged union or sum type for the algebraic type `CompressableQueryUpdate`.
94105
export type CompressableQueryUpdate =
95106
| CompressableQueryUpdate.Uncompressed
96-
| CompressableQueryUpdate.Brotli;
107+
| CompressableQueryUpdate.Brotli
108+
| CompressableQueryUpdate.Gzip;
97109

98110
export default CompressableQueryUpdate;

packages/sdk/src/client_api/database_update_type.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ import {
3434
SumTypeVariant,
3535
// @ts-ignore
3636
TableCache,
37-
} from '../index';
37+
// @ts-ignore
38+
deepEqual,
39+
} from '..';
3840
// @ts-ignore
3941
import { TableUpdate as __TableUpdate } from './table_update_type';
4042

packages/sdk/src/client_api/energy_quanta_type.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ import {
3434
SumTypeVariant,
3535
// @ts-ignore
3636
TableCache,
37-
} from '../index';
37+
// @ts-ignore
38+
deepEqual,
39+
} from '..';
3840
export type EnergyQuanta = {
3941
quanta: bigint;
4042
};

packages/sdk/src/client_api/identity_token_type.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ import {
3434
SumTypeVariant,
3535
// @ts-ignore
3636
TableCache,
37-
} from '../index';
37+
// @ts-ignore
38+
deepEqual,
39+
} from '..';
3840
export type IdentityToken = {
3941
identity: Identity;
4042
token: string;

packages/sdk/src/client_api/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ import {
3434
SumTypeVariant,
3535
// @ts-ignore
3636
TableCache,
37-
} from '../index';
37+
// @ts-ignore
38+
deepEqual,
39+
} from '..';
3840

3941
// Import and reexport all reducer arg types
4042

0 commit comments

Comments
 (0)