Skip to content

Commit 219d8c7

Browse files
committed
refactor(core): move signal debug graph interfaces to primitives/devtools
Move the DebugSignalGraph, DebugSignalGraphEdge, and DebugSignalGraphNode interfaces from packages/core/src/render3/util/signal_debug.ts into the packages/core/primitives/devtools/src package. This decouples the signal graph debug types from runtime render3 utilities and allows devtools and internal core tooling to import them directly from primitives as type-only exports.
1 parent 2f8134b commit 219d8c7

8 files changed

Lines changed: 61 additions & 49 deletions

File tree

packages/core/primitives/devtools/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ ts_project(
1212
"**/*.ts",
1313
],
1414
),
15+
deps = [
16+
"//packages/core/primitives/signals",
17+
],
1518
)
1619

1720
filegroup(

packages/core/primitives/devtools/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@
99
export {ProfilerEvent, type Profiler} from './src/profiler_types';
1010
export {Framework} from './src/framework';
1111
export type {DevtoolsToolDiscoveryEvent, ToolDefinition, ToolGroup} from './src/tool_definitions';
12+
export type {
13+
DebugSignalGraph,
14+
DebugSignalGraphEdge,
15+
DebugSignalGraphNode,
16+
} from './src/signal_debug_types';
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
8+
9+
import {ReactiveNodeKind} from '../../signals';
10+
11+
export interface DebugSignalGraphNode {
12+
kind: ReactiveNodeKind;
13+
id: string;
14+
epoch: number;
15+
label?: string;
16+
value?: unknown;
17+
debuggableFn?: () => unknown;
18+
}
19+
20+
export interface DebugSignalGraphEdge {
21+
/**
22+
* Index of a signal node in the `nodes` array that is a consumer of the signal produced by the producer node.
23+
*/
24+
consumer: number;
25+
26+
/**
27+
* Index of a signal node in the `nodes` array that is a producer of the signal consumed by the consumer node.
28+
*/
29+
producer: number;
30+
}
31+
32+
/**
33+
* A debug representation of the signal graph.
34+
*/
35+
export interface DebugSignalGraph {
36+
nodes: DebugSignalGraphNode[];
37+
edges: DebugSignalGraphEdge[];
38+
}

packages/core/src/core_render3_private_export.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
//
1212
// no code actually imports these symbols from the @angular/core entry point
1313
export {
14+
type DebugSignalGraph as ɵDebugSignalGraph,
15+
type DebugSignalGraphEdge as ɵDebugSignalGraphEdge,
16+
type DebugSignalGraphNode as ɵDebugSignalGraphNode,
1417
Framework as ɵFramework,
1518
Profiler as ɵProfiler,
1619
ProfilerEvent as ɵProfilerEvent,
@@ -295,11 +298,6 @@ export {
295298
ExternalCoreGlobalUtils as ɵExternalCoreGlobalUtils,
296299
FrameworkAgnosticGlobalUtils as ɵFrameworkAgnosticGlobalUtils,
297300
} from './render3/util/global_utils';
298-
export {
299-
DebugSignalGraph as ɵDebugSignalGraph,
300-
DebugSignalGraphEdge as ɵDebugSignalGraphEdge,
301-
DebugSignalGraphNode as ɵDebugSignalGraphNode,
302-
} from './render3/util/signal_debug';
303301
export {getTransferState as ɵgetTransferState} from './render3/util/transfer_state_utils';
304302
export {
305303
isViewDirty as ɵisViewDirty,

packages/core/src/debug/ai/signal_graph.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
import {NullInjector} from '../../di/null_injector';
1010
import {getInjector} from '../../render3/util/discovery_utils';
11-
import {DebugSignalGraph, getSignalGraph} from '../../render3/util/signal_debug';
11+
import {getSignalGraph} from '../../render3/util/signal_debug';
12+
import type {DebugSignalGraph} from '../../../primitives/devtools';
1213
import {ToolDefinition} from '../../../primitives/devtools';
1314

1415
// Omit `debuggableFn` and `id` from returned signal graph to AI agent.

packages/core/src/render3/util/global_utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
getInjectorProviders,
3838
getInjectorResolutionPath,
3939
} from './injector_discovery_utils';
40-
import {DebugSignalGraph, getSignalGraph} from './signal_debug';
40+
import {getSignalGraph} from './signal_debug';
4141

4242
import {
4343
enableProfiling,
@@ -50,7 +50,7 @@ import {InjectedService, ProviderRecord} from '../debug/injector_profiler';
5050

5151
import {Type} from '../../interface/type';
5252
import {RElement} from '../interfaces/renderer_dom';
53-
import {type Profiler} from '../../../primitives/devtools';
53+
import type {DebugSignalGraph, Profiler} from '../../../primitives/devtools';
5454
import {ControlFlowBlock} from './control_flow_types';
5555

5656
/**

packages/core/src/render3/util/signal_debug.ts

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,13 @@ import {EffectNode, EffectRefImpl} from '../reactivity/effect';
1414
import {Injector} from '../../di/injector';
1515
import {R3Injector} from '../../di/r3_injector';
1616
import {throwError} from '../../util/assert';
17-
import {
18-
ComputedNode,
19-
ReactiveNode,
20-
ReactiveNodeKind,
21-
SIGNAL,
22-
SignalNode,
23-
} from '../../../primitives/signals';
17+
import {ComputedNode, ReactiveNode, SIGNAL, SignalNode} from '../../../primitives/signals';
2418
import {isLView} from '../interfaces/type_checks';
25-
26-
export interface DebugSignalGraphNode {
27-
kind: ReactiveNodeKind;
28-
id: string;
29-
epoch: number;
30-
label?: string;
31-
value?: unknown;
32-
debuggableFn?: () => unknown;
33-
}
34-
35-
export interface DebugSignalGraphEdge {
36-
/**
37-
* Index of a signal node in the `nodes` array that is a consumer of the signal produced by the producer node.
38-
*/
39-
consumer: number;
40-
41-
/**
42-
* Index of a signal node in the `nodes` array that is a producer of the signal consumed by the consumer node.
43-
*/
44-
producer: number;
45-
}
46-
47-
/**
48-
* A debug representation of the signal graph.
49-
*/
50-
export interface DebugSignalGraph {
51-
nodes: DebugSignalGraphNode[];
52-
edges: DebugSignalGraphEdge[];
53-
}
19+
import type {
20+
DebugSignalGraph,
21+
DebugSignalGraphEdge,
22+
DebugSignalGraphNode,
23+
} from '../../../primitives/devtools';
5424

5525
function isComputedNode(node: ReactiveNode): node is ComputedNode<unknown> {
5626
return node.kind === 'computed';

packages/core/test/acceptance/signal_debug_spec.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ import {
2525
setupFrameworkInjectorProfiler,
2626
} from '../../src/render3/debug/framework_injector_profiler';
2727
import {setInjectorProfiler} from '../../src/render3/debug/injector_profiler';
28-
import {
29-
DebugSignalGraphEdge,
30-
DebugSignalGraphNode,
31-
getSignalGraph,
32-
} from '../../src/render3/util/signal_debug';
28+
import type {DebugSignalGraphEdge, DebugSignalGraphNode} from '../../primitives/devtools';
29+
import {getSignalGraph} from '../../src/render3/util/signal_debug';
3330
import {fakeAsync, TestBed, tick} from '../../testing';
3431

3532
describe('getSignalGraph', () => {

0 commit comments

Comments
 (0)