MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / stepFor

Function stepFor

src/ui-server/api/steps.ts:753–808  ·  view source on GitHub ↗
(node: Node, kind: WireStepKind, depth: number, extra: Partial<WireStep> = {})

Source from the content-addressed store, hash-verified

751 };
752
753 const stepFor = (node: Node, kind: WireStepKind, depth: number, extra: Partial<WireStep> = {}): StepRecord | null => {
754 const existing = steps.get(node.id);
755 if (existing) {
756 // A listener the screen registers is a handler when first met, and the
757 // native event's landing when the walk arrives from the other side —
758 // the second is the fuller fact, and it names the event.
759 if (existing.kind === 'trigger' && kind === 'event') {
760 existing.kind = 'event';
761 if (extra.event) existing.event = extra.event;
762 }
763 if (kind === 'event' && extra.event) {
764 existing.events = existing.events ?? (existing.event ? [existing.event] : []);
765 if (!existing.events.includes(extra.event)) existing.events.push(extra.event);
766 }
767 return existing;
768 }
769 if (steps.size >= limit) {
770 truncated.steps++;
771 return null;
772 }
773 const isRoute = node.kind === 'route';
774 const routeRoot = isRoute ? (roots.get(node.id) ?? null) : null;
775 const record: StepRecord = {
776 id: node.id,
777 // A route is a screen or an endpoint — except one reached across a
778 // tier (`fetch('/api/users')` onto its own route), which is the crossing.
779 kind: isRoute && kind !== 'bridge' ? 'screen' : kind,
780 anchor: false,
781 node: toNodeRef(node),
782 label: node.name,
783 // A screen says its component, an endpoint its handler; a route the
784 // graph bound to nothing says only where it is registered.
785 sub: isRoute
786 ? routeRoot === null
787 ? basename(node.filePath)
788 : routeRoot.inline
789 ? `inline handler · ${basename(node.filePath)}`
790 : routeRoot.node.name
791 : posix(node.filePath),
792 depth,
793 cut: null,
794 ...extra,
795 root: isRoute ? (routeRoot?.node ?? null) : node,
796 };
797 if (kind === 'event' && extra.event) record.events = [extra.event];
798 if (isRoute) {
799 record.screen = {
800 path: node.name,
801 component: routeRoot !== null && !routeRoot.inline ? toNodeRef(routeRoot.node) : null,
802 endpoint: splitRouteName(node.name).method !== null,
803 inline: routeRoot?.inline ?? false,
804 };
805 }
806 steps.set(node.id, record);
807 return record;
808 };
809
810 // One box per (function, category): `uploadARCapture` makes one network

Callers 1

buildStepsFunction · 0.85

Calls 7

toNodeRefFunction · 0.90
splitRouteNameFunction · 0.90
posixFunction · 0.85
pushMethod · 0.80
basenameFunction · 0.70
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected