codama-renderers-dart 0.2.0 → 0.3.0

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 (56) hide show
  1. package/dist/index.browser.cjs +2102 -0
  2. package/dist/index.browser.cjs.map +1 -0
  3. package/dist/index.browser.js +2092 -0
  4. package/dist/index.browser.js.map +1 -0
  5. package/dist/index.node.cjs +2102 -0
  6. package/dist/index.node.cjs.map +1 -0
  7. package/dist/index.node.js +2092 -0
  8. package/dist/index.node.js.map +1 -0
  9. package/dist/index.react-native.js +2092 -0
  10. package/dist/index.react-native.js.map +1 -0
  11. package/dist/types/fragments/accountPage.d.ts +8 -0
  12. package/dist/types/fragments/accountPage.d.ts.map +1 -0
  13. package/dist/types/fragments/discriminatorConstants.d.ts +8 -0
  14. package/dist/types/fragments/discriminatorConstants.d.ts.map +1 -0
  15. package/dist/types/fragments/errorPage.d.ts +8 -0
  16. package/dist/types/fragments/errorPage.d.ts.map +1 -0
  17. package/dist/types/fragments/index.d.ts +9 -0
  18. package/dist/types/fragments/index.d.ts.map +1 -0
  19. package/dist/types/fragments/indexPage.d.ts +10 -0
  20. package/dist/types/fragments/indexPage.d.ts.map +1 -0
  21. package/dist/types/fragments/instructionPage.d.ts +8 -0
  22. package/dist/types/fragments/instructionPage.d.ts.map +1 -0
  23. package/dist/types/fragments/pdaPage.d.ts +8 -0
  24. package/dist/types/fragments/pdaPage.d.ts.map +1 -0
  25. package/dist/types/fragments/programPage.d.ts +8 -0
  26. package/dist/types/fragments/programPage.d.ts.map +1 -0
  27. package/dist/types/fragments/typePage.d.ts +8 -0
  28. package/dist/types/fragments/typePage.d.ts.map +1 -0
  29. package/dist/types/index.d.ts +12 -0
  30. package/dist/types/index.d.ts.map +1 -0
  31. package/dist/types/utils/codecs.d.ts +10 -0
  32. package/dist/types/utils/codecs.d.ts.map +1 -0
  33. package/dist/types/utils/formatCode.d.ts +10 -0
  34. package/dist/types/utils/formatCode.d.ts.map +1 -0
  35. package/dist/types/utils/fragment.d.ts +31 -0
  36. package/dist/types/utils/fragment.d.ts.map +1 -0
  37. package/dist/types/utils/importMap.d.ts +40 -0
  38. package/dist/types/utils/importMap.d.ts.map +1 -0
  39. package/dist/types/utils/index.d.ts +8 -0
  40. package/dist/types/utils/index.d.ts.map +1 -0
  41. package/dist/types/utils/nameTransformers.d.ts +64 -0
  42. package/dist/types/utils/nameTransformers.d.ts.map +1 -0
  43. package/dist/types/utils/options.d.ts +41 -0
  44. package/dist/types/utils/options.d.ts.map +1 -0
  45. package/dist/types/utils/typeManifest.d.ts +21 -0
  46. package/dist/types/utils/typeManifest.d.ts.map +1 -0
  47. package/dist/types/visitors/getRenderMapVisitor.d.ts +9 -0
  48. package/dist/types/visitors/getRenderMapVisitor.d.ts.map +1 -0
  49. package/dist/types/visitors/getTypeManifestVisitor.d.ts +19 -0
  50. package/dist/types/visitors/getTypeManifestVisitor.d.ts.map +1 -0
  51. package/dist/types/visitors/index.d.ts +4 -0
  52. package/dist/types/visitors/index.d.ts.map +1 -0
  53. package/dist/types/visitors/renderVisitor.d.ts +9 -0
  54. package/dist/types/visitors/renderVisitor.d.ts.map +1 -0
  55. package/package.json +6 -11
  56. package/src/fragments/pdaPage.ts +18 -13
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../src/utils/codecs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAM5D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAG9D"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Format Dart code using `dart format`.
3
+ * Falls back to returning the unformatted code if dart is not available.
4
+ */
5
+ export declare function formatDartCode(code: string): string;
6
+ /**
7
+ * Format all Dart files in a directory using `dart format`.
8
+ */
9
+ export declare function formatDartDirectory(dir: string): void;
10
+ //# sourceMappingURL=formatCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatCode.d.ts","sourceRoot":"","sources":["../../../src/utils/formatCode.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAanD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAUrD"}
@@ -0,0 +1,31 @@
1
+ import type { BaseFragment } from "@codama/renderers-core";
2
+ import { DartImportMap } from "./importMap.js";
3
+ /**
4
+ * A Fragment represents a piece of generated Dart code
5
+ * along with the imports it requires.
6
+ */
7
+ export type Fragment = BaseFragment & Readonly<{
8
+ imports: DartImportMap;
9
+ }>;
10
+ /**
11
+ * Create a Fragment from a tagged template literal.
12
+ * Embedded Fragment values have their imports merged automatically.
13
+ */
14
+ export declare function fragment(strings: TemplateStringsArray, ...values: (Fragment | string | number | boolean | undefined | null)[]): Fragment;
15
+ /**
16
+ * Create an empty fragment.
17
+ */
18
+ export declare function emptyFragment(): Fragment;
19
+ /**
20
+ * Create a fragment from a raw string.
21
+ */
22
+ export declare function fragmentFromString(content: string): Fragment;
23
+ /**
24
+ * Merge multiple fragments with a joiner function.
25
+ */
26
+ export declare function mergeFragments(fragments: Fragment[], joiner: (contents: string[]) => string): Fragment;
27
+ /**
28
+ * Helper to add a Dart import to a fragment and return a type name fragment.
29
+ */
30
+ export declare function use(typeName: string, module: string): Fragment;
31
+ //# sourceMappingURL=fragment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragment.d.ts","sourceRoot":"","sources":["../../../src/utils/fragment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,YAAY,GACjC,QAAQ,CAAC;IACP,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC,CAAC;AAEL;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,oBAAoB,EAC7B,GAAG,MAAM,EAAE,CAAC,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,GACrE,QAAQ,CAqBV;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,QAAQ,CAExC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAE5D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,QAAQ,EAAE,EACrB,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,MAAM,GACrC,QAAQ,CAUV;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAI9D"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Maps logical module names to Dart package: URIs.
3
+ */
4
+ export declare const DART_EXTERNAL_PACKAGE_MAP: Record<string, string>;
5
+ /**
6
+ * Tracks Dart import URIs needed by generated code.
7
+ *
8
+ * Dart imports entire libraries (not individual symbols), so we only
9
+ * need to track which package URIs are used, not specific symbols.
10
+ */
11
+ export declare class DartImportMap {
12
+ private _imports;
13
+ /**
14
+ * Add a logical module name (resolved via DART_EXTERNAL_PACKAGE_MAP)
15
+ * or a raw Dart import URI.
16
+ */
17
+ add(module: string): this;
18
+ /**
19
+ * Merge another DartImportMap into this one.
20
+ */
21
+ mergeWith(other: DartImportMap): this;
22
+ /**
23
+ * Check if this import map is empty.
24
+ */
25
+ get isEmpty(): boolean;
26
+ /**
27
+ * Get all raw module keys.
28
+ */
29
+ get modules(): Set<string>;
30
+ /**
31
+ * Resolve all imports to Dart import URIs and return them sorted.
32
+ * @param internalMap Maps logical names to relative file paths for generated code cross-references.
33
+ */
34
+ resolve(internalMap?: Record<string, string>): string[];
35
+ /**
36
+ * Render all imports as Dart import statements.
37
+ */
38
+ toString(internalMap?: Record<string, string>): string;
39
+ }
40
+ //# sourceMappingURL=importMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importMap.d.ts","sourceRoot":"","sources":["../../../src/utils/importMap.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsB5D,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAqB;IAErC;;;OAGG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKzB;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAOrC;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,CAEzB;IAED;;;OAGG;IACH,OAAO,CAAC,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,MAAM,EAAE;IA2B3D;;OAEG;IACH,QAAQ,CAAC,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,MAAM;CAyB3D"}
@@ -0,0 +1,8 @@
1
+ export * from "./codecs.js";
2
+ export * from "./formatCode.js";
3
+ export * from "./fragment.js";
4
+ export * from "./importMap.js";
5
+ export * from "./nameTransformers.js";
6
+ export * from "./options.js";
7
+ export * from "./typeManifest.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { CamelCaseString } from "@codama/nodes";
2
+ /**
3
+ * Naming convention transformers for Dart code generation.
4
+ */
5
+ /** Convert a string to PascalCase */
6
+ export declare function pascalCase(str: string): string;
7
+ /** Convert a string to camelCase */
8
+ export declare function camelCase(str: string): string;
9
+ /** Convert a string to snake_case */
10
+ export declare function snakeCase(str: string): string;
11
+ /** Convert a string to SCREAMING_SNAKE_CASE */
12
+ export declare function screamingSnakeCase(str: string): string;
13
+ /**
14
+ * All name transformation functions for Dart code generation.
15
+ */
16
+ export interface DartNameApi {
17
+ /** Data class name: `PascalCase` */
18
+ dataType(name: string): string;
19
+ /** Encoder function name: `get{PascalCase}Encoder` */
20
+ encoderFunction(name: string): string;
21
+ /** Decoder function name: `get{PascalCase}Decoder` */
22
+ decoderFunction(name: string): string;
23
+ /** Codec function name: `get{PascalCase}Codec` */
24
+ codecFunction(name: string): string;
25
+ /** Account fetch function: `fetch{PascalCase}` */
26
+ accountFetchFunction(name: string): string;
27
+ /** Account fetch maybe function: `fetchMaybe{PascalCase}` */
28
+ accountFetchMaybeFunction(name: string): string;
29
+ /** Account decode function: `decode{PascalCase}` */
30
+ accountDecodeFunction(name: string): string;
31
+ /** Account size constant: `{camelCase}Size` */
32
+ accountSizeConstant(name: string): string;
33
+ /** PDA finder function: `find{PascalCase}Pda` */
34
+ pdaFindFunction(name: string): string;
35
+ /** Instruction builder function: `get{PascalCase}Instruction` */
36
+ instructionFunction(name: string): string;
37
+ /** Instruction parse function: `parse{PascalCase}Instruction` */
38
+ instructionParseFunction(name: string): string;
39
+ /** Program address constant: `{camelCase}ProgramAddress` */
40
+ programAddressConstant(name: string): string;
41
+ /** Error code constant: `{programName}Error{PascalCase}` */
42
+ errorConstant(programName: string, errorName: string): string;
43
+ /** Error message function: `get{PascalCase}ErrorMessage` */
44
+ errorMessageFunction(name: string): string;
45
+ /** Enum variant: `camelCase` */
46
+ enumVariant(name: string): string;
47
+ /** Sealed class variant (data enum): `PascalCase` */
48
+ sealedClassVariant(parentName: string, variantName: string): string;
49
+ /** File name: `snake_case.dart` */
50
+ fileName(name: string): string;
51
+ /** Discriminator constant: `{camelCase}Discriminator` */
52
+ discriminatorConstant(name: string): string;
53
+ /** isX() helper for type check: `is{PascalCase}` */
54
+ isTypeFunction(name: string): string;
55
+ }
56
+ /**
57
+ * Create the default Dart name API.
58
+ */
59
+ export declare function createDartNameApi(): DartNameApi;
60
+ /**
61
+ * Convert a CamelCaseString to a regular string.
62
+ */
63
+ export declare function fromCamelCaseString(str: CamelCaseString): string;
64
+ //# sourceMappingURL=nameTransformers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nameTransformers.d.ts","sourceRoot":"","sources":["../../../src/utils/nameTransformers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;GAEG;AAEH,qCAAqC;AACrC,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI9C;AAED,oCAAoC;AACpC,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED,qCAAqC;AACrC,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO7C;AAED,+CAA+C;AAC/C,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,sDAAsD;IACtD,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtC,sDAAsD;IACtD,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtC,kDAAkD;IAClD,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,kDAAkD;IAClD,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3C,6DAA6D;IAC7D,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAChD,oDAAoD;IACpD,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5C,+CAA+C;IAC/C,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1C,iDAAiD;IACjD,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtC,iEAAiE;IACjE,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1C,iEAAiE;IACjE,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/C,4DAA4D;IAC5D,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7C,4DAA4D;IAC5D,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9D,4DAA4D;IAC5D,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3C,gCAAgC;IAChC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,qDAAqD;IACrD,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IACpE,mCAAmC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,yDAAyD;IACzD,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5C,oDAAoD;IACpD,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACtC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAuB/C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAEhE"}
@@ -0,0 +1,41 @@
1
+ import type { LinkableDictionary } from "@codama/visitors-core";
2
+ import type { DartNameApi } from "./nameTransformers.js";
3
+ import type { TypeManifestVisitor } from "../visitors/getTypeManifestVisitor.js";
4
+ /**
5
+ * Options for the top-level renderVisitor.
6
+ */
7
+ export interface RenderOptions extends GetRenderMapOptions {
8
+ /** Whether to delete the output folder before rendering. Default: true. */
9
+ deleteFolderBeforeRendering?: boolean;
10
+ /** Whether to run `dart format` on generated files. Default: false. */
11
+ formatCode?: boolean;
12
+ /** The Dart package name for pubspec.yaml generation. */
13
+ dartPackageName?: string;
14
+ /** Custom dependency overrides for the generated pubspec.yaml. */
15
+ dartDependencies?: Record<string, string>;
16
+ }
17
+ /**
18
+ * Options for the getRenderMapVisitor.
19
+ */
20
+ export interface GetRenderMapOptions {
21
+ /** Custom name API overrides. */
22
+ nameApi?: Partial<DartNameApi>;
23
+ /** Dependency map overrides (logical module -> Dart package URI). */
24
+ dependencyMap?: Record<string, string>;
25
+ }
26
+ /**
27
+ * Shared rendering context passed to fragment generators.
28
+ */
29
+ export interface RenderScope {
30
+ /** The resolved name API for Dart naming conventions. */
31
+ nameApi: DartNameApi;
32
+ /** The type manifest visitor for resolving type nodes. */
33
+ typeManifestVisitor: TypeManifestVisitor;
34
+ /** Linkable nodes dictionary for cross-references. */
35
+ linkables: LinkableDictionary;
36
+ /** Custom dependency map. */
37
+ dependencyMap: Record<string, string>;
38
+ /** Internal import map (logical name -> relative file path). */
39
+ internalImportMap: Record<string, string>;
40
+ }
41
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/utils/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,mBAAmB;IACxD,2EAA2E;IAC3E,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,uEAAuE;IACvE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yDAAyD;IACzD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,iCAAiC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/B,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,yDAAyD;IACzD,OAAO,EAAE,WAAW,CAAC;IACrB,0DAA0D;IAC1D,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,sDAAsD;IACtD,SAAS,EAAE,kBAAkB,CAAC;IAC9B,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,gEAAgE;IAChE,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C"}
@@ -0,0 +1,21 @@
1
+ import type { Fragment } from "./fragment.js";
2
+ /**
3
+ * Represents how a Codama type maps to Dart types and codec expressions.
4
+ */
5
+ export interface TypeManifest {
6
+ /** The Dart type name (e.g. `int`, `BigInt`, `Address`, `MyStruct`). */
7
+ type: Fragment;
8
+ /** The Dart encoder expression (e.g. `getU8Encoder()`). */
9
+ encoder: Fragment;
10
+ /** The Dart decoder expression (e.g. `getU8Decoder()`). */
11
+ decoder: Fragment;
12
+ /** The Dart value expression for default values. */
13
+ value: Fragment;
14
+ /** Whether this is a scalar enum (Dart `enum`). */
15
+ isEnum: boolean;
16
+ }
17
+ /**
18
+ * Create an empty TypeManifest.
19
+ */
20
+ export declare function emptyTypeManifest(): TypeManifest;
21
+ //# sourceMappingURL=typeManifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeManifest.d.ts","sourceRoot":"","sources":["../../../src/utils/typeManifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,IAAI,EAAE,QAAQ,CAAC;IACf,2DAA2D;IAC3D,OAAO,EAAE,QAAQ,CAAC;IAClB,2DAA2D;IAC3D,OAAO,EAAE,QAAQ,CAAC;IAClB,oDAAoD;IACpD,KAAK,EAAE,QAAQ,CAAC;IAChB,mDAAmD;IACnD,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,YAAY,CAQhD"}
@@ -0,0 +1,9 @@
1
+ import { type RenderMap } from "@codama/renderers-core";
2
+ import { type Visitor } from "@codama/visitors-core";
3
+ import type { Fragment } from "../utils/fragment.js";
4
+ import type { GetRenderMapOptions } from "../utils/options.js";
5
+ /**
6
+ * Creates a visitor that maps Codama nodes to a RenderMap of Dart files.
7
+ */
8
+ export declare function getRenderMapVisitor(options?: GetRenderMapOptions): Visitor<RenderMap<Fragment>, "rootNode" | "programNode" | "accountNode" | "definedTypeNode" | "instructionNode" | "pdaNode">;
9
+ //# sourceMappingURL=getRenderMapVisitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRenderMapVisitor.d.ts","sourceRoot":"","sources":["../../../src/visitors/getRenderMapVisitor.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,SAAS,EAIf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,OAAO,EASb,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAe,MAAM,qBAAqB,CAAC;AAa5E;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU,GAAG,aAAa,GAAG,aAAa,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,SAAS,CAAC,CAkO9H"}
@@ -0,0 +1,19 @@
1
+ import { type CamelCaseString } from "@codama/nodes";
2
+ import { type LinkableDictionary, type NodeStack, type Visitor } from "@codama/visitors-core";
3
+ import { type TypeManifest } from "../utils/index.js";
4
+ import { type DartNameApi } from "../utils/nameTransformers.js";
5
+ /**
6
+ * Type alias for the type manifest visitor.
7
+ */
8
+ export type TypeManifestVisitor = ReturnType<typeof getTypeManifestVisitor>;
9
+ /**
10
+ * Creates a visitor that maps Codama type/value nodes to TypeManifest objects.
11
+ * Each TypeManifest contains Dart type, encoder, decoder, and value expressions.
12
+ */
13
+ export declare function getTypeManifestVisitor(input: {
14
+ nameApi: DartNameApi;
15
+ linkables: LinkableDictionary;
16
+ stack: NodeStack;
17
+ nonScalarEnums?: CamelCaseString[];
18
+ }): Visitor<TypeManifest, "accountNode" | "definedTypeNode" | "errorNode" | "instructionAccountNode" | "instructionArgumentNode" | "instructionByteDeltaNode" | "instructionNode" | "instructionRemainingAccountsNode" | "instructionStatusNode" | "pdaNode" | "programNode" | "pdaSeedValueNode" | "accountBumpValueNode" | "accountValueNode" | "argumentValueNode" | "conditionalValueNode" | "identityValueNode" | "payerValueNode" | "pdaValueNode" | "programIdValueNode" | "resolverValueNode" | "fixedCountNode" | "prefixedCountNode" | "remainderCountNode" | "constantDiscriminatorNode" | "fieldDiscriminatorNode" | "sizeDiscriminatorNode" | "accountLinkNode" | "definedTypeLinkNode" | "instructionAccountLinkNode" | "instructionArgumentLinkNode" | "instructionLinkNode" | "pdaLinkNode" | "programLinkNode" | "constantPdaSeedNode" | "variablePdaSeedNode" | "enumEmptyVariantTypeNode" | "enumStructVariantTypeNode" | "enumTupleVariantTypeNode" | "amountTypeNode" | "arrayTypeNode" | "booleanTypeNode" | "bytesTypeNode" | "dateTimeTypeNode" | "enumTypeNode" | "fixedSizeTypeNode" | "hiddenPrefixTypeNode" | "hiddenSuffixTypeNode" | "mapTypeNode" | "numberTypeNode" | "optionTypeNode" | "postOffsetTypeNode" | "preOffsetTypeNode" | "publicKeyTypeNode" | "remainderOptionTypeNode" | "sentinelTypeNode" | "setTypeNode" | "sizePrefixTypeNode" | "solAmountTypeNode" | "stringTypeNode" | "structTypeNode" | "tupleTypeNode" | "zeroableOptionTypeNode" | "structFieldTypeNode" | "mapEntryValueNode" | "arrayValueNode" | "booleanValueNode" | "bytesValueNode" | "constantValueNode" | "enumValueNode" | "mapValueNode" | "noneValueNode" | "numberValueNode" | "publicKeyValueNode" | "setValueNode" | "someValueNode" | "stringValueNode" | "structValueNode" | "tupleValueNode" | "structFieldValueNode" | "rootNode">;
19
+ //# sourceMappingURL=getTypeManifestVisitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTypeManifestVisitor.d.ts","sourceRoot":"","sources":["../../../src/visitors/getTypeManifestVisitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,eAAe,EA8BrB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,OAAO,EAIb,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAEL,KAAK,YAAY,EAKlB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,WAAW,EAAa,MAAM,8BAA8B,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,OAAO,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,cAAc,CAAC,EAAE,eAAe,EAAE,CAAC;CACpC,8vDAilBA"}
@@ -0,0 +1,4 @@
1
+ export * from "./getRenderMapVisitor.js";
2
+ export * from "./getTypeManifestVisitor.js";
3
+ export * from "./renderVisitor.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/visitors/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { RenderOptions } from "../utils/options.js";
2
+ /**
3
+ * Creates a visitor that renders Codama nodes as Dart files.
4
+ *
5
+ * @param outputDir - The directory to write generated files into (e.g., 'lib/src/generated')
6
+ * @param options - Rendering options
7
+ */
8
+ export declare function renderVisitor(outputDir: string, options?: RenderOptions): import("@codama/visitors-core").Visitor<void, "rootNode">;
9
+ //# sourceMappingURL=renderVisitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderVisitor.d.ts","sourceRoot":"","sources":["../../../src/visitors/renderVisitor.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKzD;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,aAAkB,6DA+D5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codama-renderers-dart",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Codama renderer for generating Dart code targeting the solana_kit SDK",
5
5
  "exports": {
6
6
  "node": {
@@ -38,12 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@codama/nodes-from-anchor": "^1.3.9",
41
- "@codama/renderers-js": "^2.0.2",
42
- "@types/node": "^25.3.0",
43
- "rimraf": "^6.0.1",
44
- "tsup": "^8.4.0",
45
- "typescript": "^5.7.3",
46
- "vitest": "^3.2.1"
41
+ "@codama/renderers-js": "^2.0.2"
47
42
  },
48
43
  "engines": {
49
44
  "node": ">=18"
@@ -52,10 +47,10 @@
52
47
  "access": "public"
53
48
  },
54
49
  "scripts": {
55
- "build": "rimraf dist && tsup && tsc -p tsconfig.declarations.json",
50
+ "build": "pnpm exec rimraf dist && pnpm exec tsup && pnpm exec tsc -p tsconfig.declarations.json",
56
51
  "lint": "eslint --ext .ts src",
57
- "test": "vitest run",
58
- "test:watch": "vitest",
59
- "typecheck": "tsc --noEmit"
52
+ "test": "pnpm exec vitest run",
53
+ "test:watch": "pnpm exec vitest",
54
+ "typecheck": "pnpm exec tsc --noEmit"
60
55
  }
61
56
  }
