@solana/codecs-data-structures 2.0.0-experimental.5e8ac8d

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 (48) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +25 -0
  3. package/dist/index.browser.cjs +662 -0
  4. package/dist/index.browser.cjs.map +1 -0
  5. package/dist/index.browser.js +620 -0
  6. package/dist/index.browser.js.map +1 -0
  7. package/dist/index.development.js +865 -0
  8. package/dist/index.development.js.map +1 -0
  9. package/dist/index.native.js +620 -0
  10. package/dist/index.native.js.map +1 -0
  11. package/dist/index.node.cjs +662 -0
  12. package/dist/index.node.cjs.map +1 -0
  13. package/dist/index.node.js +620 -0
  14. package/dist/index.node.js.map +1 -0
  15. package/dist/index.production.min.js +51 -0
  16. package/dist/types/array-like-codec-size.d.ts +20 -0
  17. package/dist/types/array-like-codec-size.d.ts.map +1 -0
  18. package/dist/types/array.d.ts +33 -0
  19. package/dist/types/array.d.ts.map +1 -0
  20. package/dist/types/assertions.d.ts +3 -0
  21. package/dist/types/assertions.d.ts.map +1 -0
  22. package/dist/types/bit-array.d.ts +31 -0
  23. package/dist/types/bit-array.d.ts.map +1 -0
  24. package/dist/types/boolean.d.ts +29 -0
  25. package/dist/types/boolean.d.ts.map +1 -0
  26. package/dist/types/bytes.d.ts +32 -0
  27. package/dist/types/bytes.d.ts.map +1 -0
  28. package/dist/types/data-enum.d.ts +90 -0
  29. package/dist/types/data-enum.d.ts.map +1 -0
  30. package/dist/types/index.d.ts +15 -0
  31. package/dist/types/index.d.ts.map +1 -0
  32. package/dist/types/map.d.ts +36 -0
  33. package/dist/types/map.d.ts.map +1 -0
  34. package/dist/types/nullable.d.ts +41 -0
  35. package/dist/types/nullable.d.ts.map +1 -0
  36. package/dist/types/scalar-enum.d.ts +44 -0
  37. package/dist/types/scalar-enum.d.ts.map +1 -0
  38. package/dist/types/set.d.ts +33 -0
  39. package/dist/types/set.d.ts.map +1 -0
  40. package/dist/types/struct.d.ts +37 -0
  41. package/dist/types/struct.d.ts.map +1 -0
  42. package/dist/types/tuple.d.ts +36 -0
  43. package/dist/types/tuple.d.ts.map +1 -0
  44. package/dist/types/unit.d.ts +22 -0
  45. package/dist/types/unit.d.ts.map +1 -0
  46. package/dist/types/utils.d.ts +5 -0
  47. package/dist/types/utils.d.ts.map +1 -0
  48. package/package.json +101 -0
