Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdd348ac6c3

README.md

edui.inspector.parts

The building blocks a type's inspector.luau composes its sections from. Every Context carries this module as ctx.parts, so an inspector file requires nothing from @builtin::editor:

return { sections = { {
    id = "summary", title = "Summary",
    build = function(ctx)
        local rows = ctx.parts.facts(ctx, {
            { label = "Vertices", value = 24 },
            { label = "Size", value = ctx.parts.bytes(1536) },
        })
        local n = #rows
        for _, node in ipairs(ctx.parts.action(ctx, "rebuild", "Rebuild", function() ctx.ref:rebuild() end)) do
            n += 1
            rows[n] = node
        end
        return rows
    end,
} } }

Every function takes the section's Context first and returns a list of edui nodes, unless stated.

PartWhat it showsCallback key
format(v)a value as text: integers plain, other numbers to 4 significant digits, booleans yes/no, a list as its length, a map as its entry count (returns a string)—
bytes(n)a byte count as text: 84 B, 1.5 KiB, 2.00 MiB (returns a string)—
facts(ctx, rows, empty?)label/value rows ({ label, value, mono? }); the value takes the width its label leaves and wraps within it; a row whose value is nil shows "—", so a value that could not be read is seen to be missing. A row that does not apply to the subject is left out of rows by the section; with no rows empty shows—
list(ctx, items, { max?, empty?, mono? })one text row per item, at most max (40), then "… and N more"—
table(ctx, key, columns, rows, empty?)a table of records, each cell through format<keyPrefix>:tbl:<key> (widget id)
links(ctx, refs, { max?, empty? })one button per asset (an AssetRef, a { __ref = guid } envelope, or a guid or name), named and typed; clicking selects it. An item that does not resolve is listed as text<keyPrefix>:link:<guid>
entityLinks(ctx, ids, { max?, empty? })one button per entity, by name; clicking selects it. An id whose entity no longer exists is listed as text, marked despawned<keyPrefix>:ent:<id>
action(ctx, id, label, run, { primary? })a button running run; a run that raises shows its message beneath the button until the next run<keyPrefix>:act:<id>
openFile(ctx, path, label?)an action opening path in the Code panel; nothing when the file is absent<keyPrefix>:act:open:<path>, the path relative to the subject's folder
problems(ctx, problems, clean?)one notice per { message, code?, severity?, line? } (error tone, or info for a warning, info or hint), or clean ("No problems.")—
swatch(ctx, color, label)a colour square ({ r, g, b } in 0..1) beside its label and hex (returns one node)—
cached(key, paths, compute)compute()'s value, computed again only when the content version of one of paths moves (returns the value). Read through ctx.parts, it is held while a Context that read it stays open; read through the module itself, until the next Inspector.release—
state(ctx)the table a Context's sections keep state in between builds (a picked zoom, a chosen tab), forgotten when the Context is released (returns the table)—
check(ctx, path)a "Check" action running lsp.check(path), then the counts and diagnostics of the last check of the file's current content<keyPrefix>:act:check:<path>, the path relative to the subject's folder
values(ctx, { subject, schema?, values?, write?, readOnly? })typed controls over any values: one control per schema field, each edit checked with Field.check and written through write inside one undoable operation; readOnly shows the values with no control that writes. The same subject shown by two Contexts keeps two states<keyPrefix>:val:<subject>:set:<field>

Rules a section keeps

  • No write in build. A build only reads; writes happen in an action's run, in ctx.setSettings, or in a values part's write.
  • Expensive reads are once per content version. A build that decodes a payload, walks a file or asks the LSP goes through cached (keyed on the files the value comes from) or runs behind an action. check holds each file's last result for as long as the file's content is unchanged.
  • Every callback key starts with ctx.keyPrefix, so two subjects — the panel's asset and an inline editor of the same asset — never share one.
  • What the parts hold goes with the Context. ctx.parts is the parts as that Context reads them. Inspector.release(keyPrefix) forgets the Context's action failures, file checks and state, and every cached value no other open Context read.