@@ -50,24 +50,26 @@ export function getPdaPageFragment(
50
50
  })
51
51
  .join("\n");
52
52
 
53
- // Build the seed bytes list
54
- const seedBytesList: string[] = [];
53
+ // Build the PDA seeds list.
54
+ const seedValues: string[] = [];
55
55
  for (const seed of seeds) {
56
56
  if (seed.kind === "constantPdaSeedNode") {
57
57
  if (seed.value.kind === "bytesValueNode") {
58
- seedBytesList.push(` ...${bytesValueToDart(seed.value.data)},`);
58
+ seedValues.push(` Uint8List.fromList(${bytesValueToDart(seed.value.data)}),`);
59
59
  } else if (seed.value.kind === "stringValueNode") {
60
- seedBytesList.push(` ...utf8.encode('${seed.value.string}'),`);
60
+ seedValues.push(` '${seed.value.string}',`);
61
61
  } else if (seed.value.kind === "publicKeyValueNode") {
62
- seedBytesList.push(` ...getAddressEncoder().encode(Address('${seed.value.publicKey}')),`);
62
+ seedValues.push(
63
+ ` getAddressEncoder().encode(Address('${seed.value.publicKey}')),`,
64
+ );
63
65
  } else if (seed.value.kind === "numberValueNode") {
64
66
  const manifest = visit(seed.type, scope.typeManifestVisitor);
65
- seedBytesList.push(` ...${manifest.encoder.content}.encode(${seed.value.number}),`);
67
+ seedValues.push(` ${manifest.encoder.content}.encode(${seed.value.number}),`);
66
68
  }
67
69
  } else if (seed.kind === "variablePdaSeedNode") {
68
70
  const manifest = visit(seed.type, scope.typeManifestVisitor);
69
- seedBytesList.push(
70
- ` ...${manifest.encoder.content}.encode(seeds.${camelCase(seed.name as string)}),`,
71
+ seedValues.push(
72
+ ` ${manifest.encoder.content}.encode(seeds.${camelCase(seed.name as string)}),`,
71
73
  );
72
74
  }
73
75
  }
@@ -84,7 +86,8 @@ export function getPdaPageFragment(
84
86
  ${use("Uint8List", "dartTypedData")}
85
87
  ${use("immutable", "meta")}
86
88
  ${use("Address", "solanaAddresses")}
87
- ${use("getAddressEncoder", "solanaAddresses")}`,
89
+ ${use("getAddressEncoder", "solanaAddresses")}
90
+ ${use("getProgramDerivedAddress", "solanaAddresses")}`,
88
91
  ];
89
92
 
90
93
  if (hasSeedsClass) {
@@ -107,12 +110,14 @@ Future<(Address, int)> ${fragmentFromString(findFnName)}({
107
110
  ${fragmentFromString(seedsParam)}
108
111
  ${fragmentFromString(programIdParam)},
109
112
  }) async {
110
- final seedBytes = <int>[
111
- ${fragmentFromString(seedBytesList.join("\n"))}
113
+ final seeds = <Object>[
114
+ ${fragmentFromString(seedValues.join("\n"))}
112
115
  ];
113
116
 
114
- // TODO: Call getProgramDerivedAddress with seedBytes and programAddress
115
- throw UnimplementedError('PDA derivation not yet implemented');
117
+ return getProgramDerivedAddress(
118
+ programAddress: programAddress,
119
+ seeds: seeds,
120
+ );
116
121
  }`);
117
122
 
118
123
  return mergeFragments(parts, (cs) => cs.join("\n"));