mirror of
https://github.com/hanzoai/base.git
synced 2026-10-21 03:41:50 +00:00
Base is not the only thing that runs plugins. Cloud grew a second goja runtime — its own shim, its own bundler, its own registry — because the loader and the runners lived here and there was nothing to import. hanzoai/plugin is that something, and it implements zip's Module and Loader rather than the private copies of them that sat beside these runners. extruntime, gojavm, pyvm and wasmvm move out. jsvm stays, because it is base's own app scripting rather than a plugin runtime — the two were only ever adjacent. Their one tie to base was a single call for an unguessable string, and crypto/rand says that without a dependency. Co-authored-by: Hanzo Dev <[email protected]>
44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
//go:build !v8vm
|
|
// +build !v8vm
|
|
|
|
// Package v8vm is the V8 (via cgo) extension runtime for Base.
|
|
//
|
|
// The real implementation lives behind the `v8vm` build tag because v8go
|
|
// pulls in roughly 50 MB of cgo dependencies. The default build of base
|
|
// must compile without it, so this stub file is what gets linked in
|
|
// normally — `NewRuntime()` is always callable and always exists; only
|
|
// the actual V8 engine is opt-in via `go build -tags v8vm`.
|
|
package v8vm
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/hanzoai/plugin/extruntime"
|
|
)
|
|
|
|
// NewRuntime returns a v8go-shaped runtime that errors at Load time when
|
|
// the binary was built without the `v8vm` build tag. Name() and
|
|
// Capabilities() still report the v8go identity so callers can detect
|
|
// the runtime is present-but-unavailable rather than missing entirely.
|
|
func NewRuntime() extruntime.Runtime { return &stubRuntime{} }
|
|
|
|
type stubRuntime struct{}
|
|
|
|
func (*stubRuntime) Name() string { return "v8go" }
|
|
|
|
func (*stubRuntime) Capabilities() extruntime.Capabilities {
|
|
return extruntime.Capabilities{
|
|
AcceptsLanguages: []string{"js"},
|
|
HardSandbox: true,
|
|
Cgo: true,
|
|
SupportsAbort: true,
|
|
}
|
|
}
|
|
|
|
func (*stubRuntime) Load(_ context.Context, _ string) (extruntime.Module, error) {
|
|
return nil, fmt.Errorf("%w: built without -tags v8vm", extruntime.ErrUnsupported)
|
|
}
|
|
|
|
func (*stubRuntime) Close() error { return nil }
|