electron

package
v0.50.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

README

Electron

The Electron target bundles the platform-specific Electron bundle into a target. Electron implements the Runtime interface for creating/controlling WebView.

Documentation

Index

Constants

View Source
const ConfigID = ControllerID

ConfigID is the string used to identify this config object.

View Source
const ControllerID = "bldr/web/plugin/electron"

ControllerID is the browser runtime controller ID.

View Source
const RuntimeID = "electron"

RuntimeID is the runtime identifier

Variables

View Source
var (
	ExternalLinks_name = map[int32]string{
		0: "EXTERNAL_LINKS_OS_BROWSER",
		1: "EXTERNAL_LINKS_DENY",
	}
	ExternalLinks_value = map[string]int32{
		"EXTERNAL_LINKS_OS_BROWSER": 0,
		"EXTERNAL_LINKS_DENY":       1,
	}
)

Enum value maps for ExternalLinks.

View Source
var (
	QuitPolicy_name = map[int32]string{
		0: "QUIT_POLICY_UNSPECIFIED",
		1: "QUIT_POLICY_RESTART",
		2: "QUIT_POLICY_EXIT",
	}
	QuitPolicy_value = map[string]int32{
		"QUIT_POLICY_UNSPECIFIED": 0,
		"QUIT_POLICY_RESTART":     1,
		"QUIT_POLICY_EXIT":        2,
	}
)

Enum value maps for QuitPolicy.

View Source
var Version = semver.MustParse("0.0.1")

Version is the API version.

Functions

This section is empty.

Types

type Config

type Config struct {

	// ElectronPath is the path to the electron binary.
	ElectronPath string `protobuf:"bytes,1,opt,name=electron_path,json=electronPath,proto3" json:"electronPath,omitempty"`
	// WorkdirPath is the path to the working directory to use.
	// If unset, defaults to the current working directory of the process.
	WorkdirPath string `protobuf:"bytes,5,opt,name=workdir_path,json=workdirPath,proto3" json:"workdirPath,omitempty"`
	// RendererPath is the path to the renderer bundle.
	// Must be one of the accepted Electron path types.
	// Ex: http://, file://, path to directory, path to index.js
	// Relative paths must be relative to workdir_path.
	RendererPath string `protobuf:"bytes,2,opt,name=renderer_path,json=rendererPath,proto3" json:"rendererPath,omitempty"`
	// WebRuntimeId is the value to use for the runtime uuid.
	// Used for the Unix pipe paths and for the BroadcastChannel ids.
	// Should be unique against other running Electron instances.
	WebRuntimeId string `protobuf:"bytes,3,opt,name=web_runtime_id,json=webRuntimeId,proto3" json:"webRuntimeId,omitempty"`
	// ElectronFlags are additional flags to pass to electron.
	ElectronFlags []string `protobuf:"bytes,4,rep,name=electron_flags,json=electronFlags,proto3" json:"electronFlags,omitempty"`
	// ExternalLinks configures how external links are handled.
	ExternalLinks ExternalLinks `protobuf:"varint,6,opt,name=external_links,json=externalLinks,proto3" json:"externalLinks,omitempty"`
	// AppName is the application display name.
	AppName string `protobuf:"bytes,7,opt,name=app_name,json=appName,proto3" json:"appName,omitempty"`
	// WindowTitle overrides the window title (defaults to app_name).
	WindowTitle string `protobuf:"bytes,8,opt,name=window_title,json=windowTitle,proto3" json:"windowTitle,omitempty"`
	// WindowWidth is the default window width in pixels.
	WindowWidth uint32 `protobuf:"varint,9,opt,name=window_width,json=windowWidth,proto3" json:"windowWidth,omitempty"`
	// WindowHeight is the default window height in pixels.
	WindowHeight uint32 `protobuf:"varint,10,opt,name=window_height,json=windowHeight,proto3" json:"windowHeight,omitempty"`
	// DevTools enables DevTools on window creation.
	DevTools bool `protobuf:"varint,11,opt,name=dev_tools,json=devTools,proto3" json:"devTools,omitempty"`
	// ThemeSource sets native theme ("dark", "light", "system").
	ThemeSource string `protobuf:"bytes,12,opt,name=theme_source,json=themeSource,proto3" json:"themeSource,omitempty"`
	// QuitPolicy configures whether user quit should restart or exit.
	QuitPolicy QuitPolicy `protobuf:"varint,13,opt,name=quit_policy,json=quitPolicy,proto3" json:"quitPolicy,omitempty"`
	// contains filtered or unexported fields
}

Config is the configuration for the electron runtime.

func (*Config) CloneMessageVT

func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Config) CloneVT

func (m *Config) CloneVT() *Config

func (*Config) EqualMessageVT

func (this *Config) EqualMessageVT(thatMsg any) bool

func (*Config) EqualVT

func (this *Config) EqualVT(that *Config) bool

func (*Config) EqualsConfig

func (c *Config) EqualsConfig(other config.Config) bool

EqualsConfig checks if the other config is equal.

func (*Config) GetAppName

func (x *Config) GetAppName() string

func (*Config) GetConfigID

func (c *Config) GetConfigID() string

GetConfigID returns the unique string for this configuration type.

func (*Config) GetDevTools

func (x *Config) GetDevTools() bool

func (*Config) GetElectronFlags

func (x *Config) GetElectronFlags() []string

func (*Config) GetElectronPath

func (x *Config) GetElectronPath() string
func (x *Config) GetExternalLinks() ExternalLinks

func (*Config) GetQuitPolicy

func (x *Config) GetQuitPolicy() QuitPolicy

func (*Config) GetRendererPath

func (x *Config) GetRendererPath() string

func (*Config) GetThemeSource

func (x *Config) GetThemeSource() string

func (*Config) GetWebRuntimeId

func (x *Config) GetWebRuntimeId() string

func (*Config) GetWindowHeight

func (x *Config) GetWindowHeight() uint32

func (*Config) GetWindowTitle

func (x *Config) GetWindowTitle() string

func (*Config) GetWindowWidth

func (x *Config) GetWindowWidth() uint32

func (*Config) GetWorkdirPath

func (x *Config) GetWorkdirPath() string

func (*Config) MarshalJSON

func (x *Config) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Config to JSON.

func (*Config) MarshalProtoJSON

func (x *Config) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Config message to JSON.

func (*Config) MarshalProtoText

func (x *Config) MarshalProtoText() string

func (*Config) MarshalToSizedBufferVT

func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Config) MarshalToVT

func (m *Config) MarshalToVT(dAtA []byte) (int, error)

func (*Config) MarshalVT

func (m *Config) MarshalVT() (dAtA []byte, err error)

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) Reset

func (x *Config) Reset()

func (*Config) SizeVT

func (m *Config) SizeVT() (n int)

func (*Config) String

func (x *Config) String() string

func (*Config) UnmarshalJSON

func (x *Config) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Config from JSON.

func (*Config) UnmarshalProtoJSON

func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Config message from JSON.

func (*Config) UnmarshalVT

func (m *Config) UnmarshalVT(dAtA []byte) error

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller is the electron runtime controller.

Communicates with the electron Renderer via IPC.

func NewController

func NewController(
	le *logrus.Entry,
	b bus.Bus,
	electronPath, workdirPath, rendererPath,
	runtimeUuid string,
	extraElectronArgs []string,
	electronInit *ElectronInit,
) (*Controller, error)

NewController constructs a new browser runtime which starts Electron. sessionUuid is used to make the unix pipe path unique.

func (*Controller) Close

func (r *Controller) Close() error

Close closes the runtime.

func (*Controller) Execute

func (r *Controller) Execute(ctx context.Context) error

Execute executes the runtime. Returns any errors, nil if Execute is not required.

func (*Controller) GetBus

func (r *Controller) GetBus() bus.Bus

GetBus returns the root controller bus to use in this process.

func (*Controller) GetControllerInfo

func (r *Controller) GetControllerInfo() *controller.Info

GetControllerInfo returns information about the controller.

func (*Controller) GetLogger

func (r *Controller) GetLogger() *logrus.Entry

GetLogger returns the root log entry.

func (*Controller) HandleDirective

func (r *Controller) HandleDirective(ctx context.Context, di directive.Instance) ([]directive.Resolver, error)

HandleDirective asks if the handler can resolve the directive.

func (*Controller) WaitElectron

func (r *Controller) WaitElectron(ctx context.Context, errCh <-chan error) (*Electron, error)

WaitElectron waits for the Electron object to be ready and returns it. if errCh is set, checks it for errors to return early.

type Electron

type Electron struct {
	// contains filtered or unexported fields
}

Electron is a running instance of Electron.

func RunElectron

func RunElectron(
	ctx context.Context,
	le *logrus.Entry,
	electronPath,
	workdirPath,
	rendererPath,
	runtimeUuid string,
	extraElectronFlags []string,
	electronInit *ElectronInit,
) (*Electron, error)

RunElectron listens on the IPC pipe and starts Electron sub-process.

