target

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Log             = "_log"
	Sleep           = "_sleep"
	ServiceRegister = "_astral_service_register"
	ServiceClose    = "_astral_service_close"
	ConnAccept      = "_astral_conn_accept"
	ConnClose       = "_astral_conn_close"
	ConnWrite       = "_astral_conn_write"
	ConnRead        = "_astral_conn_read"
	Query           = "_astral_query"
	QueryName       = "_astral_query_name"
	GetNodeInfo     = "_astral_node_info"
	ResolveId       = "_astral_resolve"
	Interrupt       = "_astral_interrupt"
)
View Source
const PackageJsonFilename = "package.json"
View Source
const PortalJsonFilename = "portal.json"
View Source
const TemplateInfoFileName = "template.json"

Variables

View Source
var ErrNotTarget = errors.New("not a target")
View Source
var PortMsg = PortPortal.Route("broadcast")
View Source
var PortOpen = PortPortal.Route("open")
View Source
var PortPortal = NewPort("portal")

Functions

func Abs

func Abs(src string) string

func ApiFactory

func ApiFactory(
	wrap func(Api) Api,
	frontendApphost NewApphost,
	backendApphost NewApphost,
) func(context.Context, Portal) Api

func Mapper

func Mapper[A any, T any](of ...func(A) (A, error)) func(A) (T, error)

func Skip

func Skip(names ...string) func(source Source) (result Source, err error)

Types

type Api

type Api interface{ Apphost }

type App

type App interface {
	IsApp()
	Portal
}

type AppExec

type AppExec interface {
	App
	Exec
}

type AppHtml

type AppHtml interface {
	App
	Html
}

type AppJs

type AppJs interface {
	App
	Js
}

type Apphost

type Apphost interface {
	ApphostCache
	ApphostApi
}

type ApphostApi

type ApphostApi interface {
	Close() error
	Interrupt()
	Log(arg ...any)
	LogArr(arg []any)
	Sleep(duration int64)
	ServiceRegister(service string) (err error)
	ServiceClose(service string) (err error)
	ConnAccept(service string) (data string, err error)
	ConnClose(id string) (err error)
	ConnWrite(id string, data string) (err error)
	ConnRead(id string) (data string, err error)
	Query(identity string, query string) (data string, err error)
	QueryName(name string, query string) (data string, err error)
	Resolve(name string) (id string, err error)
	NodeInfo(identity string) (info NodeInfo, err error)
}

type ApphostCache

type ApphostCache interface {
	Connections() []ApphostConn
	Listeners() []ApphostListener
	Events() *sig.Queue[ApphostEvent]
}

type ApphostConn

type ApphostConn struct {
	Query string
	In    bool
}

type ApphostEvent

type ApphostEvent struct {
	Type ApphostEventType
	Port string
	Ref  string
}

type ApphostEventType

type ApphostEventType int
const (
	ApphostConnect ApphostEventType = iota
	ApphostDisconnect
	ApphostRegister
	ApphostUnregister
)

type ApphostListener

type ApphostListener struct {
	Port string
}

type Bundle

type Bundle interface {
	IsBundle()
	App
}

type BundleExec

type BundleExec interface {
	Bundle
	Exec
}

type BundleHtml

type BundleHtml interface {
	Bundle
	Html
}

type BundleJs

type BundleJs interface {
	Bundle
	Js
}

type Cache

type Cache[T Portal] struct {
	// contains filtered or unexported fields
}

func (*Cache[T]) Add

func (c *Cache[T]) Add(portals Portals[T])

func (*Cache[T]) Get

func (c *Cache[T]) Get(src string) (portal Portal, ok bool)

type CreateProject

type CreateProject func(Template) error

type Dispatch

type Dispatch func(context.Context, string, ...string) (err error)

type Dist

type Dist interface {
	IsDist()
	App
}

type DistExec

type DistExec interface {
	Dist
	Exec
}

type DistHtml

type DistHtml interface {
	Dist
	Html
}

type DistJs

type DistJs interface {
	Dist
	Js
}

type Env

type Env struct {
	Timeout int64 `json:"timeout,omitempty"`
}

type Event

type Event int
const (
	DevChanged Event = iota
	DevRefreshed
)

type Exec

type Exec interface {
	Executable() Source
}

type Find

type Find[T Portal] func(ctx context.Context, src string) (portals Portals[T], err error)

type Finder

type Finder[T Portal] func(resolve Path, files ...fs.FS) Find[T]

func (Finder[T]) Cached

func (finder Finder[T]) Cached(c *Cache[T]) Finder[T]

