@solana/codecs-strings 2.0.0-experimental.fc4e943 → 2.0.0-experimental.fcff844

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.
@@ -1,7 +1,7 @@
1
1
  /** Encodes strings in base58. */
2
- export declare const getBase58Encoder: () => import("@solana/codecs-core").Encoder<string>;
2
+ export declare const getBase58Encoder: () => import("@solana/codecs-core").VariableSizeEncoder<string>;
3
3
  /** Decodes strings in base58. */
4
- export declare const getBase58Decoder: () => import("@solana/codecs-core").Decoder<string>;
4
+ export declare const getBase58Decoder: () => import("@solana/codecs-core").VariableSizeDecoder<string>;
5
5
  /** Encodes and decodes strings in base58. */
6
- export declare const getBase58Codec: () => import("@solana/codecs-core").Codec<string>;
6
+ export declare const getBase58Codec: () => import("@solana/codecs-core").VariableSizeCodec<string>;
7
7
  //# sourceMappingURL=base58.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base58.d.ts","sourceRoot":"","sources":["../../src/base58.ts"],"names":[],"mappings":"AAIA,iCAAiC;AACjC,eAAO,MAAM,gBAAgB,iEAAkC,CAAC;AAEhE,iCAAiC;AACjC,eAAO,MAAM,gBAAgB,iEAAkC,CAAC;AAEhE,6CAA6C;AAC7C,eAAO,MAAM,cAAc,+DAAgC,CAAC"}
