client

package
v0.1.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client exposes typed Pencode services over any owned byte stream.

Index

Constants

This section is empty.

Variables

View Source
var ErrBusy = errors.New("pencode: request queue is full")
View Source
var ErrClosed = errors.New("pencode: server connection closed")

Functions

This section is empty.

Types

type Client

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

func New

func New(ctx context.Context, conn io.ReadWriteCloser) (*Client, error)

func (*Client) BeginExtension

func (c *Client) BeginExtension(ctx context.Context) (*ExtensionUpload, error)

func (*Client) BrowseDirectory

func (c *Client) BrowseDirectory(ctx context.Context, directory string) (string, string, []string, error)

BrowseDirectory enumerates project choices without opening a workspace.

func (*Client) Close

func (c *Client) Close() error

func (*Client) CloseIndex

func (c *Client) CloseIndex(ctx context.Context, id uint64) error

func (*Client) CloseWorkspace

func (c *Client) CloseWorkspace(ctx context.Context, id uint64) error

func (*Client) Create

func (c *Client) Create(ctx context.Context, workspace uint64, path string, directory bool) error

func (*Client) Diff

func (c *Client) Diff(ctx context.Context, left, right string) ([]byte, error)

Diff encodes immutable editor text directly into the request buffer.

func (*Client) DisableExtension

func (c *Client) DisableExtension(ctx context.Context, id string) (protocol.ExtensionInfo, error)

func (*Client) Done

func (c *Client) Done() <-chan struct{}

Done closes as soon as transport failure makes every handle unusable.

func (*Client) Err

func (c *Client) Err() error

func (*Client) ForwardPort

func (c *Client) ForwardPort(parent context.Context, remote protocol.Port, options ForwardOptions) (*Forward, error)

func (*Client) Git

func (c *Client) Git(ctx context.Context, root string, args ...string) ([]byte, error)

func (*Client) GitRepositories

func (c *Client) GitRepositories(ctx context.Context, root string) ([]string, error)

func (*Client) Import

func (c *Client) Import(ctx context.Context, target uint64, source, directory string, overwrite bool) (string, error)

Import copies a native file on the server host into a workspace.

func (*Client) IndexPage

func (c *Client) IndexPage(ctx context.Context, id uint64, offset int, dst []protocol.IndexEntry) ([]protocol.IndexEntry, bool, string, error)

func (*Client) ListExtensions

func (c *Client) ListExtensions(ctx context.Context) (ExtensionCatalog, error)

func (*Client) ListeningPorts

func (c *Client) ListeningPorts(ctx context.Context) ([]protocol.Port, error)

func (*Client) LoadExtension

func (c *Client) LoadExtension(ctx context.Context, id string) (*Extension, error)

func (*Client) NewSyntax

func (c *Client) NewSyntax(ctx context.Context) *Syntax

func (*Client) OpenDebugAdapter

func (c *Client) OpenDebugAdapter(ctx context.Context, root, adapter, command, address string, args []string) (*Process, error)

OpenDebugAdapter returns the same owned, flow-controlled stream for local and SSH workspaces. Delve selects an ephemeral loopback port on the server.

func (*Client) OpenDebugTerminal

func (c *Client) OpenDebugTerminal(ctx context.Context, root string, command protocol.TerminalCommand) (*Process, int, error)

func (*Client) OpenDocument

func (c *Client) OpenDocument(ctx context.Context, workspace uint64, path string, mode protocol.DocumentMode) (*Document, string, error)

func (*Client) OpenIndex

func (c *Client) OpenIndex(ctx context.Context, root string) (uint64, error)

func (*Client) OpenProcess

func (c *Client) OpenProcess(ctx context.Context, root, name string, args ...string) (*Process, error)

func (*Client) OpenTerminal

func (c *Client) OpenTerminal(ctx context.Context, root string, cols, rows int) (*Process, error)

func (*Client) OpenWorkspace

func (c *Client) OpenWorkspace(ctx context.Context, path string) (protocol.Workspace, error)

func (*Client) PrepareEnableExtension

func (c *Client) PrepareEnableExtension(ctx context.Context, id string) (*Extension, error)

func (*Client) ReadConfiguration

func (c *Client) ReadConfiguration(ctx context.Context) (configuration.Snapshot, error)

func (*Client) ReadFile

func (c *Client) ReadFile(ctx context.Context, root, name string) ([]byte, error)

func (*Client) RefreshIndex

func (c *Client) RefreshIndex(ctx context.Context, root string, previous uint64) (uint64, error)

RefreshIndex reuses the previous snapshot and rereads directories reported by the native watcher. A missing or invalid snapshot is rebuilt in full.

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, workspace uint64, path string) error

func (*Client) RemoveExtension

func (c *Client) RemoveExtension(ctx context.Context, id string) error

func (*Client) Rename

func (c *Client) Rename(ctx context.Context, workspace uint64, from, to string) error

func (*Client) SaveFile

func (c *Client) SaveFile(ctx context.Context, root, name, before, after string) error

func (*Client) SaveSettings

func (c *Client) SaveSettings(ctx context.Context, data []byte) error

func (*Client) SearchPaths

func (c *Client) SearchPaths(ctx context.Context, id uint64, query string, preferred []string) ([]string, error)

func (*Client) SearchText

func (c *Client) SearchText(ctx context.Context, root, directory, query string, options textsearch.Options, documents []protocol.SearchDocument) (protocol.SearchResult, error)

func (*Client) Transfer

func (c *Client) Transfer(ctx context.Context, source, target uint64, from, directory string, cut, duplicate bool) (string, error)

func (*Client) WatchFiles

func (c *Client) WatchFiles(root string) *FileWatch

