The @dotgui/kit/package module reads and edits a .gui container in memory — unpack, pack, list/add/remove assets, set preview — pure, byte-based, nothing touches disk.

/package

i/othe .gui container, in memory

A .gui is a ZIP of the markup (design.guix), an assets/ folder, and a rendered preview.webp. This module reads and edits that container entirely in memory — nothing touches disk.

Read the markup, list/add/remove assets, or swap the preview without extracting a shadow folder. Edits are pure and chainable — each returns an updated package. setMarkup is guarded: it validates first, so invalid markup never enters the model.

Signature

unpack(bytes: Uint8Array): GuiPackage     // .gui or raw .guix → model
pack(pkg: GuiPackage): Uint8Array         // model → .gui bytes

getMarkup · getAsset · listAssets · getPreview · info
setMarkup · addAsset · removeAsset · setPreview   // pure, return a new package

Use cases

  • Read, edit, and repack .gui files in any tool.
  • In-memory asset management — add, remove, rename, swap preview.
  • Guarded saves — never persist a broken edit.

Read a .gui without touching disk

import { unpack, getMarkup, listAssets } from '@dotgui/kit/package'

const pkg = unpack(bytes)
console.log(getMarkup(pkg))
console.log(listAssets(pkg))   // ["assets/hero.webp", ...]

Edit and repack (pure, chainable)

import { unpack, addAsset, removeAsset, setPreview, pack } from '@dotgui/kit/package'

let pkg = unpack(bytes)
pkg = addAsset(pkg, 'logo.png', logoBytes)
pkg = removeAsset(pkg, 'old.png')
pkg = setPreview(pkg, previewBytes)
const out = pack(pkg)          // new .gui bytes

setMarkup is guarded — invalid edits throw

import { setMarkup, InvalidMarkupError } from '@dotgui/kit/package'

try {
  pkg = setMarkup(pkg, editedXml)   // saved only if valid
} catch (e) {
  if (e instanceof InvalidMarkupError) showErrors(e.errors)
}