feat(editor): F4.6a simulation mode and a computer's desktop
Java's mode buttons start and stop the room, now in a worker of the editor's page (LocalSimHost), with Java's speed slider. While the simulation runs the design is locked as in Java: no palette, no sheet, nothing moves, no undo. Cables that carry a frame light up in Java's green, and a tap on a computer opens its desktop: Java's title, the software installation first, then the installed programs in the order of Java's list for the language, a taskbar with the network icon and the network as the simulation runs it. The room sends that over a new topic, node:<id>. Desktops stay over a return to the design and show again at the next start. The programs' windows follow from F4.6b. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
// so that it can run on every change while someone drags a device.
|
||||
|
||||
import * as Y from 'yjs';
|
||||
import { compareIds, stableGeneratedMacAddress, type DocumentationItemKind, type HostLabelPolicy, type NodeKind } from '@mdg-filius/core';
|
||||
import { compareIds, stableGeneratedMacAddress, type DocumentationItemKind, type HostLabelPolicy, type InstallableProgram, type NodeKind } from '@mdg-filius/core';
|
||||
import { inOrder, ROOTS } from './projectDoc.js';
|
||||
|
||||
export interface NodeView {
|
||||
@@ -115,3 +115,28 @@ export function topologyView(doc: Y.Doc): TopologyView {
|
||||
docs.sort((left, right) => layer(left) - layer(right) || left.order - right.order || compareIds(left.id, right.id));
|
||||
return { nodes, links, docs };
|
||||
}
|
||||
|
||||
/** What a computer's desktop needs of the document (Java's GUIDesktopWindow, GUIDesktopPanel). */
|
||||
export interface DesktopView {
|
||||
readonly kind: 'pc' | 'notebook';
|
||||
/** Its label (Host.holeAnzeigeName). */
|
||||
readonly label: string;
|
||||
/** Whether the label is its address: Java's title then leaves the address out (isUseIPAsName). */
|
||||
readonly addressAsName: boolean;
|
||||
readonly programs: readonly InstallableProgram[];
|
||||
}
|
||||
|
||||
/** A PC's or notebook's desktop; undefined for any other device. */
|
||||
export function desktopView(doc: Y.Doc, id: string): DesktopView | undefined {
|
||||
const node = doc.getMap<Y.Map<unknown>>(ROOTS.nodes).get(id);
|
||||
const kind = node?.get('kind') as NodeKind | undefined;
|
||||
if (node === undefined || (kind !== 'pc' && kind !== 'notebook')) return undefined;
|
||||
const policy = node.get('labelPolicy') as HostLabelPolicy;
|
||||
return {
|
||||
kind,
|
||||
label: nodeLabel(node),
|
||||
addressAsName: policy === 'ipAddress' || policy === 'ipAndMAC',
|
||||
programs: [...(node.get('programs') as Y.Map<unknown>).keys()] as InstallableProgram[],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user