add solid-start support

This commit is contained in:
Gregor Lohaus
2026-04-16 13:35:26 +02:00
parent e35a038f09
commit 73dc856821
7 changed files with 62 additions and 15 deletions

View File

@@ -48,11 +48,11 @@ const isStringLiteral = (s: string | StringLiteral | undefined): s is StringLite
return (s as StringLiteral).forEachChild != undefined;
}
const serviceNameToRouterPropertyName = (n:string) : string => {
return n.toLowerCase().replace('service','') + 's'
const serviceNameToRouterPropertyName = (n: string): string => {
return n.toLowerCase().replace('service', '') + 's'
}
const exportDecl = (exp: Map<string, boolean>, typesOnly:boolean = false, from?: string | StringLiteral) => {
const exportDecl = (exp: Map<string, boolean>, typesOnly: boolean = false, from?: string | StringLiteral) => {
return factory.createExportDeclaration(
undefined,
typesOnly,
@@ -145,6 +145,14 @@ for (const filePath of files) {
"@connectrpc/connect"
)
)
statements.push(
importDecl(
new Map<string, boolean>([
["Message", true],
]),
"@bufbuild/protobuf"
)
)
statements.push(
importDecl(
new Map<string, boolean>([
@@ -308,10 +316,44 @@ statements.push(factory.createFunctionDeclaration(
)
))
statements.push(exportDecl(new Map<string,boolean>([
statements.push(exportDecl(new Map<string, boolean>([
['createRouter', false]
])))
statements.push(
ts.factory.createTypeAliasDeclaration(
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
ts.factory.createIdentifier("ExtractPayload"),
[
ts.factory.createTypeParameterDeclaration(
undefined,
ts.factory.createIdentifier("T"),
undefined,
undefined
),
],
ts.factory.createTypeReferenceNode(
ts.factory.createIdentifier("Omit"),
[
// T
ts.factory.createTypeReferenceNode("T", undefined),
// keyof Message<any>
ts.factory.createTypeOperatorNode(
ts.SyntaxKind.KeyOfKeyword,
ts.factory.createTypeReferenceNode(
ts.factory.createIdentifier("Message"),
[
ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword),
]
)
),
]
)
)
)
const outputFile = ts.createSourceFile(INDEX_FILE, "", ts.ScriptTarget.ESNext, false, ts.ScriptKind.TS);
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });