@light-web/windowing-core
v0.0.1
Published
Pure headless window state for the web. No DOM, zero dependencies.
Maintainers
Readme
@light-web/windowing-core
Pure headless window state for the web. No DOM, no events library, zero dependencies.
Pairs with @light-web/windowing-ui for drop-in windows, or drive your own Tailwind/custom chrome from the same state.
Install
npm i @light-web/windowing-coreUse
import { createDesktop } from "@light-web/windowing-core";
const desktop = createDesktop({ container: { w: 1024, h: 768 } });
const id = desktop.create({ title: "Notes", x: 24, y: 24, w: 320, h: 200 });
desktop.subscribe((snap, changed) => {
console.log(changed); // [{ id, kind: "move" }]
render(snap.windows, snap.activeId);
});
desktop.move(id, 100, 100);
desktop.resize(id, 400, 300);
desktop.focus(id);
desktop.minimize(id); // hidden-only, still in listWindows() — build your own taskbar
desktop.restore(id);
desktop.maximize(id);
desktop.close(id);API
createDesktop({ container?, minSize?, bounds? })—bounds: "parent"(default, clamps inside container) or"none".create({ title?, x?, y?, w?, h? })→id(win-1,win-2, …; never reused).move(id, x, y),resize(id, w, h),focus(id)(brings to front),minimize(id),maximize(id),restore(id),close(id).getWindow(id),listWindows()(z-sorted, includes minimized),getSnapshot(),setContainerSize(w, h).subscribe(listener)→unsubscribe. Listener gets(snapshot, changed[]).- Defaults:
minSize { 180, 120 }, container{ 1024, 768 }untilsetContainerSizeis called.
License
MIT