func (*Client) WorkFile

func (c *Client) WorkFile(ctx context.Context, root, name string) ([]byte, error)

type Directories

type Directories struct {
	Context   context.Context
	Client    *Client
	Workspace uint64
}

Directories supplies only directory enumeration to the existing scanner. File content is accessed through versioned Document APIs.

func (Directories) ReadDir

func (f Directories) ReadDir(name string) ([]fs.DirEntry, error)

type Document

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

Document keeps one latest immutable edit snapshot. Submitting an edit never waits for I/O and does not allocate. A worker coalesces intermediate snapshots and sends ordered, versioned deltas; saves explicitly wait for that barrier.

func (*Document) Close

func (d *Document) Close()

func (*Document) Move

func (d *Document) Move(ctx context.Context, workspace uint64, path string) error

func (*Document) Release

func (d *Document) Release()

Release retires a handle without waiting on the transport. Close additionally waits for cleanup and is intended for workers and connection shutdown.

func (*Document) Save

func (d *Document) Save(ctx context.Context, content string) error

func (*Document) SaveSnapshot

func (d *Document) SaveSnapshot[V piecetree.Value](ctx context.Context, value V) error

SaveSnapshot persists exactly content while Update may continue accepting newer GUI edits. The document worker owns both the version and save barrier; newer text is restored in memory afterwards and is never saved implicitly.

func (*Document) Update

func (d *Document) Update[V piecetree.Value](baseValue, contentValue V, start, oldEnd, newEnd int)

type Extension

type Extension struct {
	Info          protocol.ExtensionInfo
	Diagnostics   string
	Contributions peb.Contributions
	Handle        uint64
	// contains filtered or unexported fields
}

Extension is a connection-scoped server registration. No executable or asset path is interpreted on the GUI host.

func (*Extension) Abort

func (x *Extension) Abort(ctx context.Context) error

func (*Extension) Commit

Commit publishes a prepared package or persists a validated enable operation.

func (*Extension) FS

func (x *Extension) FS(ctx context.Context, cache map[string][]byte) fs.FS

FS lets appearance loaders consume remote resources through the standard Go filesystem interface. Each open returns bounded, memory-owned bytes.

func (*Extension) OpenLanguageServer

func (x *Extension) OpenLanguageServer(ctx context.Context, root, id string) (*Process, error)

func (*Extension) OpenProcess

func (x *Extension) OpenProcess(ctx context.Context, root string) (*Process, error)

func (*Extension) ReadResource

func (x *Extension) ReadResource(ctx context.Context, name string, limit int64) ([]byte, error)

func (*Extension) ReadResources

func (x *Extension) ReadResources(ctx context.Context, names []string, limit int64) (map[string][]byte, error)

ReadResources batches names and pages the response at the server's byte budget. Large resources can never exceed a protocol message.

func (*Extension) ReadWorkspaceFile

func (x *Extension) ReadWorkspaceFile(ctx context.Context, root, name string, limit int) ([]byte, error)

ReadWorkspaceFile reads a document asset through the workspace connection. Paths are resolved and confined to root by the workspace server.

type ExtensionCatalog

type ExtensionCatalog struct {
	Directory string
	Items     []protocol.ExtensionInfo
}

type ExtensionUpload

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

func (*ExtensionUpload) Abort

func (u *ExtensionUpload) Abort(ctx context.Context) error

func (*ExtensionUpload) Prepare

func (u *ExtensionUpload) Prepare(ctx context.Context) (*Extension, error)

func (*ExtensionUpload) Write

func (u *ExtensionUpload) Write(ctx context.Context, name string, offset uint64, mode uint32, final bool, data []byte) error

type FileWatch

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

FileWatch is an independent cursor over the file service's bounded event journal. Cancellation leaves the cursor intact so retry never loses a batch.

func (*FileWatch) Next

type Forward

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

Forward owns a local TCP listener and every connection accepted on it. Both the caller context and the backend connection bound its lifetime.

func (*Forward) Address

func (f *Forward) Address() string

func (*Forward) Close

func (f *Forward) Close() error

func (*Forward) Err

func (f *Forward) Err() error

type ForwardOptions

type ForwardOptions struct {
	Port          uint16
	AllInterfaces bool
}

type Process

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

Process is a flow-controlled stdio/PTY stream. Each reader has at most one outstanding receive of up to StreamWindow bytes; an idle stream cannot block the connection reader. Writes are serialized so concurrent callers cannot interleave the fragments of a logical Write.

func (*Process) Close

func (p *Process) Close() error

func (*Process) Done

func (p *Process) Done() <-chan struct{}

func (*Process) Read

func (p *Process) Read(dst []byte) (int, error)

func (*Process) Resize

func (p *Process) Resize(cols, rows int) error

func (*Process) Stderr

func (p *Process) Stderr() io.Reader

func (*Process) Wait

func (p *Process) Wait() error

func (*Process) Write

func (p *Process) Write(data []byte) (int, error)

type Syntax

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

Syntax owns a server lexical session. Updates transmit only the changed range. Like syntax.Document it belongs to one worker, never the render thread.

func (*Syntax) Close

func (s *Syntax) Close()

func (*Syntax) Language

func (s *Syntax) Language() string

func (*Syntax) Tokens

func (s *Syntax) Tokens(theme *syntax.Theme, definitions *syntax.Definitions) []syntax.Token

func (*Syntax) Update

func (s *Syntax) Update[V piecetree.Value](path string, value V) error

func (*Syntax) UpdateSnapshot

func (s *Syntax) UpdateSnapshot(path string, source piecetree.Snapshot) error

Jump to

Keyboard shortcuts

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