func (*Electron) Close

func (e *Electron) Close()

Close shuts down the electron instance.

func (*Electron) GetCmd

func (e *Electron) GetCmd() *oexec.Cmd

GetCmd returns the running Electron command.

func (*Electron) GetMuxedConn

func (e *Electron) GetMuxedConn() srpc.MuxedConn

GetMuxedConn returns the muxed conn with the main process.

func (*Electron) Wait

func (e *Electron) Wait(ctx context.Context) error

Wait waits for the Electron process to exit.

type ElectronInit

type ElectronInit struct {

	// ExternalLinks configures how external links are handled.
	ExternalLinks ExternalLinks `protobuf:"varint,1,opt,name=external_links,json=externalLinks,proto3" json:"externalLinks,omitempty"`
	// AppName is the application display name.
	AppName string `protobuf:"bytes,2,opt,name=app_name,json=appName,proto3" json:"appName,omitempty"`
	// WindowTitle overrides the window title (defaults to app_name).
	WindowTitle string `protobuf:"bytes,3,opt,name=window_title,json=windowTitle,proto3" json:"windowTitle,omitempty"`
	// WindowWidth is the default window width in pixels (default: 900).
	WindowWidth uint32 `protobuf:"varint,4,opt,name=window_width,json=windowWidth,proto3" json:"windowWidth,omitempty"`
	// WindowHeight is the default window height in pixels (default: 680).
	WindowHeight uint32 `protobuf:"varint,5,opt,name=window_height,json=windowHeight,proto3" json:"windowHeight,omitempty"`
	// DevTools enables DevTools on window creation (default: false).
	DevTools bool `protobuf:"varint,6,opt,name=dev_tools,json=devTools,proto3" json:"devTools,omitempty"`
	// ThemeSource sets native theme ("dark", "light", "system").
	ThemeSource string `protobuf:"bytes,7,opt,name=theme_source,json=themeSource,proto3" json:"themeSource,omitempty"`
	// QuitPolicy configures whether user quit should restart or exit.
	QuitPolicy QuitPolicy `protobuf:"varint,8,opt,name=quit_policy,json=quitPolicy,proto3" json:"quitPolicy,omitempty"`
	// contains filtered or unexported fields
}

ElectronInit is passed from Go to the Electron main process on startup.

func (*ElectronInit) CloneMessageVT

func (m *ElectronInit) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*ElectronInit) CloneVT

func (m *ElectronInit) CloneVT() *ElectronInit

func (*ElectronInit) EqualMessageVT

func (this *ElectronInit) EqualMessageVT(thatMsg any) bool

func (*ElectronInit) EqualVT

func (this *ElectronInit) EqualVT(that *ElectronInit) bool

func (*ElectronInit) GetAppName

func (x *ElectronInit) GetAppName() string

func (*ElectronInit) GetDevTools

func (x *ElectronInit) GetDevTools() bool
func (x *ElectronInit) GetExternalLinks() ExternalLinks

func (*ElectronInit) GetQuitPolicy

func (x *ElectronInit) GetQuitPolicy() QuitPolicy

func (*ElectronInit) GetThemeSource

func (x *ElectronInit) GetThemeSource() string

func (*ElectronInit) GetWindowHeight

func (x *ElectronInit) GetWindowHeight() uint32

func (*ElectronInit) GetWindowTitle

func (x *ElectronInit) GetWindowTitle() string

func (*ElectronInit) GetWindowWidth

func (x *ElectronInit) GetWindowWidth() uint32

func (*ElectronInit) MarshalJSON

func (x *ElectronInit) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ElectronInit to JSON.

func (*ElectronInit) MarshalProtoJSON

func (x *ElectronInit) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the ElectronInit message to JSON.

func (*ElectronInit) MarshalProtoText

func (x *ElectronInit) MarshalProtoText() string

func (*ElectronInit) MarshalToSizedBufferVT

func (m *ElectronInit) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*ElectronInit) MarshalToVT

func (m *ElectronInit) MarshalToVT(dAtA []byte) (int, error)

func (*ElectronInit) MarshalVT

func (m *ElectronInit) MarshalVT() (dAtA []byte, err error)

func (*ElectronInit) ProtoMessage

func (*ElectronInit) ProtoMessage()

func (*ElectronInit) Reset

func (x *ElectronInit) Reset()

func (*ElectronInit) SizeVT

func (m *ElectronInit) SizeVT() (n int)

func (*ElectronInit) String

func (x *ElectronInit) String() string

func (*ElectronInit) UnmarshalJSON

