{"modulePath":"github.com/pencode-labs/pencode","version":"v0.1.0-rc.15","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package peb\n\nPackage peb implements Pencode Extension Binary protocol version 20. Frames and payloads use little endian integers; stdout is reserved for frames.\n\n## Constants\n\n```go\nconst (\n\tVersion    = 20\n\tHeaderSize = 20\n\tMaxPayload = 4 \u003c\u003c 20\n\tMaxString  = 64 \u003c\u003c 10\n\tMaxItems   = 16384\n)\n```\n\n```go\nconst MaxDocument = 2 \u003c\u003c 20\n```\n\n```go\nconst MaxSessions = 256\n```\n\n## Variables\n\n```go\nvar ErrProtocol = errors.New(\"peb: invalid protocol message\")\n```\n\n```go\nvar ErrViewBase = errors.New(\"peb: missing view patch base\")\n```\nErrViewBase asks the session to request a full view through resync.\n\n## Functions\n\n```go\nfunc DecodeFailure(data []byte) (string, error)\n```\n\n```go\nfunc DecodeSetting[T any](values SettingValues, id string) (value T, err error)\n```\nDecodeSetting reads a typed value from a complete settings snapshot.\n\n```go\nfunc EncodeActionChange(dst []byte, v ActionChange) ([]byte, error)\n```\n\n```go\nfunc EncodeActionContext(dst []byte, v ActionContext) ([]byte, error)\n```\n\n```go\nfunc EncodeContributions(dst []byte, v Contributions) ([]byte, error)\n```\n\n```go\nfunc EncodeEditorMessage(dst []byte, v EditorMessage) ([]byte, error)\n```\n\n```go\nfunc EncodeEditorReply(dst []byte, v EditorReply) ([]byte, error)\n```\n\n```go\nfunc EncodeFailure(dst []byte, message string) ([]byte, error)\n```\n\n```go\nfunc EncodeFileChanges(dst []byte, v FileChanges) ([]byte, error)\n```\n\n```go\nfunc EncodeHello(dst []byte, v Hello) ([]byte, error)\n```\nEncode functions reset and reuse dst. Decoders own their returned strings.\n\n```go\nfunc EncodeLifecycleEvent(dst []byte, v LifecycleEvent) ([]byte, error)\n```\n\n```go\nfunc EncodeLifecycleReply(dst []byte, v LifecycleReply) ([]byte, error)\n```\n\n```go\nfunc EncodeSettingValues(dst []byte, values SettingValues) ([]byte, error)\n```\nEncodeSettingValues reuses dst. Values must be validated against their schema before publication; the peer validates JSON when decoding the snapshot.\n\n```go\nfunc EncodeUI(dst []byte, v UI) ([]byte, error)\n```\n\n```go\nfunc EncodeUIEvent(dst []byte, v UIEvent) ([]byte, error)\n```\n\n```go\nfunc LaunchSetting(arg string) (string, bool)\n```\nLaunchSetting returns the string setting referenced by an entire argument of the form ${setting:id}. Its value is passed as one argument.\n\n```go\nfunc Serve(input io.Reader, output io.Writer, contributions Contributions) error\n```\nServe registers static resources, then waits for Shutdown. Logs belong on stderr. The host closes the process after registration; no per-file RPC runs.\n\n```go\nfunc ServeEditors(input io.Reader, output io.Writer, contributions Contributions, handle func(EditorMessage) (EditorReply, error)) error\n```\nServeEditors shares a stateless handler across document views until Shutdown. Stateful editors use Handlers.NewEditor with ServeExtension.\n\n```go\nfunc ServeExtension(input io.Reader, output io.Writer, contributions Contributions, handlers Handlers) error\n```\nServeExtension supports static registration, editors and live actions. Logs belong on stderr. Action updates can be published independently of clicks.\n\n```go\nfunc ValidateSettings(settings []Setting) error\n```\n\n## Types\n\n```go\ntype Action struct {\n\tID, Text, Tooltip, Icon, Color, IconColor, IconStyle string\n\t// Shortcut is a single chord, e.g. \"Primary+Shift+B\"; empty disables it.\n\tShortcut         string\n\tSelectors        []DocumentSelector\n\tLocation         ActionLocation\n\tDisabled, Hidden bool\n\tDefault          bool\n}\n```\nAction is a complete button description. Updates replace the description; empty fields clear their previous values. Icon is an SVG resource path. OpenWith actions use Selectors to match documents and Default to opt into automatic activation. Their view is served by Handlers.Editor, not Action.\n\n```go\nfunc (a Action) Equal(b Action) bool\n```\nEqual compares full descriptions, including document associations.\n\n```go\ntype ActionChange struct {\n\tAction Action\n\tRemove bool\n}\n```\n\n```go\nfunc DecodeActionChange(data []byte) (ActionChange, error)\n```\n\n```go\ntype ActionContext struct {\n\tID, ProjectPath, Path string\n\tDirectory             bool\n\tCaret, Anchor         uint32\n}\n```\nActionContext uses absolute paths; Caret and Anchor are Unicode rune offsets.\n\n```go\nfunc DecodeActionContext(data []byte) (ActionContext, error)\n```\n\n```go\ntype ActionLocation uint32\n```\nActionLocation identifies workbench button slots, including document views.\n\n```go\nconst (\n\tStatusBar ActionLocation = iota\n\tLeftContextMenu\n\tRightContextMenu\n\tTitleBarRight\n\tOpenWith\n\t// Command registers an action without a workbench button.\n\tCommand\n)\n```\n\n```go\ntype ActionPublisher struct {\n\t// contains filtered or unexported fields\n}\n```\nActionPublisher serializes unsolicited updates with request replies. It may be used from background goroutines until the activation context is canceled.\n\n```go\nfunc (p *ActionPublisher) CloseUI(id string) error\n```\n\n```go\nfunc (p *ActionPublisher) Remove(id string) error\n```\n\n```go\nfunc (p *ActionPublisher) Show(ui UI) error\n```\nShow opens or updates a surface from an action handler or background worker.\n\n```go\nfunc (p *ActionPublisher) Update(action Action) error\n```\n\n```go\ntype Capability uint32\n```\n\n```go\nconst (\n\tFileIcons Capability = 1 \u003c\u003c iota\n\tEditorThemes\n\tCustomEditors\n\tFonts\n\tLanguageServers\n\tActions\n\tExtensionUI\n\tDebugAdapters\n\tExtensionSettings\n\tLanguagePacks\n\tCapabilities = FileIcons | EditorThemes | CustomEditors | Fonts | LanguageServers | Actions | ExtensionUI | DebugAdapters | ExtensionSettings | LanguagePacks\n)\n```\n\n```go\ntype Contributions struct {\n\tLanguagePacks   []LanguagePack\n\tActions         []Action\n\tThemes          []Theme\n\tIconThemes      []IconTheme\n\tFonts           []Font\n\tLanguageServers []LanguageServer\n\tDebugAdapters   []DebugAdapter\n\tSettings        []Setting\n\t// ActionService keeps a live process even when no buttons are registered yet.\n\tActionService bool\n}\n```\n\n```go\nfunc DecodeContributions(data []byte) (Contributions, error)\n```\n\n```go\ntype DebugAdapter struct {\n\tID, Label, Command string\n\t// Templates is a debug.json array copied into project configuration on demand.\n\tTemplates string\n\tArgs      []string\n}\n```\nDebugAdapter supplies an executable and argument prefix for an adapter ID (for example Delve). The workspace server owns its process and transport. Command follows the same path rules as LanguageServer.Command.\n\n```go\ntype DocumentSelector struct {\n\tPattern string\n\t// LanguageID overrides a language server's default for this selector.\n\tLanguageID string\n\tMatch      Match\n}\n```\n\n```go\ntype EditorBinding struct{ Ref, Kind string }\n```\n\n```go\ntype EditorEvent struct {\n\tKind, Ref, Value, InputType, Data string\n\tChecked                           bool\n\tSelected, Anchor, Focus           uint32\n}\n```\n\n```go\ntype EditorMessage struct {\n\tEditor, Path, Content string\n\tEvent                 EditorEvent\n\tBinary                bool\n}\n```\nEditorMessage contains a host-owned document snapshot. Binary files supply only Path and Binary=true; this first API permits text edits only.\n\n```go\nfunc DecodeEditorMessage(data []byte) (EditorMessage, error)\n```\n\n```go\ntype EditorReply struct {\n\tView    *EditorView\n\tContent *string\n}\n```\nA nil View preserves the retained DOM, caret and scroll. A non-nil View replaces the fragment. Content=nil preserves the host document; \u0026\"\" clears it.\n\n```go\nfunc DecodeEditorReply(data []byte) (EditorReply, error)\n```\n\n```go\ntype EditorView struct {\n\tHTML, CSS string\n\tEvents    []EditorBinding\n}\n```\nExtension UI fragments can use img with data-ref and data-pencode-icon=\"name\" to reuse a built-in IDE icon with its theme color, raster scale and texture cache; omit src. Icons inside anchors or role=\"link\" use textLink.foreground. UI surface anchors with data-ref and href open workspace files in permanent editor tabs or HTTP(S)/mailto links in the system browser. Relative paths in UI surfaces resolve against ActionContext.ProjectPath. File links accept :line\\[:column] and #Lline locations. An explicit click binding takes ownership of the link. Native buttons can use role=\"link\" and data-pencode-href for the same navigation. pencode-diff:/absolute/path opens the host Source Control comparison for the file's current changes (working tree, staged, or merge), using its preview tab. EditorTab and Panel fragments can use data-pencode-layout=\"fill\" without host padding or scrolling. A fill Panel supplies its own header; reserve 40px on the header's right for the workbench close button. An element with data-ref and data-pencode-scroll=\"end\" follows new output until the user scrolls up; changing its data-pencode-scroll-key reveals the end of a different transcript. data-pencode-scroll=\"preserve\" retains another scroll area's position while its data-pencode-scroll-key stays the same. A scroll container with data-ref and data-pencode-selectable supports native text selection, copy/select-all shortcuts, and the text context menu. Copy retains paragraph breaks, explicit br elements and preformatted text. Other containers with CSS white-space:pre-wrap can opt into preserving source whitespace when copied with data-pencode-preserve-whitespace. A custom editor container with data-ref and data-pencode-searchable enables the host find bar for its rendered text, including highlight and navigation. Find in a rendered view is read-only; replacement applies to source editors. An empty div with data-ref and data-pencode-grid carries an HTML-escaped JSON sparse grid: rows/columns (counts), rowHeight/columnWidth (pixels), optional rowSizes/columnSizes (\\[oneBasedIndex,pixels] overrides), styles (CSS strings), and cells (\\[row,column,text,styleIndex] tuples sorted by row then column). Within a searchable/selectable custom editor, the host mounts only the visible two-axis window plus overscan. Find indexes every value and reveals unmounted matches; selection/copy retains data offsets when cells are unmounted. Copy emits TSV data without row/column headings. Use .pencode-grid-cell and .pencode-grid-header CSS to style cells/headings. The outer editor scrolls. An optional grid source string defers cell transfer. The host sends internal EditorEvent{Kind:\"grid\",Ref:source,Value:JSON} requests with integer request, offset (UTF-8 bytes), firstRow/endRow and firstColumn/endColumn (half-open, one-based), plus all and metadata booleans. all loads a complete sparse index only for find/copy/select-all; metadata requests styles and size overrides. Reply with a standalone div whose data-pencode-grid-chunk is escaped JSON: {source,request,offset,done,data}, where data is base64 for up to 64 KiB of a UTF-8 JSON stream containing cells and optionally styles/rowSizes/columnSizes. The host requests consecutive offsets until done, then applies atomically; stale source/request IDs are discarded. Supply a new source on reload/switch. The 2 MiB per-view and 4 MiB message limits still apply to every reply. A button with data-ref and data-pencode-copy=\"text\" copies that exact text to the local clipboard on click. An explicit click binding overrides this action. A container with data-ref and data-pencode-region updates its children independently. Changes confined to regions preserve the surrounding DOM, including native input focus and selection. Nested regions update together. A container with data-ref and data-pencode-focus=\"input-ref\" focuses the named control when its blank area is clicked, preserving child control focus. A textarea with data-ref and data-pencode-autosize grows with its native text layout. Use border-box sizing and CSS min/max-height to bound its height. data-pencode-submit-on-enter=\"form\" submits the named form binding on Enter; Shift+Enter inserts a newline, and IME confirmation keeps its native behavior. data-pencode-completion=\"true\" routes unmodified Up/Down, Enter/Tab and Escape to EditorEvent{Kind:\"completion\", Ref:inputRef, Data:action}, with action \"previous\", \"next\", \"accept\" or \"dismiss\", and the current text/selection. data-pencode-caret=\"runeOffset:revision\" restores focus and a collapsed caret when this attribute changes. Use a new revision for each programmatic edit. data-pencode-markdown-links displays inline \\[label](path) references using the theme link color and hides their syntax with a one-pixel inset. References behave as atomic tokens for selection, arrow navigation and deletion. Values, selection offsets, clipboard contents and undo retain Markdown source. A text control with data-pencode-paste-images receives images on the paste shortcut as Kind:\"paste\", InputType:\"image/png\", Data:a PNG data URL, with the current Value/Anchor/Focus. Text pastes retain native editing behavior. InputType:\"error\" reports an image paste failure in Data.\n\n```go\ntype FileChanges struct {\n\tRoot  string\n\tFiles []FileEvent\n\tReset bool\n}\n```\nFileChanges comes from the host's unified file service, never a private extension watcher. Paths are relative to Root. Reset requests reconciliation after native, history or subscriber overflow; a rename may appear as remove and create. The batch owns its paths and may be retained by the handler.\n\n```go\nfunc DecodeFileChanges(data []byte) (FileChanges, error)\n```\n\n```go\ntype FileEvent struct {\n\tPath      string\n\tOp        FileOperation\n\tDirectory bool\n}\n```\n\n```go\ntype FileOperation uint8\n```\n\n```go\nconst (\n\tFileCreated FileOperation = 1 \u003c\u003c iota\n\tFileWritten\n\tFileRemoved\n\tFileRenamed\n\tFileMetadataChanged\n)\n```\n\n```go\ntype Font struct{ ID, Label, Path, BoldPath string }\n```\nFont contributes a regular face and an optional bold face from resources/.\n\n```go\ntype Frame struct {\n\tPayload []byte\n\tID      uint32\n\tSession uint32\n\tKind    Kind\n}\n```\nFrame.Payload is borrowed until the next Read. Session identifies a window action session or a document view; zero addresses the process control session. Request IDs correlate replies; Initialize/Register/Failure use the same nonzero ID. Shutdown, ActionActivate and unsolicited ActionUpdate/UIUpdate notifications use zero.\n\n```go\ntype Handlers struct {\n\t// NewEditor creates isolated document-view state. Its context ends when the view closes.\n\t// Editor may instead be used for stateless handlers shared by all views.\n\tNewEditor func(context.Context) func(EditorMessage) (EditorReply, error)\n\t// Settings runs before activation/first document request and on each change.\n\t// The snapshot owns its data and may be retained by the extension.\n\tSettings        func(SettingValues) error\n\tLifecycle       func(LifecycleEvent) (LifecycleReply, error)\n\tFileChanges     func(FileChanges) error\n\tEditor          func(EditorMessage) (EditorReply, error)\n\tAction          func(ActionContext) error\n\tUIEvent         func(UIEvent) error\n\tActivateActions func(context.Context, *ActionPublisher)\n}\n```\nHandlers shares one SDK for editor requests and persistent workbench actions. ActivateActions runs once in the window's workbench action session. Start any background work there; return promptly and stop when ctx is canceled.\n\n```go\ntype Hello struct {\n\tHost         string\n\tCapabilities Capability\n}\n```\n\n```go\nfunc DecodeHello(data []byte) (Hello, error)\n```\n\n```go\ntype IconRule struct {\n\tPattern, Path string\n\tMatch         Match\n}\n```\nIconRule matches file and folder names case-insensitively.\n\n```go\ntype IconTheme struct {\n\tID, Label string\n\tRules     []IconRule\n}\n```\n\n```go\ntype Kind uint16\n```\n\n```go\nconst (\n\tInitialize Kind = 1 + iota\n\tRegister\n\tShutdown\n\tFailure\n\tEditorRequest\n\tEditorResponse\n\tActionActivate\n\tActionInvoke\n\tActionResponse\n\tActionUpdate\n\tUIUpdate\n\tUIRequest\n\tUIResponse\n\tSettingsRequest\n\tSettingsResponse\n\tFileChangesRequest\n\tFileChangesResponse\n\tLifecycleRequest\n\tLifecycleResponse\n)\n```\n\n```go\ntype LanguagePack struct{ ID, Label, Path string }\n```\nLanguagePack points to a JSON language pack under resources/.\n\n```go\ntype LanguageServer struct {\n\tID, Label, LanguageID, Command       string\n\tInitializationOptions, Configuration string\n\tArgs                                 []string\n\tSelectors                            []DocumentSelector\n}\n```\nLanguageServer contributes a standard stdio LSP server. Command is an executable from PATH, an absolute path, or an extension-relative path. Args can reference extension string settings using ${setting:id}. JSON options are carried verbatim; the host validates them before activation.\n\n```go\nfunc (s LanguageServer) LaunchArgs(settings []Setting, values SettingValues) ([]string, error)\n```\nLaunchArgs resolves settings against the registered schema.\n\n```go\ntype LifecycleEvent struct {\n\tProjectPath string\n\tKind        LifecycleKind\n}\n```\nLifecycleEvent reaches the action process even when all its views are closed. ProjectPath is absolute for project events and empty for WindowClosing.\n\n```go\nfunc DecodeLifecycleEvent(data []byte) (LifecycleEvent, error)\n```\n\n```go\ntype LifecycleKind uint32\n```\nLifecycleKind identifies a host close request or a completed project closure.\n\n```go\nconst (\n\tWindowClosing LifecycleKind = iota\n\tProjectClosing\n\tProjectClosed\n)\n```\n\n```go\ntype LifecycleReply struct{ Message string }\n```\nLifecycleReply asks the host to confirm closure before proceeding. Empty Message allows closure. ProjectClosed replies cannot prevent closure.\n\n```go\nfunc DecodeLifecycleReply(data []byte) (LifecycleReply, error)\n```\n\n```go\ntype Match uint32\n```\nMatch selects basenames or suffixes. Suffix includes its leading dot; the longest suffix wins, after an exact basename match. Directory names use FolderName.\n\n```go\nconst (\n\tDefaultFile Match = iota\n\tFileName\n\tFileSuffix\n\tDefaultFolder\n\tFolderName\n)\n```\n\n```go\ntype NotificationSeverity uint32\n```\nNotificationSeverity selects the notification's theme colors and status icon.\n\n```go\nconst (\n\tNotificationInfo NotificationSeverity = iota\n\tNotificationWarning\n\tNotificationError\n)\n```\n\n```go\ntype Reader struct {\n\tSource io.Reader\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (r *Reader) Read() (Frame, error)\n```\n\n```go\ntype Setting struct {\n\tID, Label, Description string\n\tDefault                json.RawMessage\n\tOptions                []SettingOption\n\tType                   SettingType\n}\n```\nSetting IDs are local to an extension. Defaults are JSON scalar values; Options, when present, constrain a string setting to the listed values.\n\n```go\nfunc (s Setting) Validate(value json.RawMessage) error\n```\n\n```go\ntype SettingOption struct{ Value, Label string }\n```\n\n```go\ntype SettingType uint32\n```\n\n```go\nconst (\n\tSettingString SettingType = iota\n\tSettingBoolean\n\tSettingNumber\n\tSettingInteger\n)\n```\n\n```go\ntype SettingValues map[string]json.RawMessage\n```\n\n```go\nfunc DecodeSettingValues(data []byte) (SettingValues, error)\n```\n\n```go\nfunc ResolveSettings(settings []Setting, saved SettingValues) SettingValues\n```\nResolveSettings creates an immutable snapshot with defaults for missing or invalid saved values. Unknown keys remain in storage, outside this snapshot.\n\n```go\ntype Shortcut struct {\n\tKey                                 string\n\tPrimary, Control, Super, Shift, Alt bool\n}\n```\nShortcut is the parsed, platform-independent form of an Action.Shortcut. Primary means Command on macOS and Control elsewhere.\n\n```go\nfunc ParseShortcut(chord string) (Shortcut, error)\n```\nParseShortcut accepts a single chord with case-sensitive key names. Successful parsing does not allocate.\n\n```go\ntype Theme struct{ ID, Label, Path string }\n```\n\n```go\ntype UI struct {\n\tPatch             *ViewPatch\n\tView              *EditorView\n\tID, Title, Anchor string\n\tContext           ActionContext\n\tPlacement         UIPlacement\n\t// ViewVersion identifies a complete view or the result of Patch. Patches\n\t// replace only existing region contents; structure, CSS or event changes\n\t// require a full View. ActionPublisher manages these fields automatically.\n\tViewVersion uint32\n\tKind        UIKind\n\t// AutoCloseMS dismisses a Notification after this many milliseconds. Zero\n\t// keeps it open until closed by the user or extension. Updates reset the timer.\n\tAutoCloseMS uint32\n\t// Severity applies only to Notification. Zero uses the information style.\n\tSeverity NotificationSeverity\n\tClose    bool\n\t// CloseOnOutsideClick dismisses a Popup on an outside pointer press.\n\t// False keeps it open. ContextMenu always dismisses on outside presses.\n\tCloseOnOutsideClick bool\n\t// Busy replaces an EditorTab's close icon with a processing animation.\n\tBusy bool\n\t// Unread marks an EditorTab with completed work that has not been viewed.\n\tUnread bool\n\t// InterceptClose keeps an EditorTab open on user close and emits\n\t// \"closerequest\" instead. Call CloseUI after any confirmation succeeds.\n\tInterceptClose bool\n}\n```\nUI replaces a surface's description. A nil View retains its controls, focus and scroll. Anchor is a local action ID, or \"ui:\\\u003csurface ID\u003e#\\\u003cdata-ref\u003e\" for a focusable control in another surface owned by this extension. Close removes the surface. Empty Context.ID inherits the current Action/UIEvent context; background workers should pass their saved Context explicitly. Title names the surface. EditorTab opens selected. Updates with a View retain selection; a nil View explicitly reveals an existing tab. Closing a tab emits the usual close event.\n\n```go\nfunc DecodeUI(data []byte) (UI, error)\n```\n\n```go\ntype UIEvent struct {\n\tID, Reason string\n\tContext    ActionContext\n\tEvent      EditorEvent\n}\n```\nUIEvent carries DOM events and \"open\", \"closerequest\", \"close\", \"visibilitychange\", \"projectchange\". visibilitychange uses Event.Value=\"visible\" or \"hidden\". projectchange notifies EditorTab surfaces when the active project changes. Its Context contains the new ProjectPath and clears file-specific fields. Close reasons are \"extension\", \"button\", \"escape\", \"outside\", \"replace\", \"timeout\". Context is the action invocation that opened this surface, updated by projectchange.\n\n```go\nfunc DecodeUIEvent(data []byte) (UIEvent, error)\n```\n\n```go\ntype UIKind uint32\n```\nUIKind selects a host-owned surface. Menus are anchored to an action; dialogs are modal; panels live in the resizable workbench bottom area.\n\n```go\nconst (\n\tDialog UIKind = iota\n\tContextMenu\n\tPanel\n\tPopup        // Nonmodal floating window; workspace interaction remains available.\n\tNotification // Bottom-right message stack; never takes focus when opened.\n\tEditorTab    // Document-independent tab in the editor area.\n)\n```\n\n```go\ntype UIPlacement struct {\n\tMode                UIPosition\n\tX, Y, Width, Height float32\n}\n```\nUIPlacement controls an overlay's position and size. X/Y offset the selected origin. Zero Width/Height use the surface's default size. The host constrains overlays to the viewport. Panels use their workbench layout instead.\n\n```go\ntype UIPosition uint32\n```\nUIPosition selects the origin for Placement.X/Y, in workspace CSS pixels.\n\n```go\nconst (\n\tPositionDefault     UIPosition = iota // Center dialogs/popups; anchor context menus.\n\tPositionAbsolute                      // Workspace top-left.\n\tPositionAnchor                        // Action's bottom-left, falling back to its captured location.\n\tPositionAnchorAbove                   // Above the anchor's top-left; falls below when space is insufficient.\n)\n```\n\n```go\ntype ViewPatch struct {\n\tRegions []ViewRegion\n\tBase    uint32\n}\n```\nViewPatch is relative to exactly one previously received view version. Nested regions belong to their outer region and cannot be patched separately.\n\n```go\ntype ViewReceiver struct {\n\t// contains filtered or unexported fields\n}\n```\nViewReceiver reconstructs raw views on the session I/O worker, before asset preparation and UI validation. It owns at most 32 surface bases. A new session starts empty and its publisher sends a full view first. Apply is transactional. Do not share a receiver across processes or access it concurrently.\n\n```go\nfunc (r *ViewReceiver) Apply(ui UI) (UI, error)\n```\n\n```go\ntype ViewRegion struct {\n\tRef, HTML string\n\t// contains filtered or unexported fields\n}\n```\nViewRegion replaces the children of an existing data-pencode-region element.\n\n```go\nfunc SplitViewRegions(source string) (string, []ViewRegion, error)\n```\nSplitViewRegions separates outer region contents from their surrounding template. Nested regions remain part of their outer region's HTML.\n\n```go\ntype ViewRegionSplitter struct {\n\t// contains filtered or unexported fields\n}\n```\nViewRegionSplitter reuses region boundaries when an update changes only one region. The returned region slice is borrowed until the next successful Split. Strings remain immutable. A splitter must not be used concurrently.\n\n```go\nfunc (s *ViewRegionSplitter) Split(source string) (string, []ViewRegion, error)\n```\n\n```go\ntype Writer struct {\n\tTarget io.Writer\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (w *Writer) Write(kind Kind, id uint32, payload []byte) error\n```\nWrite handles short writes on the process control session.\n\n```go\nfunc (w *Writer) WriteSession(session uint32, kind Kind, id uint32, payload []byte) error\n```\nWriteSession serializes complete frames from independent session publishers.\n\n","path":"github.com/pencode-labs/pencode/peb","name":"peb","synopsis":"Package peb implements Pencode Extension Binary protocol version 20.","isRedistributable":true}
