@solana/options 2.0.0-experimental.c8d8b83 → 2.0.0-experimental.c9bd7fa

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,8 +1,8 @@
1
- import { BaseCodecOptions, Codec, Decoder, Encoder } from '@solana/codecs-core';
2
- import { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
3
- import { Option, OptionOrNullable } from './option';
4
- /** Defines the options for option codecs. */
5
- export type OptionCodecOptions<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecOptions & {
1
+ import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from '@solana/codecs-core';
2
+ import { FixedSizeNumberCodec, FixedSizeNumberDecoder, FixedSizeNumberEncoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';
3
+ import { Option, OptionOrNullable } from './option.js';
4
+ /** Defines the config for option codecs. */
5
+ export type OptionCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = {
6
6
  /**
7
7
  * The codec to use for the boolean prefix.
8
8
  * @defaultValue u8 prefix.
@@ -22,21 +22,39 @@ export type OptionCodecOptions<TPrefix extends NumberCodec | NumberEncoder | Num
22
22
  * Creates a encoder for an optional value using `null` as the `None` value.
23
23
  *
24
24
  * @param item - The encoder to use for the value that may be present.
25
- * @param options - A set of options for the encoder.
25
+ * @param config - A set of config for the encoder.
26
26
  */
27
- export declare function getOptionEncoder<T>(item: Encoder<T>, options?: OptionCodecOptions<NumberEncoder>): Encoder<OptionOrNullable<T>>;
27
+ export declare function getOptionEncoder<TFrom>(item: FixedSizeEncoder<TFrom>, config: OptionCodecConfig<FixedSizeNumberEncoder> & {
28
+ fixed: true;
29
+ }): FixedSizeEncoder<OptionOrNullable<TFrom>>;
30
+ export declare function getOptionEncoder<TFrom>(item: FixedSizeEncoder<TFrom, 0>, config?: OptionCodecConfig<FixedSizeNumberEncoder>): FixedSizeEncoder<OptionOrNullable<TFrom>>;
31
+ export declare function getOptionEncoder<TFrom>(item: Encoder<TFrom>, config?: OptionCodecConfig<NumberEncoder> & {
32
+ fixed?: false;
33
+ }): VariableSizeEncoder<OptionOrNullable<TFrom>>;
28
34
  /**
29
35
  * Creates a decoder for an optional value using `null` as the `None` value.
30
36
  *
31
37
  * @param item - The decoder to use for the value that may be present.
32
- * @param options - A set of options for the decoder.
38
+ * @param config - A set of config for the decoder.
33
39
  */
34
- export declare function getOptionDecoder<T>(item: Decoder<T>, options?: OptionCodecOptions<NumberDecoder>): Decoder<Option<T>>;
40
+ export declare function getOptionDecoder<TTo>(item: FixedSizeDecoder<TTo>, config: OptionCodecConfig<FixedSizeNumberDecoder> & {
41
+ fixed: true;
42
+ }): FixedSizeDecoder<Option<TTo>>;
43
+ export declare function getOptionDecoder<TTo>(item: FixedSizeDecoder<TTo, 0>, config?: OptionCodecConfig<FixedSizeNumberDecoder>): FixedSizeDecoder<Option<TTo>>;
44
+ export declare function getOptionDecoder<TTo>(item: Decoder<TTo>, config?: OptionCodecConfig<NumberDecoder> & {
45
+ fixed?: false;
46
+ }): VariableSizeDecoder<Option<TTo>>;
35
47
  /**
36
48
  * Creates a codec for an optional value using `null` as the `None` value.
37
49
  *
38
50
  * @param item - The codec to use for the value that may be present.
39
- * @param options - A set of options for the codec.
51
+ * @param config - A set of config for the codec.
40
52
  */
41
- export declare function getOptionCodec<T, U extends T = T>(item: Codec<T, U>, options?: OptionCodecOptions<NumberCodec>): Codec<OptionOrNullable<T>, Option<U>>;
53
+ export declare function getOptionCodec<TFrom, TTo extends TFrom = TFrom>(item: FixedSizeCodec<TFrom, TTo>, config: OptionCodecConfig<FixedSizeNumberCodec> & {
54
+ fixed: true;
55
+ }): FixedSizeCodec<OptionOrNullable<TFrom>, Option<TTo>>;
56
+ export declare function getOptionCodec<TFrom, TTo extends TFrom = TFrom>(item: FixedSizeCodec<TFrom, TTo, 0>, config?: OptionCodecConfig<FixedSizeNumberCodec>): FixedSizeCodec<OptionOrNullable<TFrom>, Option<TTo>>;
57
+ export declare function getOptionCodec<TFrom, TTo extends TFrom = TFrom>(item: Codec<TFrom, TTo>, config?: OptionCodecConfig<NumberCodec> & {
58
+ fixed?: false;
59
+ }): VariableSizeCodec<OptionOrNullable<TFrom>, Option<TTo>>;
42
60
  //# sourceMappingURL=option-codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"option-codec.d.ts","sourceRoot":"","sources":["../../src/option-codec.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;AAE/G,OAAO,EAA0B,MAAM,EAAE,gBAAgB,EAAQ,MAAM,UAAU,CAAC;AAGlF,6CAA6C;AAC7C,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,WAAW,GAAG,aAAa,GAAG,aAAa,IAAI,gBAAgB,GAAG;IAC7G;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAuBF;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAC9B,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,OAAO,GAAE,kBAAkB,CAAC,aAAa,CAAM,GAChD,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAa9B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAC9B,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,OAAO,GAAE,kBAAkB,CAAC,aAAa,CAAM,GAChD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAoBpB;AAED;;;;;GAKG;A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AAI,CAAA;CAAE,GAClE,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACxD,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,SAAS,KAAK,GAAG,KAAK,EAC3D,IAAI,EAAE,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EACnC,MAAM,CAAC,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,GACjD,cAAc,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACxD,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,SAAS,KAAK,GAAG,KAAK,EAC3D,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EACvB,MAAM,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAC5D,iBAAiB,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { None, Some } from './option';
1
+ import { None, Some } from './option.js';
2
2
  /**
3
3
  * Lists all types that should not be recursively unwrapped.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"unwrap-option-recursively.d.ts","sourceRoot":"","sources":["../../src/unwrap-option-recursively.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAExD;;;;GAIG;AACH,KAAK,cAAc,GACb,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,GACT,IAAI,GACJ,UAAU,GACV,SAAS,GACT,WAAW,GACX,UAAU,GACV,WAAW,GACX,UAAU,GACV,IAAI,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM,MAAM,CAAC,GACjE,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,GAC1B,CAAC,SAAS,IAAI,GACd,CAAC,GACD,CAAC,SAAS,cAAc,GACxB,CAAC,GACD,CAAC,SAAS,MAAM,GAChB;KAAG,GAAG,IAAI,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;CAAE,GAChD,CAAC,SAAS,KAAK,CAAC,MAAM,KAAK,CAAC,GAC5B,KAAK,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAChC,CAAC,CAAC;AAER;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AACzE,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"unwrap-option-recursively.d.ts","sourceRoot":"","sources":["../../src/unwrap-option-recursively.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAExD;;;;GAIG;AACH,KAAK,cAAc,GACb,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,GACT,IAAI,GACJ,UAAU,GACV,SAAS,GACT,WAAW,GACX,UAAU,GACV,WAAW,GACX,UAAU,GACV,IAAI,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM,MAAM,CAAC,GACjE,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,GAC1B,CAAC,SAAS,IAAI,GACZ,CAAC,GACD,CAAC,SAAS,cAAc,GACtB,CAAC,GACD,CAAC,SAAS,MAAM,GACd;KAAG,GAAG,IAAI,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;CAAE,GAChD,CAAC,SAAS,KAAK,CAAC,MAAM,KAAK,CAAC,GAC1B,KAAK,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAChC,CAAC,CAAC;AAEhB;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;AACzE,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Option } from './option';
1
+ import { Option } from './option.js';
2
2
  /**
3
3
  * Unwraps the value of an {@link Option} of type `T`
4
4
  * or returns a fallback value that defaults to `null`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/options",
3
- "version": "2.0.0-experimental.c8d8b83",
3
+ "version": "2.0.0-experimental.c9bd7fa",
4
4
  "description": "Managing and serializing Rust-like Option types in JavaScript",
5
5
  "exports": {
6
6
  "browser": {
@@ -49,25 +49,25 @@
49
49
  "node": ">=17.4"
50
50
  },
51
51
  "dependencies": {
52
- "@solana/codecs-core": "2.0.0-experimental.c8d8b83",
53
- "@solana/codecs-numbers": "2.0.0-experimental.c8d8b83"
52
+ "@solana/codecs-core": "2.0.0-experimental.c9bd7fa",
53
+ "@solana/codecs-numbers": "2.0.0-experimental.c9bd7fa"
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",
59
- "@typescript-eslint/eslint-plugin": "^6.7.0",
57
+ "@swc/jest": "^0.2.29",
58
+ "@types/jest": "^29.5.11",
59
+ "@typescript-eslint/eslint-plugin": "^6.13.2",
60
60
  "@typescript-eslint/parser": "^6.3.0",
61
61
  "agadoo": "^3.0.0",
62
62
  "eslint": "^8.45.0",
63
- "eslint-plugin-jest": "^27.2.3",
63
+ "eslint-plugin-jest": "^27.4.2",
64
64
  "eslint-plugin-sort-keys-fix": "^1.1.2",
65
65
  "jest": "^29.7.0",
66
- "jest-environment-jsdom": "^29.6.4",
67
- "jest-runner-eslint": "^2.1.0",
66
+ "jest-environment-jsdom": "^29.7.0",
67
+ "jest-runner-eslint": "^2.1.2",
68
68
  "jest-runner-prettier": "^1.0.0",
69
- "prettier": "^2.8",
70
- "tsup": "7.2.0",
69
+ "prettier": "^3.1",
70
+ "tsup": "^8.0.1",
71
71
  "typescript": "^5.2.2",
72
72
  "version-from-git": "^1.1.1",
73
73
  "build-scripts": "0.0.0",
@@ -84,10 +84,10 @@
84
84
  },
85
85
  "scripts": {
86
86
  "compile:js": "tsup --config build-scripts/tsup.config.library.ts",
87
- "compile:typedefs": "tsc -p ./tsconfig.declarations.json",
87
+ "compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/build-scripts/add-js-extension-to-types.mjs",
88
88
  "dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch",
89
89
  "publish-packages": "pnpm publish --tag experimental --access public --no-git-checks",
90
- "style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/*",
90
+ "style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json",
91
91
  "test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent",
92
92
  "test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent",
93
93
  "test:treeshakability:browser": "agadoo dist/index.browser.js",