func (x *ElectronInit) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the ElectronInit from JSON.

func (*ElectronInit) UnmarshalProtoJSON

func (x *ElectronInit) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the ElectronInit message from JSON.

func (*ElectronInit) UnmarshalVT

func (m *ElectronInit) UnmarshalVT(dAtA []byte) error
type ExternalLinks int32

ExternalLinks configures how external links are handled.

const (
	// EXTERNAL_LINKS_OS_BROWSER opens external links in the OS default browser.
	ExternalLinks_EXTERNAL_LINKS_OS_BROWSER ExternalLinks = 0
	// EXTERNAL_LINKS_DENY denies all external link navigation.
	ExternalLinks_EXTERNAL_LINKS_DENY ExternalLinks = 1
)

func (ExternalLinks) Enum

func (x ExternalLinks) Enum() *ExternalLinks

func (ExternalLinks) MarshalJSON

func (x ExternalLinks) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ExternalLinks to JSON.

func (ExternalLinks) MarshalProtoJSON

func (x ExternalLinks) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the ExternalLinks to JSON.

func (ExternalLinks) MarshalProtoText

func (x ExternalLinks) MarshalProtoText() string

func (ExternalLinks) MarshalText

func (x ExternalLinks) MarshalText() ([]byte, error)

MarshalText marshals the ExternalLinks to text.

func (ExternalLinks) String

func (x ExternalLinks) String() string

func (*ExternalLinks) UnmarshalJSON

func (x *ExternalLinks) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the ExternalLinks from JSON.

func (*ExternalLinks) UnmarshalProtoJSON

func (x *ExternalLinks) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the ExternalLinks from JSON.

func (*ExternalLinks) UnmarshalText

func (x *ExternalLinks) UnmarshalText(b []byte) error

UnmarshalText unmarshals the ExternalLinks from text.

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

Factory constructs a Electron runtime controller.

func NewFactory

func NewFactory(bus bus.Bus) *Factory

NewFactory builds a Browser runtime factory.

func (*Factory) Construct

func (t *Factory) Construct(
	ctx context.Context,
	conf config.Config,
	opts controller.ConstructOpts,
) (controller.Controller, error)

Construct constructs the associated controller given configuration.

func (*Factory) ConstructConfig

func (t *Factory) ConstructConfig() config.Config

ConstructConfig constructs an instance of the controller configuration.

func (*Factory) GetConfigID

func (t *Factory) GetConfigID() string

GetConfigID returns the configuration ID for the controller.

func (*Factory) GetControllerID

func (t *Factory) GetControllerID() string

GetControllerID returns the unique ID for the controller.

func (*Factory) GetVersion

func (t *Factory) GetVersion() semver.Version

GetVersion returns the version of this controller.

type QuitPolicy

type QuitPolicy int32

QuitPolicy configures how the Electron runtime behaves on user quit.

const (
	// QUIT_POLICY_UNSPECIFIED lets the caller choose the runtime default.
	QuitPolicy_QUIT_POLICY_UNSPECIFIED QuitPolicy = 0
	// QUIT_POLICY_RESTART keeps the host restart-friendly after user quit.
	QuitPolicy_QUIT_POLICY_RESTART QuitPolicy = 1
	// QUIT_POLICY_EXIT exits cleanly without restart after user quit.
	QuitPolicy_QUIT_POLICY_EXIT QuitPolicy = 2
)

func (QuitPolicy) Enum

func (x QuitPolicy) Enum() *QuitPolicy

func (QuitPolicy) MarshalJSON

func (x QuitPolicy) MarshalJSON() ([]byte, error)

MarshalJSON marshals the QuitPolicy to JSON.

func (QuitPolicy) MarshalProtoJSON

func (x QuitPolicy) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the QuitPolicy to JSON.

func (QuitPolicy) MarshalProtoText

func (x QuitPolicy) MarshalProtoText() string

func (QuitPolicy) MarshalText

func (x QuitPolicy) MarshalText() ([]byte, error)

MarshalText marshals the QuitPolicy to text.

func (QuitPolicy) String

func (x QuitPolicy) String() string

func (*QuitPolicy) UnmarshalJSON

func (x *QuitPolicy) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the QuitPolicy from JSON.

func (*QuitPolicy) UnmarshalProtoJSON

func (x *QuitPolicy) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the QuitPolicy from JSON.

func (*QuitPolicy) UnmarshalText

func (x *QuitPolicy) UnmarshalText(b []byte) error

UnmarshalText unmarshals the QuitPolicy from text.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL