Files
AstroJS/resolver-go/internal/closure/compiler.go
T
2026-06-13 04:00:52 +08:00

32 lines
633 B
Go

package closure
import (
"context"
"fmt"
"github.com/tgckpg/resolver-go/internal/compilecache"
)
type Compiler struct {
client *Client
}
func NewCompiler() *Compiler {
return &Compiler{client: NewClientFromEnv()}
}
func (c *Compiler) Compile(ctx context.Context, job compilecache.Job) ([]byte, error) {
payload, ok := job.Payload.(CompilePayload)
if !ok {
return nil, fmt.Errorf("closure compiler got invalid payload type %T", job.Payload)
}
req := CompileRequest{
ExternSources: payload.ExternSources,
JSSources: payload.JSSources,
Defines: payload.Defines,
}
return c.client.Compile(ctx, req)
}