simulator

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSimulatorNotFound = fmt.Errorf("simulator not found")
)

Common errors

Functions

func FormatFileDate

func FormatFileDate(t time.Time) string

FormatFileDate formats a date for display in the file list

func FormatHexDump

func FormatHexDump(data []byte, offset int64) []string

FormatHexDump formats binary data as hex dump

func FormatModTime

func FormatModTime(t time.Time) string

FormatModTime formats modification time in a human-friendly way

func FormatSize

func FormatSize(bytes int64) string

FormatSize formats bytes into human readable format

func GetSyntaxHighlightedLine

func GetSyntaxHighlightedLine(line string, fileExt string) string

GetSyntaxHighlightedLine returns a syntax highlighted version of a line This is a simple implementation - could be enhanced with a proper syntax highlighting library

func GetSyntaxHighlightedLineWithLang

func GetSyntaxHighlightedLineWithLang(line string, fileExt string, detectedLang string) string

GetSyntaxHighlightedLineWithLang returns a syntax highlighted version of a line with support for detected language override

func IsImageFile

func IsImageFile(filename string) bool

IsImageFile checks if a file is a supported image format (including SVG)

func ReadTableData

func ReadTableData(dbPath, tableName string, offset, limit int) ([]map[string]any, error)

ReadTableData reads paginated data from a specific table

Types

type App

type App struct {
	Name          string
	BundleID      string
	Version       string
	Size          int64
	Path          string
	Container     string
	SimulatorName string    // Name of the parent simulator
	SimulatorUDID string    // UDID of the parent simulator
	ModTime       time.Time // Last modified time of the app
}

App represents an installed application

func GetAllApps

func GetAllApps(fetcher Fetcher) ([]App, error)

GetAllApps returns all apps from all simulators with simulator info populated

func GetAppsForSimulator

func GetAppsForSimulator(udid string, isRunning bool) ([]App, error)

GetAppsForSimulator returns all apps installed on a simulator

type AppInfo

type AppInfo struct {
	DisplayName string
	BundleID    string
	Version     string
}

AppInfo represents parsed Info.plist data

type ArchiveEntry

type ArchiveEntry struct {
	Name           string
	Size           int64
	CompressedSize int64
	ModTime        time.Time
	IsDir          bool
}

ArchiveEntry represents a single file or directory in an archive

type ArchiveInfo

type ArchiveInfo struct {
	Format         string
	Entries        []ArchiveEntry
	FileCount      int
	FolderCount    int
	TotalSize      int64
	CompressedSize int64
}

ArchiveInfo contains information about an archive file

type ColumnInfo

type ColumnInfo struct {
	Name    string `json:"name"`
	Type    string `json:"type"`
	NotNull bool   `json:"not_null"`
	PK      bool   `json:"primary_key"`
}

ColumnInfo represents information about a table column

type DatabaseInfo

type DatabaseInfo struct {
	Format     string      `json:"format"`  // "SQLite", "MySQL", etc.
	Version    string      `json:"version"` // Database version
	FileSize   int64       `json:"file_size"`
	TableCount int         `json:"table_count"`
	Tables     []TableInfo `json:"tables"`
	Schema     string      `json:"schema"` // Full schema dump
	Error      string      `json:"error,omitempty"`
}

DatabaseInfo contains information about a database file

func ReadDatabaseContent

func ReadDatabaseContent(path string) (*DatabaseInfo, error)

ReadDatabaseContent reads information from a database file

type DevicesByRuntime

type DevicesByRuntime map[string][]Simulator

DevicesByRuntime maps runtime identifiers to simulators

type Fetcher

type Fetcher interface {
	Fetch() ([]Item, error)
	FetchSimulators() ([]Simulator, error)
	Boot(udid string) error
}

Fetcher is responsible for fetching simulator information

func NewFetcher

func NewFetcher() Fetcher

NewFetcher creates a new simulator fetcher

type FileContent

type FileContent struct {
	Type          FileType
	Lines         []string // For text files
	TotalLines    int      // Total number of lines in the file
	ImageInfo     *ImageInfo
	BinaryData    []byte        // For hex view (current chunk)
	BinaryOffset  int64         // Offset of the current chunk in the file
	TotalSize     int64         // Total size of the file (for binary files)
	ArchiveInfo   *ArchiveInfo  // For archive files
	DatabaseInfo  *DatabaseInfo // For database files
	IsBinaryPlist bool          // Whether this was converted from binary plist
	DetectedLang  string        // Detected language for syntax highlighting (e.g., "html")
	Error         error
}

FileContent represents the content of a file prepared for viewing

func ReadFileContent

func ReadFileContent(path string, startLine, maxLines, maxWidth int) (*FileContent, error)

ReadFileContent reads file content based on its type

type FileInfo

type FileInfo struct {
	Name        string
	Path        string
	Size        int64
	IsDirectory bool
	CreatedAt   time.Time
	ModifiedAt  time.Time
}

FileInfo represents information about a file or directory

func GetFilesForContainer

func GetFilesForContainer(containerPath string) ([]FileInfo, error)

GetFilesForContainer returns all files and directories in the app's data container

type FileType

type FileType int

FileType represents the type of file for viewing

const (
	FileTypeText FileType = iota
	FileTypeImage
	FileTypeBinary
	FileTypeArchive
	FileTypeDatabase
)

func DetectFileType

func DetectFileType(path string) FileType

DetectFileType determines the type of file based on content and extension

type ImageInfo

type ImageInfo struct {
	Format  string
	Width   int
	Height  int
	Size    int64
	Preview *ImagePreview
}

ImageInfo contains metadata about an image file

type ImagePreview

type ImagePreview struct {
	Width  int
	Height int
	Rows   []string // Pre-rendered rows with ANSI colors
}

ImagePreview contains the terminal-renderable preview

type Item

type Item struct {
	Simulator
	Runtime  string
	AppCount int
}

Item represents a simulator with its runtime information

type SimctlFetcher

type SimctlFetcher struct{}

SimctlFetcher fetches simulators using xcrun simctl

func (*SimctlFetcher) Boot

func (f *SimctlFetcher) Boot(udid string) error

Boot starts the simulator with the given UDID

func (*SimctlFetcher) Fetch

func (f *SimctlFetcher) Fetch() ([]Item, error)

Fetch retrieves all available iOS simulators

func (*SimctlFetcher) FetchSimulators

func (f *SimctlFetcher) FetchSimulators() ([]Simulator, error)

FetchSimulators retrieves all available simulators without app counts

type SimctlOutput

type SimctlOutput struct {
	Devices DevicesByRuntime `json:"devices"`
}

SimctlOutput represents the JSON output from simctl

type Simulator

type Simulator struct {
	UDID                 string `json:"udid"`
	Name                 string `json:"name"`
	State                string `json:"state"`
	IsAvailable          bool   `json:"isAvailable"`
	DeviceTypeIdentifier string `json:"deviceTypeIdentifier"`
}

Simulator represents an iOS simulator device

func (*Simulator) IsRunning

func (s *Simulator) IsRunning() bool

IsRunning returns true if the simulator is booted

func (*Simulator) StateDisplay

func (s *Simulator) StateDisplay() string

StateDisplay returns a user-friendly state description

type TableInfo

type TableInfo struct {
	Name     string           `json:"name"`
	RowCount int64            `json:"row_count"`
	Schema   string           `json:"schema"`
	Columns  []ColumnInfo     `json:"columns"`
	Sample   []map[string]any `json:"sample,omitempty"` // First few rows
}

TableInfo represents information about a database table

Jump to

Keyboard shortcuts

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