Workspace
Legacy address for preview.2 documentation. Use the versioned page. The API is the same.
Optional app library · SDK 0.1.0-preview.2.
Track which known document IDs belong in two panes and calculate their widths. This is a layout model, not a docking-window framework.
From the extracted SDK folder, create a sibling app with ./lui.cmd new ../MyWorkbench --template workbench. Keep its Vendor files, lui.json, module lock and SDK pin together. See library setup.
Import require("@LuiWorkbench/Workspace") after the project declares that library. An import copied into a basic starter is not enough.
Example
Section titled “Example”Replace Src/Main.luau in that prepared project with this complete file.
local Window = Instance.new("Window", {Title = "Library example", Size = UDim2.fromOffset(640, 300)})local Status = Instance.new("TextLabel", {Parent = Window, Text = "Ready", Position = UDim2.fromOffset(16, 190), Size = UDim2.fromOffset(600, 72)})local Workspace = require("@LuiWorkbench/Workspace")local Layout = Workspace.New()Layout:Add("Notes", "Left")Layout:Add("Preview", "Right")local Left, Right, IsSplit = Layout:Layout(600)Status.Text = "Two panes: " .. tostring(IsSplit) .. "; widths: " .. Left .. ", " .. RightWindow.Destroying:Connect(function() Layout:Dispose() end)Window.Visible = trueExpected result: Displays the widths calculated by the model. Workspace stores tab/layout state; it does not create windows, editors or visual panes.
Functions
Section titled “Functions”Workspace.New(): ModelBehavior and limits
Section titled “Behavior and limits”Workspace owns presentation IDs only. Add registers up to 32 unique UTF-8 IDs (128 bytes each) in Left or Right; default Left. Remove unregisters an ID and repairs active selection. Dock moves a known ID to a side and optional final 1-based position, default end. Activate selects the visible tab in its side. Snapshot returns a deeply frozen Version 1 layout. Restore validates the entire snapshot before mutation: exact known identity set, unique dense arrays, valid active tabs, finite Ratio in 0.1–0.9, no unknown fields or metatables. It returns false, InvalidLayout on incompatible data, preserving current presentation. It never opens documents from stored IDs.
SetRatio stores presentation intent. Layout(Width) returns logical widths and
whether to display two panes; at least 240 units per pane plus an 8-unit divider
are required. With two populated groups below 488 units, it returns a single
left-sized viewport. The view must show its selected tab there, including a tab
from the Right group. A single populated group receives the full width.
Encode/Decode use the bounded LUIW1 length-prefixed UTF-8 format, maximum 8192
bytes, with no native paths, document contents or executable objects. Truncated,
extra, unknown-version and incompatible identity data are refused atomically.
Split.New() provides Begin(Input, WindowX, Width, Ratio),
Move(Input, WindowX, Width), Finish(Input), Cancel() and Dispose(). Begin accepts
one primary mouse contact at a time. Use window-relative logical X for both
Begin and Move. Movement returns a clamped ratio; matching primary release
commits it. Native cancellation, invalid coordinates or a resized viewport
returns the original ratio and retires the gesture. Other contacts/buttons
cannot finish it. Call Cancel on other presentation changes and apply its
returned original ratio. Dispose retires without invoking callbacks. The view
owns the existing input signal connections; no native capture API is introduced.
Exported type declarations — advanced reference
These types describe returned models/controllers and their options. They are not additional classes to create.
Snapshot
Section titled “Snapshot”export type Snapshot = { read Version: number, read Left: {string}, read Right: {string}, read ActiveLeft: string?, read ActiveRight: string?, read Ratio: number,}export type Model = { Add: (Self: Model, Id: string, Side: string?) -> (), Remove: (Self: Model, Id: string) -> boolean, Dock: (Self: Model, Id: string, Side: string, Index: number?) -> (), Activate: (Self: Model, Id: string) -> (), Snapshot: (Self: Model) -> Snapshot, Restore: (Self: Model, Input: any) -> (boolean, string?), Encode: (Self: Model) -> string, Decode: (Self: Model, Bytes: string) -> (boolean, string?), SetRatio: (Self: Model, Ratio: number) -> (), Layout: (Self: Model, Width: number) -> (number, number, boolean), Dispose: (Self: Model) -> (),}Deeper implementation reading
Section titled “Deeper implementation reading”The library source is useful when extending the framework or understanding cleanup. Private support modules such as Scope/State are implementation details, not additional supported app APIs.