dev

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package dev provides development session management for Flutter and React Native hot reload.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureCustomDevice

func EnsureCustomDevice(mobaiURL string) error

EnsureCustomDevice ensures Flutter custom_devices.json has mobai-ios configured.

func FindIPA

func FindIPA(distDir string) (string, error)

FindIPA lists IPAs in distDir and lets user select if multiple.

Types

type FileWatcher added in v0.3.0

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

FileWatcher watches for file changes and triggers callbacks.

func NewFileWatcher added in v0.3.0

func NewFileWatcher(cfg *FileWatcherConfig) (*FileWatcher, error)

NewFileWatcher creates a new file watcher with the given configuration.

func (*FileWatcher) Start added in v0.3.0

func (w *FileWatcher) Start(ctx context.Context) error

Start begins watching for file changes. It blocks until the context is cancelled.

func (*FileWatcher) Stop added in v0.3.0

func (w *FileWatcher) Stop()

Stop stops the file watcher.

type FileWatcherConfig added in v0.3.0

type FileWatcherConfig struct {
	Dirs     []string
	Patterns []string
	Ignore   []string
	Debounce time.Duration
	OnChange func()
}

FileWatcherConfig holds configuration for the file watcher.

type FlutterHandler added in v0.2.0

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

FlutterHandler implements FrameworkHandler for Flutter projects.

func NewFlutterHandler added in v0.2.0

func NewFlutterHandler(mobaiURL string, noAttach, noWatch bool, watchCfg *config.WatchConfig) *FlutterHandler

NewFlutterHandler creates a new Flutter handler.

func (*FlutterHandler) Attach added in v0.2.0

func (h *FlutterHandler) Attach(ctx context.Context, deviceID string, debugOutput <-chan mobai.DebugOutput) error

Attach finds the VM Service URL and runs flutter attach.

func (*FlutterHandler) DebugConfig added in v0.2.0

func (h *FlutterHandler) DebugConfig() *mobai.DebugConfig

DebugConfig returns nil for Flutter (no special environment needed).

func (*FlutterHandler) Setup added in v0.2.0

func (h *FlutterHandler) Setup(ctx context.Context) error

Setup configures Flutter custom device for MobAI.

func (*FlutterHandler) Stop added in v0.2.0

func (h *FlutterHandler) Stop()

type FrameworkHandler added in v0.2.0

type FrameworkHandler interface {
	// Setup runs before app install (e.g., Flutter custom device, Metro start)
	Setup(ctx context.Context) error
	// DebugConfig returns environment variables and arguments for app launch
	DebugConfig() *mobai.DebugConfig
	// Attach runs after app launch to enable hot reload
	Attach(ctx context.Context, deviceID string, debugOutput <-chan mobai.DebugOutput) error
	// Stop cleans up resources
	Stop()
}

FrameworkHandler handles framework-specific dev workflow.

type PollingWatcher added in v0.3.0

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

PollingWatcher watches for file changes using polling (for WSL2 compatibility).

func NewPollingWatcher added in v0.3.0

func NewPollingWatcher(cfg *FileWatcherConfig) *PollingWatcher

NewPollingWatcher creates a new polling-based file watcher.

func (*PollingWatcher) Start added in v0.3.0

func (w *PollingWatcher) Start(ctx context.Context) error

Start begins polling for file changes. It blocks until the context is cancelled.

func (*PollingWatcher) Stop added in v0.3.0

func (w *PollingWatcher) Stop()

Stop stops the polling watcher.

type ReactNativeHandler added in v0.2.0

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

ReactNativeHandler implements FrameworkHandler for React Native projects.

func NewReactNativeHandler added in v0.2.0

func NewReactNativeHandler(metroPort int, showLogs bool, mobaiURL string) *ReactNativeHandler

NewReactNativeHandler creates a new React Native handler.

func (*ReactNativeHandler) Attach added in v0.2.0

func (h *ReactNativeHandler) Attach(ctx context.Context, deviceID string, debugOutput <-chan mobai.DebugOutput) error

Attach monitors app output for React Native development.

func (*ReactNativeHandler) DebugConfig added in v0.2.0

func (h *ReactNativeHandler) DebugConfig() *mobai.DebugConfig

DebugConfig returns launch arguments to configure Metro connection. React Native reads RCT_jsLocation from NSUserDefaults, which can be set via launch arguments.

func (*ReactNativeHandler) Setup added in v0.2.0

func (h *ReactNativeHandler) Setup(ctx context.Context) error

Setup checks if Metro is running and starts it if not.

func (*ReactNativeHandler) Stop added in v0.2.0

func (h *ReactNativeHandler) Stop()

Stop cleans up Metro if we started it.

type RuntimeError

type RuntimeError struct {
	Err error
}

RuntimeError wraps runtime errors to distinguish from CLI errors

func (*RuntimeError) Error

func (e *RuntimeError) Error() string

type Session

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

Session manages a development session with MobAI.

func NewSession

func NewSession(mobaiURL, deviceID, ipaPath string, h FrameworkHandler) *Session

NewSession creates a new development session.

func (*Session) SetSkipInstall

func (s *Session) SetSkipInstall(skip bool, bundleID string)

SetSkipInstall configures the session to skip installation.

func (*Session) Start

func (s *Session) Start(ctx context.Context) error

Start runs the full dev session: setup, install, launch, attach.

func (*Session) Stop

func (s *Session) Stop()

Stop cleans up resources.

type StdinMux added in v0.3.0

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

StdinMux multiplexes stdin with programmatic command injection. It allows sending commands to flutter attach while also forwarding user input.

func NewStdinMux added in v0.3.0

func NewStdinMux() *StdinMux

NewStdinMux creates a new stdin multiplexer.

func (*StdinMux) Reader added in v0.3.0

func (m *StdinMux) Reader() io.Reader

Reader returns the reader that should be used for cmd.Stdin.

func (*StdinMux) SendCommand added in v0.3.0

func (m *StdinMux) SendCommand(cmd byte)

SendCommand injects a command byte into the stdin stream.

func (*StdinMux) Start added in v0.3.0

func (m *StdinMux) Start(ctx context.Context)

Start begins forwarding stdin and programmatic commands to the pipe. It blocks until Stop is called or context is cancelled.

func (*StdinMux) Stop added in v0.3.0

func (m *StdinMux) Stop() error

Stop closes the multiplexer and returns any error from closing the pipe.

Jump to

Keyboard shortcuts

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