automation

package
v0.0.0-...-0003c0b Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: GPL-2.0 Imports: 70 Imported by: 0

Documentation

Rendered for darwin/amd64

Index

Constants

View Source
const (
	SourceFolder  = "src"
	AssetsFolder  = "assets"
	DataFolder    = "data"
	InterfaceFile = "app.js"
	ExtensionFile = "extension.js"
	ExtensionMap  = "extension.js.map"
	ManifestFile  = "manifest.json"
	IconFile      = "icon.png"
)
View Source
const (
	REPLDirectory = "@repl"
)
View Source
const UpdateGuide = "https://swipt.io/"

Variables

View Source
var (
	ErrNotFound   = E.New("not found")
	ErrNotAllowed = E.New("not allowed")
	ErrInvalid    = device.ErrInvalid
	ErrOutdated   = E.New("Swipt is outdated")
)
View Source
var DefaultIcon = Icon{Color: "grayBrown", Symbol: "square.2.layers.3d.fill"}
View Source
var ErrDismissed = E.New("the person dismissed the dialog")

Functions

func CheckID

func CheckID(id string) error

func DecodeText

func DecodeText(data []byte, fatal bool) (text string, restored int, ok bool)

func EncodeManifest

func EncodeManifest(manifest Manifest) ([]byte, error)

func FailureOf

func FailureOf(err error) string

func FileNotFound

func FileNotFound(where, name string) error

func IsNewer

func IsNewer(remote Manifest, version string, versionCode int64) bool

func Message

func Message(err error) string

Types

type ActionInfo

type ActionInfo struct {
	Name        string          `json:"name"`
	Title       string          `json:"title"`
	Description string          `json:"description,omitempty"`
	Expose      []Caller        `json:"expose,omitempty"`
	Input       json.RawMessage `json:"input,omitempty"`
	Output      json.RawMessage `json:"output,omitempty"`
}

type Archive

type Archive struct {
	Manifest Manifest
	Files    []ArchiveFile
}

func ReadArchive

func ReadArchive(reader *zip.Reader) (Archive, error)

type ArchiveFile

type ArchiveFile struct {
	*zip.File
	Name string
}

type CallRequest

type CallRequest struct {
	Swiplet string
	Action  string
	Input   json.RawMessage
	Caller  Caller
	Dialog  Dialog
	Log     func(LogEntry)
}

type Caller

type Caller string
const (
	CallerApp       Caller = "app"
	CallerShortcuts Caller = "shortcuts"
	CallerAPI       Caller = "api"
)

type DatabaseChange

type DatabaseChange struct {
	Swiplet  string
	Database string
	Path     string
	Table    string
	RowID    int64
}

type Dialog

type Dialog struct {
	App      string
	InApp    bool
	Ask      func(ctx context.Context, request string) (string, error)
	Backdrop func(image []byte)
	Active   func() bool
}

type Failure

type Failure struct {
	Name    string  `json:"name"`
	Message string  `json:"message"`
	Stack   []Frame `json:"stack"`
}

func ScriptFailure

func ScriptFailure(err error) (*Failure, bool)

func (*Failure) Describe

func (f *Failure) Describe() string

func (*Failure) Error

func (f *Failure) Error() string

func (*Failure) Is

func (f *Failure) Is(target error) bool

func (*Failure) Summary

func (f *Failure) Summary() string

type FileInfo

type FileInfo struct {
	Name      string
	Directory bool
	Size      int64
	Modified  time.Time
}

type FileWriter

type FileWriter struct {
	*os.File
	// contains filtered or unexported fields
}

func (*FileWriter) Finish

func (w *FileWriter) Finish(abort error) error

type Frame

type Frame struct {
	Function string `json:"function"`
	File     string `json:"file"`
	Line     int    `json:"line"`
	Column   int    `json:"column"`
}

type Graphics

type Graphics interface {
	Entry() uintptr
	Run(engine uint64, call int64, context *GraphicsCall) (json.RawMessage, error)
	Watch(engine uint64, call int64, context *GraphicsCall, publish func(any)) error
}

type GraphicsCall

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

func (*GraphicsCall) Authorize

func (c *GraphicsCall) Authorize(name string, write bool) error

func (*GraphicsCall) Context

func (c *GraphicsCall) Context() context.Context

func (*GraphicsCall) Screenshot

func (c *GraphicsCall) Screenshot() ([]byte, float64, error)

func (*GraphicsCall) Trace

func (c *GraphicsCall) Trace(at time.Time, name, detail string, duration time.Duration)

func (*GraphicsCall) Tracing

func (c *GraphicsCall) Tracing() bool

func (*GraphicsCall) WatchTimeline

func (c *GraphicsCall) WatchTimeline() *TimelineWatch

type Host

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

func New

func New(options Options) *Host

func (*Host) AwaitService

func (h *Host) AwaitService(ctx context.Context, id string, enabled bool, requested time.Time) (ServiceState, error)

func (*Host) Call

func (h *Host) Call(ctx context.Context, request CallRequest) (json.RawMessage, error)

func (*Host) ClearData

func (h *Host) ClearData(id string) error

func (*Host) Close

func (h *Host) Close()

func (*Host) CloseDatabases

func (h *Host) CloseDatabases(client any, swiplet string)

func (*Host) Install

func (h *Host) Install(archive io.ReaderAt, size int64) (Swiplet, error)

func (*Host) ListFiles

func (h *Host) ListFiles(id, kind, name string) (files []FileInfo, err error)

func (*Host) Log

func (h *Host) Log(swiplet string, level log.Level, message string)

func (*Host) NewREPL

