studioShare

tcmts.studio.studioShare · #7tubcayw · term · runs on the server

uses tcmts.studio.StudioFrame, which uses process

Set up the forge's pages to show in the studio's frame (its column of tabs), a definition's with how it runs below its code and what to do with it (Edit, for code and files kept as written that are text; Rename and Delete; on the codebase's own branch, as another is only read), each reading the branch the browser reads (studioCodebase); and the machine's slots watched from then on (slotSamples): what every studio page does first.

import { isBytes } from "#codebase/tcmts/cli/files";
import { definitionActions, definitionExtra, pageFrame, servedCodebase, servedFor } from "#codebase/tcmts/share";
import { DefinitionActions, HowItRuns, studioCodebase, StudioFrame, watchSlots } from "#codebase/tcmts/studio";

export function studioShare(): void {
  pageFrame.current = StudioFrame;
  definitionExtra.current = HowItRuns;
  definitionActions.current = ({ name, hash }) => {
    const cb = servedCodebase().cb;
    const rec = cb.store.getDef(hash);
    if (!rec || studioCodebase().cb !== cb) return undefined;
    const usedBy = [
      ...new Set(cb.store.namedDependents(hash).flatMap((d) => cb.store.pathsOf(d).slice(0, 1))),
    ].sort();
    return (
      <DefinitionActions
        name={name}
        usedBy={usedBy}
        editable={!(rec.kind === "file" && isBytes(rec))}
      />
    );
  };
  servedFor.current = studioCodebase;
  watchSlots();
}

uses

used by