@solana/codecs-data-structures 2.0.0-experimental.3690b65 → 2.0.0-experimental.3bc22e7

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 (44) hide show
  1. package/dist/index.browser.cjs +343 -430
  2. package/dist/index.browser.cjs.map +1 -1
  3. package/dist/index.browser.js +345 -428
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.development.js +475 -540
  6. package/dist/index.development.js.map +1 -1
  7. package/dist/index.native.js +343 -428
  8. package/dist/index.native.js.map +1 -1
  9. package/dist/index.node.cjs +343 -430
  10. package/dist/index.node.cjs.map +1 -1
  11. package/dist/index.node.js +343 -428
  12. package/dist/index.node.js.map +1 -1
  13. package/dist/index.production.min.js +36 -40
  14. package/dist/types/array.d.ts +50 -6
  15. package/dist/types/array.d.ts.map +1 -0
  16. package/dist/types/assertions.d.ts.map +1 -0
  17. package/dist/types/bit-array.d.ts +5 -5
  18. package/dist/types/bit-array.d.ts.map +1 -0
  19. package/dist/types/boolean.d.ts +18 -6
  20. package/dist/types/boolean.d.ts.map +1 -0
  21. package/dist/types/bytes.d.ts +14 -5
  22. package/dist/types/bytes.d.ts.map +1 -0
  23. package/dist/types/data-enum.d.ts +14 -14
  24. package/dist/types/data-enum.d.ts.map +1 -0
  25. package/dist/types/index.d.ts +0 -1
  26. package/dist/types/index.d.ts.map +1 -0
  27. package/dist/types/map.d.ts +39 -6
  28. package/dist/types/map.d.ts.map +1 -0
  29. package/dist/types/nullable.d.ts +24 -6
  30. package/dist/types/nullable.d.ts.map +1 -0
  31. package/dist/types/scalar-enum.d.ts +18 -6
  32. package/dist/types/scalar-enum.d.ts.map +1 -0
  33. package/dist/types/set.d.ts +39 -6
  34. package/dist/types/set.d.ts.map +1 -0
  35. package/dist/types/struct.d.ts +28 -18
  36. package/dist/types/struct.d.ts.map +1 -0
  37. package/dist/types/tuple.d.ts +22 -15
  38. package/dist/types/tuple.d.ts.map +1 -0
  39. package/dist/types/unit.d.ts +4 -12
  40. package/dist/types/unit.d.ts.map +1 -0
  41. package/dist/types/utils.d.ts +10 -2
  42. package/dist/types/utils.d.ts.map +1 -0
  43. package/package.json +5 -5
  44. package/dist/types/array-like-codec-size.d.ts +0 -20