@@ -1,8 +1,8 @@
1
- import { Decoder, Encoder } from '@solana/codecs-core';
1
+ import { VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
2
2
  /** Encodes strings in base64. */
3
- export declare const getBase64Encoder: () => Encoder<string>;
3
+ export declare const getBase64Encoder: () => VariableSizeEncoder<string>;
4
4
  /** Decodes strings in base64. */
5
- export declare const getBase64Decoder: () => Decoder<string>;
5
+ export declare const getBase64Decoder: () => VariableSizeDecoder<string>;
6
6
  /** Encodes and decodes strings in base64. */
7
- export declare const getBase64Codec: () => import("@solana/codecs-core").Codec<string, string>;
7
+ export declare const getBase64Codec: () => VariableSizeCodec<string>;
8
8
  //# sourceMappingURL=base64.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../src/base64.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,qBAAqB,CAAC;AAO7B,iCAAiC;AACjC,eAAO,MAAM,gBAAgB,QAAO,oBAAoB,MAAM,CAuC7D,CAAC;AAEF,iCAAiC;AACjC,eAAO,MAAM,gBAAgB,QAAO,oBAAoB,MAAM,CAoB7D,CAAC;AAEF,6CAA6C;AAC7C,eAAO,MAAM,cAAc,QAAO,kBAAkB,MAAM,CAAyD,CAAC"}
@@ -1,14 +1,14 @@
1
- import { Codec, Decoder, Encoder } from '@solana/codecs-core';
1
+ import { VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
2
2
  /**
3
3
  * Encodes a string using a custom alphabet by reslicing the bits of the byte array.
4
4
  * @see {@link getBaseXResliceCodec} for a more detailed description.
5
5
  */
6
- export declare const getBaseXResliceEncoder: (alphabet: string, bits: number) => Encoder<string>;
6
+ export declare const getBaseXResliceEncoder: (alphabet: string, bits: number) => VariableSizeEncoder<string>;
7
7
  /**
8
8
  * Decodes a string using a custom alphabet by reslicing the bits of the byte array.
9
9
  * @see {@link getBaseXResliceCodec} for a more detailed description.
10
10
  */
11
- export declare const getBaseXResliceDecoder: (alphabet: string, bits: number) => Decoder<string>;
11
+ export declare const getBaseXResliceDecoder: (alphabet: string, bits: number) => VariableSizeDecoder<string>;
12
12
  /**
13
13
  * A string serializer that reslices bytes into custom chunks
14
14
  * of bits that are then mapped to a custom alphabet.
@@ -16,5 +16,5 @@ export declare const getBaseXResliceDecoder: (alphabet: string, bits: number) =>
16
16
  * This can be used to create serializers whose alphabet
17
17
  * is a power of 2 such as base16 or base64.
18
18
  */
19
- export declare const getBaseXResliceCodec: (alphabet: string, bits: number) => Codec<string>;
19
+ export declare const getBaseXResliceCodec: (alphabet: string, bits: number) => VariableSizeCodec<string>;
20
20
  //# sourceMappingURL=baseX-reslice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseX-reslice.d.ts","sourceRoot":"","sources":["../../src/baseX-reslice.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,qBAAqB,CAAC;AAI7B;;;GAGG;AACH,eAAO,MAAM,sBAAsB,aAAc,MAAM,QAAQ,MAAM,KAAG,oBAAoB,MAAM,CAW5F,CAAC;AAEP;;;GAGG;AACH,eAAO,MAAM,sBAAsB,aAAc,MAAM,QAAQ,MAAM,KAAG,oBAAoB,MAAM,CAQ5F,CAAC;AAEP;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,aAAc,MAAM,QAAQ,MAAM,KAAG,kBAAkB,MAAM,CACE,CAAC"}
@@ -1,16 +1,16 @@
1
- import { Codec, Decoder, Encoder } from '@solana/codecs-core';
1
+ import { VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
2
2
  /**
3
3
  * Encodes a string using a custom alphabet by dividing
4
4
  * by the base and handling leading zeroes.
5
5
  * @see {@link getBaseXCodec} for a more detailed description.
6
6
  */
7
- export declare const getBaseXEncoder: (alphabet: string) => Encoder<string>;
7
+ export declare const getBaseXEncoder: (alphabet: string) => VariableSizeEncoder<string>;
8
8
  /**
9
9
  * Decodes a string using a custom alphabet by dividing
10
10
  * by the base and handling leading zeroes.
11
11
  * @see {@link getBaseXCodec} for a more detailed description.
12
12
  */
13
- export declare const getBaseXDecoder: (alphabet: string) => Decoder<string>;
13
+ export declare const getBaseXDecoder: (alphabet: string) => VariableSizeDecoder<string>;
14
14
  /**
15
15
  * A string codec that requires a custom alphabet and uses
16
16
  * the length of that alphabet as the base. It then divides
@@ -20,5 +20,5 @@ export declare const getBaseXDecoder: (alphabet: string) => Decoder<string>;
20
20
  *
21
21
  * This can be used to create codecs such as base10 or base58.
22
22
  */
23
- export declare const getBaseXCodec: (alphabet: string) => Codec<string>;
23
+ export declare const getBaseXCodec: (alphabet: string) => VariableSizeCodec<string>;
24
24
  //# sourceMappingURL=baseX.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseX.d.ts","sourceRoot":"","sources":["../../src/baseX.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,qBAAqB,CAAC;AAI7B;;;;GAIG;AACH,eAAO,MAAM,eAAe,aAAc,MAAM,KAAG,oBAAoB,MAAM,CAoC5E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,aAAc,MAAM,KAAG,oBAAoB,MAAM,CAqB5E,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,aAAc,MAAM,KAAG,kBAAkB,MAAM,CACH,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"null-characters.d.ts","sourceRoot":"","sources":["../../src/null-characters.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,eAAO,MAAM,oBAAoB,UAAW,MAAM,WAElB,CAAC;AAEjC,qDAAqD;AACrD,eAAO,MAAM,iBAAiB,UAAW,MAAM,SAAS,MAAM,WAAkC,CAAC"}
@@ -1,7 +1,7 @@
1
- import { BaseCodecOptions, Codec, Decoder, Encoder } from '@solana/codecs-core';
1
+ import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
2
2
  import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
3
- /** Defines the options for string codecs. */
4
- export type StringCodecOptions<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder, TEncoding extends Codec<string> | Encoder<string> | Decoder<string>> = BaseCodecOptions & {
3
+ /** Defines the config for string codecs. */
4
+ export type StringCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder, TEncoding extends Codec<string> | Encoder<string> | Decoder<string>> = {
5
5
  /**
6
6
  * The size of the string. It can be one of the following:
7
7
  * - a {@link NumberCodec} that prefixes the string with its size.
@@ -17,9 +17,30 @@ export type StringCodecOptions<TPrefix extends NumberCodec | NumberEncoder | Num
17
17
  encoding?: TEncoding;
18
18
  };
19
19
  /** Encodes strings from a given encoding and size strategy. */
20
- export declare const getStringEncoder: (options?: StringCodecOptions<NumberEncoder, Encoder<string>>) => Encoder<string>;
20
+ export declare function getStringEncoder<TSize extends number>(config: StringCodecConfig<NumberEncoder, Encoder<string>> & {
21
+ size: TSize;
22
+ }): FixedSizeEncoder<string, TSize>;
23
+ export declare function getStringEncoder<TSize extends number>(config: StringCodecConfig<NumberEncoder, Encoder<string>> & {
24
+ size: 'variable';
25
+ encoding: FixedSizeEncoder<string, TSize>;
26
+ }): FixedSizeEncoder<string, TSize>;
27
+ export declare function getStringEncoder(config?: StringCodecConfig<NumberEncoder, Encoder<string>>): VariableSizeEncoder<string>;
21
28
  /** Decodes strings from a given encoding and size strategy. */
22
- export declare const getStringDecoder: (options?: StringCodecOptions<NumberDecoder, Decoder<string>>) => Decoder<string>;
29
+ export declare function getStringDecoder<TSize extends number>(config: StringCodecConfig<NumberDecoder, Decoder<string>> & {
30
+ size: TSize;
31
+ }): FixedSizeDecoder<string, TSize>;
32
+ export declare function getStringDecoder<TSize extends number>(config: StringCodecConfig<NumberDecoder, Decoder<string>> & {
33
+ size: 'variable';
34
+ encoding: FixedSizeDecoder<string, TSize>;
35
+ }): FixedSizeDecoder<string, TSize>;
36
+ export declare function getStringDecoder(config?: StringCodecConfig<NumberDecoder, Decoder<string>>): VariableSizeDecoder<string>;
23
37
  /** Encodes and decodes strings from a given encoding and size strategy. */
24
- export declare const getStringCodec: (options?: StringCodecOptions<NumberCodec, Codec<string>>) => Codec<string>;
38
+ export declare function getStringCodec<TSize extends number>(config: StringCodecConfig<NumberCodec, Codec<string>> & {
39
+ size: TSize;
40
+ }): FixedSizeCodec<string, string, TSize>;
41
+ export declare function getStringCodec<TSize extends number>(config: StringCodecConfig<NumberCodec, Codec<string>> & {
42
+ size: 'variable';
43
+ encoding: FixedSizeCodec<string, string, TSize>;
44
+ }): FixedSizeCodec<string, string, TSize>;
45
+ export declare function getStringCodec(config?: StringCodecConfig<NumberCodec, Codec<string>>): VariableSizeCodec<string>;
25
46
  //# sourceMappingURL=string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,EAIL,OAAO,EACP,OAAO,EAEP,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAGhB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAgC,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIjH,4CAA4C;AAC5C,MAAM,MAAM,iBAAiB,CACzB,OAAO,SAAS,WAAW,GAAG,aAAa,GAAG,aAAa,EAC3D,SAAS,SAAS,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,IACnE;IACA;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;IAErC;;;OAGG;IACH,QAAQ,CAAC,E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AC,EAAE,iBAAiB,CAAC,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,GAC3D,mBAAmB,CAAC,MAAM,CAAC,CAAC;AA4B/B,2EAA2E;AAC3E,wBAAgB,cAAc,CAAC,KAAK,SAAS,MAAM,EAC/C,MAAM,EAAE,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GACxE,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACzC,wBAAgB,cAAc,CAAC,KAAK,SAAS,MAAM,EAC/C,MAAM,EAAE,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG;IACpD,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;CACnD,GACF,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACzC,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC"}
@@ -1,8 +1,8 @@
1
- import { Codec, Decoder, Encoder } from '@solana/codecs-core';
1
+ import { Codec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
2
2
  /** Encodes UTF-8 strings using the native `TextEncoder` API. */
3
- export declare const getUtf8Encoder: () => Encoder<string>;
3
+ export declare const getUtf8Encoder: () => VariableSizeEncoder<string>;
4
4
  /** Decodes UTF-8 strings using the native `TextDecoder` API. */
5
- export declare const getUtf8Decoder: () => Decoder<string>;
5
+ export declare const getUtf8Decoder: () => VariableSizeDecoder<string>;
6
6
  /** Encodes and decodes UTF-8 strings using the native `TextEncoder` and `TextDecoder` API. */
7
7
  export declare const getUtf8Codec: () => Codec<string>;
8
8
  //# sourceMappingURL=utf8.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utf8.d.ts","sourceRoot":"","sources":["../../src/utf8.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EAIL,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,qBAAqB,CAAC;AAK7B,gEAAgE;AAChE,eAAO,MAAM,cAAc,QAAO,oBAAoB,MAAM,CAU3D,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,cAAc,QAAO,oBAAoB,MAAM,CAQ3D,CAAC;AAEF,8FAA8F;AAC9F,eAAO,MAAM,YAAY,QAAO,MAAM,MAAM,CAAqD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/codecs-strings",
3
- "version": "2.0.0-experimental.fc4e943",
3
+ "version": "2.0.0-experimental.fcff844",
4
4
  "description": "Codecs for strings of different sizes and encodings",
5
5
  "exports": {
6
6
  "browser": {
@@ -49,25 +49,26 @@
49
49
  "node": ">=17.4"
50
50
  },
51
51
  "dependencies": {
52
- "@solana/codecs-core": "2.0.0-experimental.fc4e943",
53
- "@solana/codecs-numbers": "2.0.0-experimental.fc4e943"
52
+ "@solana/codecs-core": "2.0.0-experimental.fcff844",
53
+ "@solana/codecs-numbers": "2.0.0-experimental.fcff844"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@solana/eslint-config-solana": "^1.0.2",
57
- "@swc/jest": "^0.2.28",
58
- "@types/jest": "^29.5.5",
57
+ "@swc/jest": "^0.2.29",
58
+ "@types/jest": "^29.5.6",
59
+ "@types/node": "18.11.19",
59
60
  "@typescript-eslint/eslint-plugin": "^6.7.0",
60
61
  "@typescript-eslint/parser": "^6.3.0",
61
62
  "agadoo": "^3.0.0",
62
63
  "eslint": "^8.45.0",
63
- "eslint-plugin-jest": "^27.2.3",
64
+ "eslint-plugin-jest": "^27.4.2",
64
65
  "eslint-plugin-sort-keys-fix": "^1.1.2",
65
66
  "jest": "^29.7.0",
66
- "jest-environment-jsdom": "^29.6.4",
67
- "jest-runner-eslint": "^2.1.0",
67
+ "jest-environment-jsdom": "^29.7.0",
68
+ "jest-runner-eslint": "^2.1.2",
68
69
  "jest-runner-prettier": "^1.0.0",
69
- "prettier": "^2.8",
70
- "tsup": "7.2.0",
70
+ "prettier": "^3.1",
71
+ "tsup": "^8.0.1",
71
72
  "typescript": "^5.2.2",
72
73
  "version-from-git": "^1.1.1",
73
74
  "build-scripts": "0.0.0",