From 50517d6f3e66e0c2068223b5895044579e271ce9 Mon Sep 17 00:00:00 2001 From: jo <17280917+dev-jodee@users.noreply.github.com> Date: Fri, 17 Jul 2026 08:26:57 -0400 Subject: [PATCH 1/2] feat(generate): add Dart client renderer Wire codama-renderers-dart as a fifth SDK target alongside TypeScript, Umi, Rust, and Go. The language list is data-driven, so the selector and compatibility checks pick it up automatically. The package is mispublished (its exports `import` condition points at a .mjs absent from the tarball), so load its intact CJS build via createRequire, anchored on cwd so it also compiles under the CJS test build. The renderer emits only .dart sources (no pubspec.yaml); the help text notes users must add the solana_kit dependencies themselves. --- components/GeneratePanel.tsx | 26 ++++++++++++++++++++++++++ lib/codama-generate.ts | 20 ++++++++++++++++++++ lib/codama-types.ts | 12 +++++++++++- next.config.ts | 1 + package-lock.json | 16 ++++++++++++++++ package.json | 1 + 6 files changed, 75 insertions(+), 1 deletion(-) diff --git a/components/GeneratePanel.tsx b/components/GeneratePanel.tsx index 561beee..d941c9a 100644 --- a/components/GeneratePanel.tsx +++ b/components/GeneratePanel.tsx @@ -233,6 +233,32 @@ export function GeneratePanel({ idl, programId }: GeneratePanelProps) {

)} + {language === "dart" && ( + <> + + + {`dart pub get`} + + + {`import 'generated/${programName}.dart';`} + +

+ Generated as native Dart{" "} + sources targeting the solana_kit SDK. No pubspec.yaml is emitted + — add the solana_kit dependencies to your project manifest + yourself. +

+ + )} diff --git a/lib/codama-generate.ts b/lib/codama-generate.ts index f8d3315..a27bb1d 100644 --- a/lib/codama-generate.ts +++ b/lib/codama-generate.ts @@ -8,6 +8,15 @@ import JSZip from "jszip"; import fs from "fs"; import path from "path"; import { randomUUID } from "crypto"; +import { createRequire } from "module"; + +// codama-renderers-dart@0.4.x mispublishes its exports map: the `import` condition +// points at a .mjs absent from the tarball. Load the working CJS build via require. +// Anchor on cwd rather than import.meta.url so this also compiles under the CJS test build. +const renderDart: typeof import("codama-renderers-dart").renderVisitor = + createRequire(path.join(process.cwd(), "package.json"))( + "codama-renderers-dart" + ).renderVisitor; import type { Language } from "./codama-types"; import { assertLanguageSupportedForIdl } from "./codama-compat"; import { getCodamaRootNode, getIdlProgramName } from "./idl-utils"; @@ -87,6 +96,17 @@ export async function generateFromIdl( ); break; } + case "dart": { + const dartDir = path.join(tmpDir, `${programName}-dart-client`); + fs.mkdirSync(dartDir, { recursive: true }); + codama.accept( + renderDart(dartDir, { + formatCode: false, + deleteFolderBeforeRendering: false, + }) + ); + break; + } default: throw new Error(`Unknown language: ${language}`); } diff --git a/lib/codama-types.ts b/lib/codama-types.ts index 4fcd6b2..8a5153e 100644 --- a/lib/codama-types.ts +++ b/lib/codama-types.ts @@ -1,4 +1,9 @@ -export type Language = "typescript" | "typescript-umi" | "rust" | "go"; +export type Language = + | "typescript" + | "typescript-umi" + | "rust" + | "go" + | "dart"; export const LANGUAGES: { id: Language; label: string; description: string }[] = [ @@ -22,4 +27,9 @@ export const LANGUAGES: { id: Language; label: string; description: string }[] = label: "Go", description: "Native Go client", }, + { + id: "dart", + label: "Dart", + description: "Native Dart client (solana_kit)", + }, ]; diff --git a/next.config.ts b/next.config.ts index dce394c..8a76ec1 100644 --- a/next.config.ts +++ b/next.config.ts @@ -20,6 +20,7 @@ const nextConfig: NextConfig = { "@codama/renderers-js-umi", "@codama/renderers-rust", "@codama/renderers-go", + "codama-renderers-dart", "memfs", ], diff --git a/package-lock.json b/package-lock.json index 0518d32..a6c0266 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "@solana/kit": "^7.0.0", "@vercel/analytics": "^2.0.1", "codama": "^1.9.0", + "codama-renderers-dart": "^0.4.1", "jszip": "^3.10.1", "next": "^16.2.10", "pako": "^3.0.1", @@ -6416,6 +6417,21 @@ "codama": "bin/cli.cjs" } }, + "node_modules/codama-renderers-dart": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/codama-renderers-dart/-/codama-renderers-dart-0.4.1.tgz", + "integrity": "sha512-5IqnRWVDl8+2ovnYFo97syDfToCLgpRnyFM1Qo/hoPh1xlCtJXoAs9VNe0oYNqxGkuSyVzt7DBgWJBY6i6nkJA==", + "license": "MIT", + "dependencies": { + "@codama/errors": "^1.4.4", + "@codama/nodes": "^1.4.4", + "@codama/renderers-core": "^1.3.3", + "@codama/visitors-core": "^1.4.4" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", diff --git a/package.json b/package.json index dbb8472..f7f53f7 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@solana/kit": "^7.0.0", "@vercel/analytics": "^2.0.1", "codama": "^1.9.0", + "codama-renderers-dart": "^0.4.1", "jszip": "^3.10.1", "next": "^16.2.10", "pako": "^3.0.1", From e3e40d609a052c872f083bea48d53f868694968c Mon Sep 17 00:00:00 2001 From: jo <17280917+dev-jodee@users.noreply.github.com> Date: Fri, 17 Jul 2026 11:22:38 -0400 Subject: [PATCH 2/2] style: format Language union per prettier --- lib/codama-types.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/codama-types.ts b/lib/codama-types.ts index 8a5153e..ef4f8db 100644 --- a/lib/codama-types.ts +++ b/lib/codama-types.ts @@ -1,9 +1,4 @@ -export type Language = - | "typescript" - | "typescript-umi" - | "rust" - | "go" - | "dart"; +export type Language = "typescript" | "typescript-umi" | "rust" | "go" | "dart"; export const LANGUAGES: { id: Language; label: string; description: string }[] = [