Documentation
¶
Overview ¶
Package native shells out to a format's own CLI to produce a golden reference render (SVG) to validate the WebGL/SVG paths against. Running an external process is gated three ways. A tool must be registered for the file's extension, the operator must allowlist it (--enable-native <tool>), and its binary must be on PATH. Tools run under exec (no shell), on an already mount-safe absolute path, into a temp output dir, under a timeout. See docsite/content/build/native-verification.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoTool = errors.New("no native renderer for this format") ErrNotEnabled = errors.New("native renderer not enabled") ErrNotFound = errors.New("native renderer binary not found on PATH") )
Sentinel errors, mapped to Connect codes by the caller.
Functions ¶
func Available ¶
Available reports whether NATIVE can be served for absPath, meaning a renderer is registered (by extension, or by sniffing a .sch), its tool is enabled, and its binary is installed.
func OpenArgs ¶
OpenArgs returns the command (binary + args) that opens absPath in its native GUI tool on the current platform, or ErrNoTool when no native GUI is known for the format or platform. It launches nothing, so the caller execs the result and the command stays unit testable. On macOS KiCad opens via `open -a`. Otherwise, and for the X11 schematic editors, the binary runs directly, so a missing binary surfaces at exec time.
func RenderFile ¶
RenderFile renders one page (1-based) of absPath to SVG using its registered native tool, for direct CLI use, uncached. Unlike Cache.Render it does NOT consult the operator allowlist, which guards a shared server against shelling out on a request, whereas invoking the CLI is itself the operator's consent. It returns ErrNoTool or ErrNotFound for the other two gates.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache memoizes rendered SVGs by (path, mtime, page) so navigating sheets does not re-shell for an unchanged file.
func (*Cache) Render ¶
func (c *Cache) Render(ctx context.Context, absPath string, page int, enabled map[string]bool) (string, error)
Render renders one page of absPath to SVG using its registered, enabled tool. page is 1-based. It returns ErrNoTool / ErrNotEnabled / ErrNotFound for the gate failures so the caller can map them to Connect codes.