target

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 13 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

ApiFactory deprecated FIXME refactor & remove

func Combine added in v0.1.0

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

func List added in v0.1.0

func List[T any](resolve Resolve[T], from ...Source) (out []T)

List all Source from a given dir.

func Match added in v0.1.0

func Match[T any](arg Portal_) (ok bool)

func Skip

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

Types

type Api

type Api interface{ Apphost }

type App

type App[T any] interface {
	Portal[T]
	IsApp()
}

type AppBundle added in v0.1.0

type AppBundle[T any] interface {
	Package() Source
	App[T]
}

type AppExec

type AppExec App[Exec]

type AppHtml

type AppHtml App[Html]

type AppJs

type AppJs App[Js]

type App_ added in v0.1.0

type App_ interface {
	Portal_
	IsApp()
}

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 {
	Source
	Package() Source
}

type BundleExec

type BundleExec AppBundle[Exec]

type BundleHtml

type BundleHtml AppBundle[Html]

type BundleJs

type BundleJs AppBundle[Js]

type Bundle_ added in v0.1.0

type Bundle_ interface {
	Package() Source
	App_
}

type Cache

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

func (*Cache[T]) Add

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

func (*Cache[T]) Get

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

func (*Cache[T]) Path added in v0.1.0

func (c *Cache[T]) Path(src string) (path string, err error)

type Dispatch

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

type Dist

type Dist[T any] interface {
	IsDist()
	App[T]
}

type DistExec

type DistExec Dist[Exec]

type DistHtml

type DistHtml Dist[Html]

type DistJs

type DistJs Dist[Js]

type Dist_ added in v0.1.0

type Dist_ interface {
	IsDist()
	App_
}

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 File added in v0.1.0

type File func(path ...string) (source Source, err error)

type Find

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

func (Find[T]) Reduced added in v0.1.0

func (f Find[T]) Reduced() Find[T]

func (Find[T]) SortedBy added in v0.1.0

func (f Find[T]) SortedBy(priority Priority) Find[T]

type Html

type Html interface{ IndexHtml() }

type Js

type Js interface{ MainJs() }

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(id string) bool

type Matcher added in v0.1.0

type Matcher func(arg Portal_) (ok 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 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[T any] interface {
	Portal_
	Target() T
}

type PortalExec added in v0.1.0

type PortalExec Portal[Exec]

type PortalHtml

type PortalHtml Portal[Html]

type PortalJs

type PortalJs Portal[Js]

type Portal_ added in v0.1.0

type Portal_ interface {
	Source
	Manifest() *Manifest
}

type Portals

type Portals[T Portal_] []T

func Set added in v0.1.0

func Set[T Portal_](resolve Resolve[T], from ...Source) (out Portals[T])

Set all Source from a given dir.

func (Portals[T]) Reduced added in v0.1.0

func (p Portals[T]) Reduced() (reduced Portals[T])

func (Portals[T]) SortBy added in v0.1.0

func (p Portals[T]) SortBy(priority Priority)

type Priority added in v0.1.0

type Priority []Matcher

func (Priority) Get added in v0.1.0

func (priority Priority) Get(app Portal_) int

type Project

type Project[T any] interface {
	Portal[T]
	IsProject()
	Dist_() Dist_
	Dist() Dist[T]
}

type ProjectExec added in v0.1.0

type ProjectExec Project[Exec]

type ProjectGo

type ProjectGo interface {
	Project[Exec]
	IsGo()
}

type ProjectHtml

type ProjectHtml ProjectNpm[Html]

type ProjectJs

type ProjectJs ProjectNpm[Js]

type ProjectNpm

type ProjectNpm[T any] interface {
	Project[T]
	PkgJson() *PackageJson
}

type ProjectNpm_ added in v0.1.0

type ProjectNpm_ interface {
	Project_
	PkgJson() *PackageJson
}

type Project_ added in v0.1.0

type Project_ interface {
	Portal_
	IsProject()
	Dist_() Dist_
}

type Resolve

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

func Any

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

func Try

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

type Run

type Run[T Source] 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 Source

type Source interface {
	Abs() string
	Path() string
	Files() fs.FS
	Sub(dir string) (Source, error)
	IsDir() 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

Directories

Path Synopsis
js

Jump to

Keyboard shortcuts

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