@@ -0,0 +1,41 @@
1
+ import { BaseCodecOptions, Codec, Decoder, Encoder } from '@solana/codecs-core';
2
+ import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
3
+ /** Defines the options for nullable codecs. */
4
+ export type NullableCodecOptions<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecOptions & {
5
+ /**
6
+ * The codec to use for the boolean prefix.
7
+ * @defaultValue u8 prefix.
8
+ */
9
+ prefix?: TPrefix;
10
+ /**
11
+ * Whether the item codec should be of fixed size.
12
+ *
13
+ * When this is true, a `null` value will skip the bytes that would
14
+ * have been used for the item. Note that this will only work if the
15
+ * item codec is of fixed size.
16
+ * @defaultValue `false`
17
+ */
18
+ fixed?: boolean;
19
+ };
20
+ /**
21
+ * Creates a encoder for an optional value using `null` as the `None` value.
22
+ *
23
+ * @param item - The encoder to use for the value that may be present.
24
+ * @param options - A set of options for the encoder.
25
+ */
26
+ export declare function getNullableEncoder<T>(item: Encoder<T>, options?: NullableCodecOptions<NumberEncoder>): Encoder<T | null>;
27
+ /**
28
+ * Creates a decoder for an optional value using `null` as the `None` value.
29
+ *
30
+ * @param item - The decoder to use for the value that may be present.
31
+ * @param options - A set of options for the decoder.
32
+ */
33
+ export declare function getNullableDecoder<T>(item: Decoder<T>, options?: NullableCodecOptions<NumberDecoder>): Decoder<T | null>;
34
+ /**
35
+ * Creates a codec for an optional value using `null` as the `None` value.
36
+ *
37
+ * @param item - The codec to use for the value that may be present.
38
+ * @param options - A set of options for the codec.
39
+ */
40
+ export declare function getNullableCodec<T, U extends T = T>(item: Codec<T, U>, options?: NullableCodecOptions<NumberCodec>): Codec<T | null, U | null>;
41
+ //# sourceMappingURL=nullable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nullable.d.ts","sourceRoot":"","sources":["../../src/nullable.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,gBAAgB,EAChB,KAAK,EAGL,OAAO,EACP,OAAO,EAGV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA8B,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAK/G,+CAA+C;AAC/C,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,WAAW,GAAG,aAAa,GAAG,aAAa,IAAI,gBAAgB,GAAG;IAC/G;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAmBF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAChC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,OAAO,GAAE,oBAAoB,CAAC,aAAa,CAAM,GAClD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAYnB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAChC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,OAAO,GAAE,oBAAoB,CAAC,aAAa,CAAM,GAClD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAoBnB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAC/C,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EACjB,OAAO,GAAE,oBAAoB,CAAC,WAAW,CAAM,GAChD,KAAK,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAE3B"}
@@ -0,0 +1,44 @@
1
+ import { BaseCodecOptions, Codec, Decoder, Encoder } from '@solana/codecs-core';
2
+ import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
3
+ /**
4
+ * Defines a scalar enum as a type from its constructor.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * enum Direction { Left, Right };
9
+ * type DirectionType = ScalarEnum<Direction>;
10
+ * ```
11
+ */
12
+ export type ScalarEnum<T> = ({
13
+ [key: number | string]: string | number | T;
14
+ } | number | T) & NonNullable<unknown>;
15
+ /** Defines the options for scalar enum codecs. */
16
+ export type ScalarEnumCodecOptions<TDiscriminator extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecOptions & {
17
+ /**
18
+ * The codec to use for the enum discriminator.
19
+ * @defaultValue u8 discriminator.
20
+ */
21
+ size?: TDiscriminator;
22
+ };
23
+ /**
24
+ * Creates a scalar enum encoder.
25
+ *
26
+ * @param constructor - The constructor of the scalar enum.
27
+ * @param options - A set of options for the encoder.
28
+ */
29
+ export declare function getScalarEnumEncoder<T>(constructor: ScalarEnum<T>, options?: ScalarEnumCodecOptions<NumberCodec>): Encoder<T>;
30
+ /**
31
+ * Creates a scalar enum decoder.
32
+ *
33
+ * @param constructor - The constructor of the scalar enum.
34
+ * @param options - A set of options for the decoder.
35
+ */
36
+ export declare function getScalarEnumDecoder<T>(constructor: ScalarEnum<T>, options?: ScalarEnumCodecOptions<NumberCodec>): Decoder<T>;
37
+ /**
38
+ * Creates a scalar enum codec.
39
+ *
40
+ * @param constructor - The constructor of the scalar enum.
41
+ * @param options - A set of options for the codec.
42
+ */
43
+ export declare function getScalarEnumCodec<T>(constructor: ScalarEnum<T>, options?: ScalarEnumCodecOptions<NumberCodec>): Codec<T>;
44
+ //# sourceMappingURL=scalar-enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalar-enum.d.ts","sourceRoot":"","sources":["../../src/scalar-enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,gBAAgB,EAChB,KAAK,EAGL,OAAO,EACP,OAAO,EACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA8B,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE/G;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,CAAA;CAAE,GAAG,MAAM,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;AAElH,kDAAkD;AAClD,MAAM,MAAM,sBAAsB,CAAC,cAAc,SAAS,WAAW,GAAG,aAAa,GAAG,aAAa,IACjG,gBAAgB,GAAG;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAmCN;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAClC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAC1B,OAAO,GAAE,sBAAsB,CAAC,WAAW,CAAM,GAClD,OAAO,CAAC,CAAC,CAAC,CA0BZ;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAClC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAC1B,OAAO,GAAE,sBAAsB,CAAC,WAAW,CAAM,GAClD,OAAO,CAAC,CAAC,CAAC,CA0BZ;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAChC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,EAC1B,OAAO,GAAE,sBAAsB,CAAC,WAAW,CAAM,GAClD,KAAK,CAAC,CAAC,CAAC,CAEV"}
@@ -0,0 +1,33 @@
1
+ import { BaseCodecOptions, Codec, Decoder, Encoder } from '@solana/codecs-core';
2
+ import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
3
+ import { ArrayLikeCodecSize } from './array-like-codec-size';
4
+ /** Defines the options for set codecs. */
5
+ export type SetCodecOptions<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecOptions & {
6
+ /**
7
+ * The size of the set.
8
+ * @defaultValue u32 prefix.
9
+ */
10
+ size?: ArrayLikeCodecSize<TPrefix>;
11
+ };
12
+ /**
13
+ * Encodes an set of items.
14
+ *
15
+ * @param item - The encoder to use for the set's items.
16
+ * @param options - A set of options for the encoder.
17
+ */
18
+ export declare function getSetEncoder<T>(item: Encoder<T>, options?: SetCodecOptions<NumberEncoder>): Encoder<Set<T>>;
19
+ /**
20
+ * Decodes an set of items.
21
+ *
22
+ * @param item - The encoder to use for the set's items.
23
+ * @param options - A set of options for the encoder.
24
+ */
25
+ export declare function getSetDecoder<T>(item: Decoder<T>, options?: SetCodecOptions<NumberDecoder>): Decoder<Set<T>>;
26
+ /**
27
+ * Creates a codec for an set of items.
28
+ *
29
+ * @param item - The codec to use for the set's items.
30
+ * @param options - A set of options for the codec.
31
+ */
32
+ export declare function getSetCodec<T, U extends T = T>(item: Codec<T, U>, options?: SetCodecOptions<NumberCodec>): Codec<Set<T>, Set<U>>;
33
+ //# sourceMappingURL=set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAA2B,OAAO,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AACrH,OAAO,EAAgC,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEjH,OAAO,EACH,kBAAkB,EAKrB,MAAM,yBAAyB,CAAC;AAGjC,0CAA0C;AAC1C,MAAM,MAAM,eAAe,CAAC,OAAO,SAAS,WAAW,GAAG,aAAa,GAAG,aAAa,IAAI,gBAAgB,GAAG;IAC1G;;;OAGG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;CACtC,CAAC;AAeF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,GAAE,eAAe,CAAC,aAAa,CAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAYhH;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,GAAE,eAAe,CAAC,aAAa,CAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAmBhH;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAC1C,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EACjB,OAAO,GAAE,eAAe,CAAC,WAAW,CAAM,GAC3C,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAEvB"}
@@ -0,0 +1,37 @@
1
+ import { BaseCodecOptions, Codec, Decoder, Encoder } from '@solana/codecs-core';
2
+ /** Get the name and encoder of each field in a struct. */
3
+ export type StructToEncoderTuple<T extends object> = Array<{
4
+ [K in keyof T]: [K, Encoder<T[K]>];
5
+ }[keyof T]>;
6
+ /** Get the name and decoder of each field in a struct. */
7
+ export type StructToDecoderTuple<T extends object> = Array<{
8
+ [K in keyof T]: [K, Decoder<T[K]>];
9
+ }[keyof T]>;
10
+ /** Get the name and codec of each field in a struct. */
11
+ export type StructToCodecTuple<T extends object, U extends T> = Array<{
12
+ [K in keyof T]: [K, Codec<T[K], U[K]>];
13
+ }[keyof T]>;
14
+ /** Defines the options for struct codecs. */
15
+ export type StructCodecOptions = BaseCodecOptions;
16
+ /**
17
+ * Creates a encoder for a custom object.
18
+ *
19
+ * @param fields - The name and encoder of each field.
20
+ * @param options - A set of options for the encoder.
21
+ */
22
+ export declare function getStructEncoder<T extends object>(fields: StructToEncoderTuple<T>, options?: StructCodecOptions): Encoder<T>;
23
+ /**
24
+ * Creates a decoder for a custom object.
25
+ *
26
+ * @param fields - The name and decoder of each field.
27
+ * @param options - A set of options for the decoder.
28
+ */
29
+ export declare function getStructDecoder<T extends object>(fields: StructToDecoderTuple<T>, options?: StructCodecOptions): Decoder<T>;
30
+ /**
31
+ * Creates a codec for a custom object.
32
+ *
33
+ * @param fields - The name and codec of each field.
34
+ * @param options - A set of options for the codec.
35
+ */
36
+ export declare function getStructCodec<T extends object, U extends T = T>(fields: StructToCodecTuple<T, U>, options?: StructCodecOptions): Codec<T, U>;
37
+ //# sourceMappingURL=struct.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["../../src/struct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAA2B,OAAO,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAIrH,0DAA0D;AAC1D,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,IAAI,KAAK,CACtD;KACK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACrC,CAAC,MAAM,CAAC,CAAC,CACb,CAAC;AAEF,0DAA0D;AAC1D,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,MAAM,IAAI,KAAK,CACtD;KACK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACrC,CAAC,MAAM,CAAC,CAAC,CACb,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,CACjE;KACK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACzC,CAAC,MAAM,CAAC,CAAC,CACb,CAAC;AAEF,6CAA6C;AAC7C,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAYlD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC7C,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAC/B,OAAO,GAAE,kBAAuB,GACjC,OAAO,CAAC,CAAC,CAAC,CAQZ;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC7C,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAC/B,OAAO,GAAE,kBAAuB,GACjC,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAC5D,MAAM,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,EAChC,OAAO,GAAE,kBAAuB,GACjC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAEb"}
@@ -0,0 +1,36 @@
1
+ import { BaseCodecOptions, Codec, Decoder, Encoder } from '@solana/codecs-core';
2
+ /** Defines the options for tuple codecs. */
3
+ export type TupleCodecOptions = BaseCodecOptions;
4
+ type WrapInEncoder<T> = {
5
+ [P in keyof T]: Encoder<T[P]>;
6
+ };
7
+ type WrapInDecoder<T> = {
8
+ [P in keyof T]: Decoder<T[P]>;
9
+ };
10
+ type WrapInCodec<T, U extends T = T> = {
11
+ [P in keyof T]: Codec<T[P], U[P]>;
12
+ };
13
+ type AnyArray = any[];
14
+ /**
15
+ * Creates a encoder for a tuple-like array.
16
+ *
17
+ * @param items - The encoders to use for each item in the tuple.
18
+ * @param options - A set of options for the encoder.
19
+ */
20
+ export declare function getTupleEncoder<T extends AnyArray>(items: WrapInEncoder<[...T]>, options?: TupleCodecOptions): Encoder<T>;
21
+ /**
22
+ * Creates a decoder for a tuple-like array.
23
+ *
24
+ * @param items - The decoders to use for each item in the tuple.
25
+ * @param options - A set of options for the decoder.
26
+ */
27
+ export declare function getTupleDecoder<T extends AnyArray>(items: WrapInDecoder<[...T]>, options?: TupleCodecOptions): Decoder<T>;
28
+ /**
29
+ * Creates a codec for a tuple-like array.
30
+ *
31
+ * @param items - The codecs to use for each item in the tuple.
32
+ * @param options - A set of options for the codec.
33
+ */
34
+ export declare function getTupleCodec<T extends AnyArray, U extends T = T>(items: WrapInCodec<[...T], [...U]>, options?: TupleCodecOptions): Codec<T, U>;
35
+ export {};
36
+ //# sourceMappingURL=tuple.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tuple.d.ts","sourceRoot":"","sources":["../../src/tuple.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAA2B,OAAO,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAKrH,4CAA4C;AAC5C,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAEjD,KAAK,aAAa,CAAC,CAAC,IAAI;KACnB,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAChC,CAAC;AACF,KAAK,aAAa,CAAC,CAAC,IAAI;KACnB,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAChC,CAAC;AACF,KAAK,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI;KAClC,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CACpC,CAAC;AAGF,KAAK,QAAQ,GAAG,GAAG,EAAE,CAAC;AAYtB;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,QAAQ,EAC9C,KAAK,EAAE,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAC5B,OAAO,GAAE,iBAAsB,GAChC,OAAO,CAAC,CAAC,CAAC,CAQZ;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,QAAQ,EAC9C,KAAK,EAAE,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAC5B,OAAO,GAAE,iBAAsB,GAChC,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,QAAQ,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAC7D,KAAK,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAClC,OAAO,GAAE,iBAAsB,GAChC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAKb"}
@@ -0,0 +1,22 @@
1
+ import { BaseCodecOptions, Codec, Decoder, Encoder } from '@solana/codecs-core';
2
+ /** Defines the options for unit codecs. */
3
+ export type UnitSerializerOptions = BaseCodecOptions;
4
+ /**
5
+ * Creates a void encoder.
6
+ *
7
+ * @param options - A set of options for the encoder.
8
+ */
9
+ export declare function getUnitEncoder(options?: UnitSerializerOptions): Encoder<void>;
10
+ /**
11
+ * Creates a void decoder.
12
+ *
13
+ * @param options - A set of options for the decoder.
14
+ */
15
+ export declare function getUnitDecoder(options?: UnitSerializerOptions): Decoder<void>;
16
+ /**
17
+ * Creates a void codec.
18
+ *
19
+ * @param options - A set of options for the codec.
20
+ */
21
+ export declare function getUnitCodec(options?: UnitSerializerOptions): Codec<void>;
22
+ //# sourceMappingURL=unit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit.d.ts","sourceRoot":"","sources":["../../src/unit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAgB,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9F,2CAA2C;AAC3C,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,qBAA0B,GAAG,KAAK,CAAC,IAAI,CAAC,CAE7E"}
@@ -0,0 +1,5 @@
1
+ /** Returns the max size or null if at least one size is null. */
2
+ 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
+ export declare function sumCodecSizes(sizes: (number | null)[]): number | null;
5
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,CAKrE;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,CAErE"}
package/package.json ADDED
@@ -0,0 +1,101 @@
1
+ {
2
+ "name": "@solana/codecs-data-structures",
3
+ "version": "2.0.0-experimental.5e8ac8d",
4
+ "description": "Codecs for various data structures",
5
+ "exports": {
6
+ "browser": {
7
+ "import": "./dist/index.browser.js",
8
+ "require": "./dist/index.browser.cjs"
9
+ },
10
+ "node": {
11
+ "import": "./dist/index.node.js",
12
+ "require": "./dist/index.node.cjs"
13
+ },
14
+ "react-native": "./dist/index.native.js",
15
+ "types": "./dist/types/index.d.ts"
16
+ },
17
+ "browser": {
18
+ "./dist/index.node.cjs": "./dist/index.browser.cjs",
19
+ "./dist/index.node.js": "./dist/index.browser.js"
20
+ },
21
+ "main": "./dist/index.node.cjs",
22
+ "module": "./dist/index.node.js",
23
+ "react-native": "./dist/index.native.js",
24
+ "types": "./dist/types/index.d.ts",
25
+ "type": "module",
26
+ "files": [
27
+ "./dist/"
28
+ ],
29
+ "sideEffects": false,
30
+ "keywords": [
31
+ "blockchain",
32
+ "solana",
33
+ "web3"
34
+ ],
35
+ "author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
36
+ "license": "MIT",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/solana-labs/solana-web3.js"
40
+ },
41
+ "bugs": {
42
+ "url": "http://github.com/solana-labs/solana-web3.js/issues"
43
+ },
44
+ "browserslist": [
45
+ "supports bigint and not dead",
46
+ "maintained node versions"
47
+ ],
48
+ "engine": {
49
+ "node": ">=17.4"
50
+ },
51
+ "dependencies": {
52
+ "@solana/codecs-core": "2.0.0-experimental.5e8ac8d",
53
+ "@solana/codecs-numbers": "2.0.0-development"
54
+ },
55
+ "devDependencies": {
56
+ "@solana/eslint-config-solana": "^1.0.2",
57
+ "@swc/jest": "^0.2.28",
58
+ "@types/jest": "^29.5.5",
59
+ "@typescript-eslint/eslint-plugin": "^6.7.0",
60
+ "@typescript-eslint/parser": "^6.3.0",
61
+ "agadoo": "^3.0.0",
62
+ "eslint": "^8.45.0",
63
+ "eslint-plugin-jest": "^27.2.3",
64
+ "eslint-plugin-sort-keys-fix": "^1.1.2",
65
+ "jest": "^29.7.0",
66
+ "jest-environment-jsdom": "^29.6.4",
67
+ "jest-runner-eslint": "^2.1.0",
68
+ "jest-runner-prettier": "^1.0.0",
69
+ "prettier": "^2.8",
70
+ "tsup": "7.2.0",
71
+ "typescript": "^5.2.2",
72
+ "version-from-git": "^1.1.1",
73
+ "@solana/codecs-strings": "2.0.0-development",
74
+ "build-scripts": "0.0.0",
75
+ "test-config": "0.0.0",
76
+ "tsconfig": "0.0.0"
77
+ },
78
+ "bundlewatch": {
79
+ "defaultCompression": "gzip",
80
+ "files": [
81
+ {
82
+ "path": "./dist/index*.js"
83
+ }
84
+ ]
85
+ },
86
+ "scripts": {
87
+ "compile:js": "tsup --config build-scripts/tsup.config.library.ts",
88
+ "compile:typedefs": "tsc -p ./tsconfig.declarations.json",
89
+ "dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
90
+ "publish-packages": "pnpm publish --tag experimental --access public --no-git-checks",
91
+ "style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/*",
92
+ "test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
93
+ "test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",
94
+ "test:treeshakability:browser": "agadoo dist/index.browser.js",
95
+ "test:treeshakability:native": "agadoo dist/index.node.js",
96
+ "test:treeshakability:node": "agadoo dist/index.native.js",
97
+ "test:typecheck": "tsc --noEmit",
98
+ "test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent",
99
+ "test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --rootDir . --silent"
100
+ }
101
+ }