type Html

type Html interface {
	IsHtml()
}

type Js

type Js interface {
	IsJs()
}

type Manifest

type Manifest struct {
	Name        string `json:"name,omitempty"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	Package     string `json:"package,omitempty"`
	Version     string `json:"version,omitempty"`
	Icon        string `json:"icon,omitempty"`
	Exec        string `json:"exec,omitempty"`
	Build       string `json:"build,omitempty"`
	Env         Env    `json:"env,omitempty"`
}

func (Manifest) Match

func (m Manifest) Match(port string) bool

type Msg

type Msg struct {
	Pkg   string    `json:"pkg"`
	Event Event     `json:"event"`
	Time  time.Time `json:"time"`
}

func NewMsg

func NewMsg(pkg string, event Event) Msg

type MsgSend

type MsgSend func(msg Msg) error

type MsgSender

type MsgSender func(port Port) MsgSend

type NewApi

type NewApi func(context.Context, Portal) Api

type NewApphost

type NewApphost func(ctx context.Context, portal Portal) Apphost

type NewTray

type NewTray func(dispatch Dispatch) Tray

type NodeInfo

type NodeInfo struct {
	Identity string
	Name     string
}

type NodeModule

type NodeModule interface {
	Source
	PkgJson() *PackageJson
}

type PackageJson

type PackageJson struct {
	Portal  string `json:"portal,omitempty"`
	Scripts struct {
		Build string `json:"build"`
	} `json:"scripts,omitempty"`
}

func (PackageJson) CanBuild

func (p PackageJson) CanBuild() bool

func (PackageJson) IsPortalLib

func (p PackageJson) IsPortalLib() bool

type Path

type Path func(src string) (path string, err error)

type Port

type Port struct {
	Base string
	Name string
}

func NewPort

func NewPort(base string) Port

func (Port) Copy

func (p Port) Copy(base string) Port

func (Port) Route

func (p Port) Route(name string) Port

func (Port) String

func (p Port) String() string

func (Port) Target

func (p Port) Target(portal Portal) Port

type Portal

type Portal interface {
	Source
	Manifest() *Manifest
}

type PortalHtml

type PortalHtml interface {
	Portal
	Html
}

type PortalJs

type PortalJs interface {
	Portal
	Js
}

type Portals

type Portals[T Portal] map[string]T

type Project

type Project interface {
	Portal
	IsProject()
	Dist() Dist
}

type ProjectGo

type ProjectGo interface {
	Project
	DistGolang() DistExec
}

type ProjectHtml

type ProjectHtml interface {
	ProjectNpm
	Html
	DistHtml() DistHtml
}

type ProjectJs

type ProjectJs interface {
	ProjectNpm
	Js
	DistJs() DistJs
}

type ProjectNpm

type ProjectNpm interface {
	Project
	NodeModule
}

type Resolve

type Resolve[T Source] func(src Source) (result T, err error)

func Any

func Any[T Source](of ...func(Source) (Source, error)) Resolve[T]

type ResolveSource

type ResolveSource Resolve[Source]

func Try

func Try[A Source, B Source](f func(A) (B, error)) ResolveSource

func (ResolveSource) Lift

func (from ResolveSource) Lift(to ...func(Source) (Source, error)) func(Source) (Source, error)

type Run

type Run[T Portal] func(ctx context.Context, src T) (err error)

func (Run[T]) Portal

func (r Run[T]) Portal() Run[Portal]

type Runner

type Runner[T Portal] interface {
	Run(ctx context.Context, src T) (err error)
	Reload() error
}

type Serve

type Serve func(ctx context.Context, tray bool) error

type Source

type Source interface {
	Abs() string
	Path() string
	Files() fs.FS
	Type() Type
	Lift() Source
	Parent() Source
	IsFile() bool
}

type Template

type Template interface {
	Source
	Info() TemplateInfo
	Name() string
}

type TemplateInfo

type TemplateInfo struct {
	Name        string `json:"name"`
	ShortName   string `json:"shortname"`
	Author      string `json:"author"`
	Description string `json:"description"`
	HelpUrl     string `json:"helpurl"`
}

type Tray

type Tray func(ctx context.Context) error

type Type

type Type int
const (
	TypeAny     Type = 0
	TypeBackend Type = 1 << (iota - 1)
	TypeFrontend
	TypeDev
	TypeBundle
)

func ParseType

func ParseType(def Type, args ...string) (typ Type)

func (Type) Is

func (t Type) Is(p Type) bool

Jump to

Keyboard shortcuts

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