func (h *Host) NewREPL(dialog Dialog) *REPL

func (*Host) OpenWeb

func (h *Host) OpenWeb(id string) (*WebSession, error)

func (*Host) ReadFile

func (h *Host) ReadFile(id, kind, name string) (data []byte, err error)

func (*Host) Remove

func (h *Host) Remove(id string) error

func (*Host) RemoveFile

func (h *Host) RemoveFile(id, kind, name string) error

func (*Host) RetryServices

func (h *Host) RetryServices()

func (*Host) SQLite

func (h *Host) SQLite(client any, swiplet string, request []byte) (any, error)

func (*Host) Service

func (h *Host) Service(id string) (ServiceState, error)

func (*Host) SetServiceEnabled

func (h *Host) SetServiceEnabled(id string, enabled bool) error

func (*Host) Start

func (h *Host) Start()

func (*Host) Swiplet

func (h *Host) Swiplet(id string) (Swiplet, error)

func (*Host) Swiplets

func (h *Host) Swiplets() ([]Swiplet, error)

func (*Host) WatchDatabases

func (h *Host) WatchDatabases(ctx context.Context, swiplet string, publish func(DatabaseChange))

func (*Host) WatchServiceLogs

func (h *Host) WatchServiceLogs(ctx context.Context, id string, observe func(LogEntry)) error

func (*Host) WatchServices

func (h *Host) WatchServices(ctx context.Context, observe func(id string, state ServiceState)) error

func (*Host) WriteFile

func (h *Host) WriteFile(id, kind, name string, data []byte) error

type Icon

type Icon struct {
	Color  string `json:"color"`
	Symbol string `json:"symbol"`
}

func LoadIcon

func LoadIcon(directory string) Icon

func (Icon) Check

func (i Icon) Check() error

type LogEntry

type LogEntry struct {
	Time    time.Time
	Level   log.Level
	Message string
}

type Manifest

type Manifest struct {
	ID              string
	Name            string
	LocalizedNames  map[string]string
	Description     string
	Version         string
	VersionCode     int64
	Icon            Icon
	UpdateURL       string
	MinimumAPILevel int64
	Interface       bool
	Service         bool
	Actions         []ActionInfo
	// contains filtered or unexported fields
}

func LoadManifest

func LoadManifest(directory string) (Manifest, error)

func ParseManifest

func ParseManifest(data []byte) (Manifest, error)

type Options

type Options struct {
	Device            *device.Phone
	Directory         string
	Caches            string
	Languages         []string
	LogFactory        *log.Factory
	Dialog            Dialog
	Graphics          Graphics
	OnSwipletsChanged func()
}

type Output

type Output struct {
	Kind  OutputKind
	Level log.Level
	Text  string
	JSON  json.RawMessage
	Image []byte
}

type OutputKind

type OutputKind int
const (
	OutputConsole OutputKind = iota
	OutputValue
	OutputImage
)

type REPL

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

func (*REPL) Close

func (r *REPL) Close()

func (*REPL) Execute

func (r *REPL) Execute(ctx context.Context, script Script, timeout time.Duration, emit func(Output)) error

func (*REPL) Reset

func (r *REPL) Reset(ctx context.Context) error

type Script

type Script struct {
	Code    string
	Args    []string
	Program bool
}

type ServiceState

type ServiceState struct {
	Enabled bool
	Status  ServiceStatus
	Error   string
	Failure *Failure
	Since   time.Time
}

type ServiceStatus

type ServiceStatus string
const (
	ServiceStarting ServiceStatus = "starting"
	ServiceRunning  ServiceStatus = "running"
	ServiceStopped  ServiceStatus = "stopped"
	ServiceFailed   ServiceStatus = "failed"
)

type Swiplet

type Swiplet struct {
	ID        string
	Directory string
	Manifest  Manifest
}

type TimeLimitError

type TimeLimitError struct {
	Limit time.Duration
}

func (*TimeLimitError) Error

func (e *TimeLimitError) Error() string

func (*TimeLimitError) Is

func (e *TimeLimitError) Is(target error) bool

type TimelineEvent

type TimelineEvent struct {
	Time       int64             `json:"time"`
	Type       string            `json:"type"`
	Name       string            `json:"name,omitempty"`
	Arguments  []json.RawMessage `json:"arguments,omitempty"`
	DurationMs float64           `json:"durationMs,omitempty"`
	Error      string            `json:"error,omitempty"`
	Swiplet    string            `json:"swiplet,omitempty"`
	Action     string            `json:"action,omitempty"`
	Caller     string            `json:"caller,omitempty"`
	App        string            `json:"app,omitempty"`
	Level      string            `json:"level,omitempty"`
	Message    string            `json:"message,omitempty"`
}

type TimelineWatch

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

func (*TimelineWatch) Stop

func (w *TimelineWatch) Stop() []TimelineEvent

type WebSession

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

func (*WebSession) Cancel

func (s *WebSession) Cancel(id string)

func (*WebSession) Close

func (s *WebSession) Close()

func (*WebSession) Compression

func (s *WebSession) Compression(format, mode string) ([]string, error)

func (*WebSession) Digest

func (s *WebSession) Digest(algorithm string, data []byte) ([]byte, error)

func (*WebSession) OpenFile

func (s *WebSession) OpenFile(kind, name string) string

func (*WebSession) Put

func (s *WebSession) Put(data []byte) string

func (*WebSession) Random

func (s *WebSession) Random(length int) ([]byte, error)

func (*WebSession) Release

func (s *WebSession) Release(id, reason string)

func (*WebSession) Start

func (s *WebSession) Start(id, name, encoded string, done func(value any, err error))

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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