Help us shape the future of Go! Take the 2026 Go Developer Survey

packages

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package packages resolves local Karty package archives and development folders.

Index

Constants

View Source
const (
	ManifestName     = "karty-package.toml"
	InventoryName    = "karty-package.files.json"
	MaxFiles         = 8192
	MaxFileBytes     = 64 << 20
	MaxTotalBytes    = 512 << 20
	MaxArchiveBytes  = 256 << 20
	MaxManifestBytes = 1 << 20
	MaxPackages      = 16
	MaxTextures      = 256
	MaxPathDepth     = 32
)
View Source
const MaxUIComponents = 128

Variables

View Source
var ErrPackage = errors.New("invalid Karty package")

Functions

func CheckModules

func CheckModules(ctx context.Context, project string, set *Set) error

func Digest

func Digest(data []byte) string

func FolderRoots

func FolderRoots(ctx context.Context, project string) (map[string]string, error)

FolderRoots describes explicit development capabilities. The watcher opens a separate confined root for each; project path confinement is never relaxed.

func LoadSources

func LoadSources(ctx context.Context, directory string) (map[string]Source, string, error)

func MakeDirectories

func MakeDirectories(root *os.Root, name string) error

MakeDirectories rejects every existing symlink component, including links confined within the root. Generated outputs must not redirect into user files.

func Read

func Read(ctx context.Context, root *os.Root, name string, limit int64) ([]byte, error)

func ResolveUI

func ResolveUI(ctx context.Context, directory string, assets project.Assets, set *Set) (project.Assets, error)

ResolveUI adds package exports to the in-memory project, staging all inputs inside its root. Authored sources and the project's theme file stay untouched.

func ValidPath

func ValidPath(name string) bool

ValidPath reports whether a slash-separated name meets the portable path constraints used by package reads and generated writes.

func WriteGenerated

func WriteGenerated(ctx context.Context, root *os.Root, name string, data []byte, immutable bool) error

WriteGenerated never follows an existing file link. Immutable files are checked byte-for-byte when reused; mutable metadata is published with rooted rename.

Types

type Manifest

type Manifest struct {
	FormatVersion int         `toml:"format_version"`
	Name          string      `toml:"name"`
	Version       string      `toml:"version"`
	SDK           string      `toml:"sdk,omitempty"`
	Prefabs       string      `toml:"prefabs,omitempty"`
	Textures      []Texture   `toml:"textures,omitempty"`
	UI            UIExports   `toml:"ui,omitempty"`
	Processors    []Processor `toml:"processors,omitempty"`
	// GoModule is read from go.mod, never a second editable declaration.
	GoModule string `toml:"-"`
}

func Export

func Export(ctx context.Context, directory, output string) (Manifest, string, error)

Export packages source bytes, never generated game outputs. ZIP order, timestamps, inventory and permissions are deterministic; links are rejected.

func Import

func Import(ctx context.Context, project, input string, replace bool) (Manifest, error)

Import records a portable local archive reference or an explicit development folder. External archives are copied into the project, never merely cached. --replace is explicit permission to update one existing package declaration.

func ReadManifest

func ReadManifest(ctx context.Context, root *os.Root) (Manifest, error)

type Processor

type Processor struct {
	Name    string   `toml:"name"`
	Command []string `toml:"command"`
}

Processor declares a build tool. Import, export, restore and schema never run it. A consuming project must explicitly select it in build.processors.

type Resolved

type Resolved struct {
	Manifest  Manifest
	Root      *os.Root
	Directory string
}

type Set

type Set struct{ Items map[string]*Resolved }

func Restore

func Restore(ctx context.Context, project string) (_ *Set, err error)

Restore regenerates only ignored cache/link state, never project manifests or go.mod. Every archive is verified against the committed source and checksum.

func (*Set) Close

func (set *Set) Close()

func (*Set) Names

func (set *Set) Names() []string

type Source

type Source struct {
	Archive string `koanf:"archive" toml:"archive,omitempty"`
	Folder  string `koanf:"folder"  toml:"folder,omitempty"`
	SHA256  string `koanf:"sha256"  toml:"sha256,omitempty"`
}

type Texture

type Texture struct {
	Name    string `toml:"name"`
	Source  string `toml:"source"`
	Profile string `toml:"profile"`
}

type UIComponent

type UIComponent struct {
	Name   string `toml:"name"`
	Source string `toml:"source"`
}

type UIExports

type UIExports struct {
	Components []UIComponent `toml:"components,omitempty"`
	Layouts    []string      `toml:"layouts,omitempty"`
	Images     []Texture     `toml:"images,omitempty"`
	Fonts      []UIFont      `toml:"fonts,omitempty"`
	Theme      string        `toml:"theme,omitempty"`
}

UIExports are authored sources, compiled against the consuming game's SDK. Component and layout names retain KartUI's ordinary filename convention.

type UIFont

type UIFont struct {
	Role   string `toml:"role"`
	Source string `toml:"source"`
}

type WorldTexture

type WorldTexture struct {
	Name, Profile string
	Data          []byte
}

func ResolveWorld

func ResolveWorld(ctx context.Context, set *Set, contents []byte, localTextures []string) ([]byte, []WorldTexture, error)

ResolveWorld merges selected static prefab exports into an ordinary authored world. Scalar types/null presence survive until the existing schema checks.

Jump to

Keyboard shortcuts

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