@@ -1,36 +1,43 @@
1
- import { BaseCodecConfig, Codec, Decoder, Encoder } from '@solana/codecs-core';
2
- /** Defines the config for tuple codecs. */
3
- export type TupleCodecConfig = BaseCodecConfig;
4
- type WrapInEncoder<T> = {
5
- [P in keyof T]: Encoder<T[P]>;
1
+ import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
2
+ type WrapInFixedSizeEncoder<TFrom> = {
3
+ [P in keyof TFrom]: FixedSizeEncoder<TFrom[P]>;
6
4
  };
7
- type WrapInDecoder<T> = {
8
- [P in keyof T]: Decoder<T[P]>;
5
+ type WrapInEncoder<TFrom> = {
6
+ [P in keyof TFrom]: Encoder<TFrom[P]>;
9
7
  };
10
- type WrapInCodec<T, U extends T = T> = {
11
- [P in keyof T]: Codec<T[P], U[P]>;
8
+ type WrapInFixedSizeDecoder<TTo> = {
9
+ [P in keyof TTo]: FixedSizeDecoder<TTo[P]>;
10
+ };
11
+ type WrapInDecoder<TTo> = {
12
+ [P in keyof TTo]: Decoder<TTo[P]>;
13
+ };
14
+ type WrapInCodec<TFrom, TTo extends TFrom> = {
15
+ [P in keyof TFrom]: Codec<TFrom[P], TTo[P]>;
16
+ };
17
+ type WrapInFixedSizeCodec<TFrom, TTo extends TFrom> = {
18
+ [P in keyof TFrom]: FixedSizeCodec<TFrom[P], TTo[P]>;
12
19
  };
13
20
  type AnyArray = any[];
14
21
  /**
15
22
  * Creates a encoder for a tuple-like array.
16
23
  *
17
24
  * @param items - The encoders to use for each item in the tuple.
18
- * @param config - A set of config for the encoder.
19
25
  */
20
- export declare function getTupleEncoder<T extends AnyArray>(items: WrapInEncoder<[...T]>, config?: TupleCodecConfig): Encoder<T>;
26
+ export declare function getTupleEncoder<TFrom extends AnyArray>(items: WrapInFixedSizeEncoder<[...TFrom]>): FixedSizeEncoder<TFrom>;
27
+ export declare function getTupleEncoder<TFrom extends AnyArray>(items: WrapInEncoder<[...TFrom]>): VariableSizeEncoder<TFrom>;
21
28
  /**
22
29
  * Creates a decoder for a tuple-like array.
23
30
  *
24
31
  * @param items - The decoders to use for each item in the tuple.
25
- * @param config - A set of config for the decoder.
26
32
  */
27
- export declare function getTupleDecoder<T extends AnyArray>(items: WrapInDecoder<[...T]>, config?: TupleCodecConfig): Decoder<T>;
33
+ export declare function getTupleDecoder<TTo extends AnyArray>(items: WrapInFixedSizeDecoder<[...TTo]>): FixedSizeDecoder<TTo>;
34
+ export declare function getTupleDecoder<TTo extends AnyArray>(items: WrapInDecoder<[...TTo]>): VariableSizeDecoder<TTo>;
28
35
  /**
29
36
  * Creates a codec for a tuple-like array.
30
37
  *
31
38
  * @param items - The codecs to use for each item in the tuple.
32
- * @param config - A set of config for the codec.
33
39
  */
34
- export declare function getTupleCodec<T extends AnyArray, U extends T = T>(items: WrapInCodec<[...T], [...U]>, config?: TupleCodecConfig): Codec<T, U>;
40
+ export declare function getTupleCodec<TFrom extends AnyArray, TTo extends TFrom = TFrom>(items: WrapInFixedSizeCodec<[...TFrom], [...TTo]>): FixedSizeCodec<TFrom, TTo>;
41
+ export declare function getTupleCodec<TFrom extends AnyArray, TTo extends TFrom = TFrom>(items: WrapInCodec<[...TFrom], [...TTo]>): VariableSizeCodec<TFrom, TTo>;
35
42
  export {};
36
43
  //# sourceMappingURL=tuple.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tuple.d.ts","sourceRoot":"","sources":["../../src/tuple.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAIL,OAAO,EACP,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAEhB,iBAAiB,EACjB,mBAAmB,EACnB,mB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AAmB,CAAC,KAAK,CAAC,CAAC;AAuBtH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,SAAS,QAAQ,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;AACtH,wBAAgB,eAAe,CAAC,GAAG,SAAS,QAAQ,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;AAmBhH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,SAAS,QAAQ,EAAE,GAAG,SAAS,KAAK,GAAG,KAAK,EAC3E,KAAK,EAAE,oBAAoB,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAClD,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC9B,wBAAgB,aAAa,CAAC,KAAK,SAAS,QAAQ,EAAE,GAAG,SAAS,KAAK,GAAG,KAAK,EAC3E,KAAK,EAAE,WAAW,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GACzC,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC"}
@@ -1,22 +1,14 @@
1
- import { BaseCodecConfig, Codec, Decoder, Encoder } from '@solana/codecs-core';
2
- /** Defines the config for unit codecs. */
3
- export type UnitSerializerconfig = BaseCodecConfig;
1
+ import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
4
2
  /**
5
3
  * Creates a void encoder.
6
- *
7
- * @param config - A set of config for the encoder.
8
4
  */
9
- export declare function getUnitEncoder(config?: UnitSerializerconfig): Encoder<void>;
5
+ export declare function getUnitEncoder(): FixedSizeEncoder<void, 0>;
10
6
  /**
11
7
  * Creates a void decoder.
12
- *
13
- * @param config - A set of config for the decoder.
14
8
  */
15
- export declare function getUnitDecoder(config?: UnitSerializerconfig): Decoder<void>;
9
+ export declare function getUnitDecoder(): FixedSizeDecoder<void, 0>;
16
10
  /**
17
11
  * Creates a void codec.
18
- *
19
- * @param config - A set of config for the codec.
20
12
  */
21
- export declare function getUnitCodec(config?: UnitSerializerconfig): Codec<void>;
13
+ export declare function getUnitCodec(): FixedSizeCodec<void, void, 0>;
22
14
  //# sourceMappingURL=unit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit.d.ts","sourceRoot":"","sources":["../../src/unit.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACnB,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,wBAAgB,cAAc,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,CAK1D;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC,CAK1D;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAE5D"}
@@ -1,5 +1,13 @@
1
- /** Returns the max size or null if at least one size is null. */
2
1
  export declare function maxCodecSizes(sizes: (number | null)[]): number | null;
3
- /** Returns the sum of all sizes or null if at least one size is null. */
4
2
  export declare function sumCodecSizes(sizes: (number | null)[]): number | null;
3
+ export declare function getFixedSize(codec: {
4
+ fixedSize: number;
5
+ } | {
6
+ maxSize?: number;
7
+ }): number | null;
8
+ export declare function getMaxSize(codec: {
9
+ fixedSize: number;
10
+ } | {
11
+ maxSize?: number;
12
+ }): number | null;
5
13
  //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,CAKrE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,CAErE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAE/F;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAE7F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/codecs-data-structures",
3
- "version": "2.0.0-experimental.3690b65",
3
+ "version": "2.0.0-experimental.3bc22e7",
4
4
  "description": "Codecs for various data structures",
5
5
  "exports": {
6
6
  "browser": {
@@ -49,8 +49,8 @@
49
49
  "node": ">=17.4"
50
50
  },
51
51
  "dependencies": {
52
- "@solana/codecs-core": "2.0.0-experimental.3690b65",
53
- "@solana/codecs-numbers": "2.0.0-experimental.3690b65"
52
+ "@solana/codecs-core": "2.0.0-experimental.3bc22e7",
53
+ "@solana/codecs-numbers": "2.0.0-experimental.3bc22e7"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@solana/eslint-config-solana": "^1.0.2",
@@ -66,11 +66,11 @@
66
66
  "jest-environment-jsdom": "^29.7.0",
67
67
  "jest-runner-eslint": "^2.1.2",
68
68
  "jest-runner-prettier": "^1.0.0",
69
- "prettier": "^2.8",
69
+ "prettier": "^3.1",
70
70
  "tsup": "^8.0.1",
71
71
  "typescript": "^5.2.2",
72
72
  "version-from-git": "^1.1.1",
73
- "@solana/codecs-strings": "2.0.0-experimental.3690b65",
73
+ "@solana/codecs-strings": "2.0.0-experimental.3bc22e7",
74
74
  "build-scripts": "0.0.0",
75
75
  "test-config": "0.0.0",
76
76
  "tsconfig": "0.0.0"
@@ -1,20 +0,0 @@
1
- import { CodecData, Offset } from '@solana/codecs-core';
2
- import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
3
- /**
4
- * Represents all the size options for array-like codecs
5
- * — i.e. `array`, `map` and `set`.
6
- *
7
- * It can be one of the following:
8
- * - a {@link NumberCodec} that prefixes its content with its size.
9
- * - a fixed number of items.
10
- * - or `'remainder'` to infer the number of items by dividing
11
- * the rest of the byte array by the fixed size of its item.
12
- * Note that this option is only available for fixed-size items.
13
- */
14
- export type ArrayLikeCodecSize<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder | CodecData> = TPrefix | number | 'remainder';
15
- /** Resolves the size of an array-like codec. */
16
- export declare function decodeArrayLikeCodecSize(size: ArrayLikeCodecSize<NumberDecoder>, childrenSizes: (number | null)[], bytes: Uint8Array, offset: Offset): [number | bigint, Offset];
17
- export declare function getArrayLikeCodecSizeDescription(size: ArrayLikeCodecSize<CodecData>): string;
18
- export declare function getArrayLikeCodecSizeFromChildren(size: ArrayLikeCodecSize<CodecData>, childrenSizes: (number | null)[]): number | null;
19
- export declare function getArrayLikeCodecSizePrefix(size: ArrayLikeCodecSize<NumberEncoder>, realSize: number): Uint8Array;
20
- //# sourceMappingURL=array-like-codec-size.d.ts.map