Skip to content

Commit d28ed2a

Browse files
committed
chore: Remove separate constants module
1 parent e0460fe commit d28ed2a

13 files changed

Lines changed: 75 additions & 85 deletions

File tree

packages/debugger/src/dependency/collect.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import '../setup.ts'
22

33
import * as s from 'solid-js'
44
import * as test from 'vitest'
5-
import {NodeType} from '../main/constants.ts'
65
import {ObjectType, getSdtId} from '../main/id.ts'
76
import setup from '../main/setup.ts'
8-
import type {NodeID, Solid} from '../main/types.ts'
7+
import {NodeType, type NodeID, type Solid} from '../main/types.ts'
98
import {type SerializedDGraph, collectDependencyGraph} from './collect.ts'
109

1110

packages/debugger/src/dependency/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import * as s from 'solid-js'
22
import {throttle} from '@solid-primitives/scheduled'
33
import {defer} from '@solid-primitives/utils'
44
import {msg} from '@solid-devtools/shared/utils'
5-
import {DevtoolsMainView, NodeType} from '../main/constants.ts'
65
import {ObjectType, getObjectById} from '../main/id.ts'
7-
import {type InspectedState, type NodeID, type OutputEmit, type Solid} from '../main/types.ts'
6+
import {DevtoolsMainView, NodeType, type InspectedState, type NodeID, type OutputEmit, type Solid} from '../main/types.ts'
87
import {getNodeType} from '../main/utils.ts'
98
import {type OnNodeUpdate, type SerializedDGraph, collectDependencyGraph} from './collect.ts'
109

packages/debugger/src/inspector/inspector.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import {misc} from '@nothing-but/utils'
22
import {parseLocationString, type SourceLocation} from '../locator/index.ts'
3-
import {NodeType, ValueItemType} from '../main/constants.ts'
43
import {ObjectType, getSdtId} from '../main/id.ts'
54
import {observeValueUpdate, removeValueUpdateObserver} from '../main/observe.ts'
65
import setup from '../main/setup.ts'
7-
import type {Mapped, NodeID, Solid, ValueItemID} from '../main/types.ts'
6+
import {type Mapped, type NodeID, type Solid, type ValueItemID, NodeType, ValueItemType} from '../main/types.ts'
87
import * as utils from '../main/utils.ts'
98
import {UNOWNED_ROOT} from '../main/roots.ts'
109
import {encodeValue} from './serialize.ts'

packages/debugger/src/main/constants.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

packages/debugger/src/main/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import {createDependencyGraph} from '../dependency/index.ts'
66
import {createInspector} from '../inspector/index.ts'
77
import {createLocator} from '../locator/index.ts'
88
import {createStructure} from '../structure/index.ts'
9-
import {DebuggerModule, DEFAULT_MAIN_VIEW, DevtoolsMainView} from './constants.ts'
109
import {getObjectById, getSdtId, ObjectType} from './id.ts'
1110
import {initRoots} from './roots.ts'
1211
import setup from './setup.ts'
1312
import {
14-
INSPECTED_STATE_NULL,
13+
DebuggerModule,
14+
DEFAULT_MAIN_VIEW, DevtoolsMainView,
15+
INSPECTED_STATE_NULL, type InspectedState,
1516
type InputChannels,
1617
type InputMessage,
17-
type InspectedState,
1818
type NodeID,
1919
type OutputListener,
2020
type OutputMessage,

packages/debugger/src/main/roots.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import {warn} from '@solid-devtools/shared/utils'
2-
import {NodeType} from './constants.ts'
32
import {ObjectType, getSdtId} from './id.ts'
43
import setup from './setup.ts'
5-
import {type NodeID, type Solid} from './types.ts'
4+
import {type NodeID, type Solid, NodeType} from './types.ts'
65
import {isSolidRoot, onOwnerCleanup} from './utils.ts'
76

87
/**

packages/debugger/src/main/types.ts

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,69 @@ import type {Union} from '@solid-devtools/shared/utils'
22
import type {EncodedValue, InspectorUpdate, PropGetterState, ToggleInspectedValueData} from '../inspector/types.ts'
33
import type {HighlightElementPayload, SourceLocation} from '../locator/types.ts'
44
import type {StructureUpdates, DGraphUpdate} from '../types.ts'
5-
import {DebuggerModule, DevtoolsMainView, NodeType, OWNER_LOCATION_PROP, TreeWalkerMode, ValueItemType} from './constants.ts'
5+
6+
/**
7+
* Main modules and views of the devtools. Used for "routing".
8+
*/
9+
export enum DevtoolsMainView {
10+
Structure = 'structure',
11+
}
12+
export const DEFAULT_MAIN_VIEW = DevtoolsMainView.Structure
13+
14+
export enum DebuggerModule {
15+
Locator = 'locator',
16+
Structure = 'structure',
17+
Dgraph = 'dgraph',
18+
}
19+
20+
export enum TreeWalkerMode {
21+
Owners = 'owners',
22+
Components = 'components',
23+
DOM = 'dom',
24+
}
25+
export const DEFAULT_WALKER_MODE = TreeWalkerMode.Components
26+
27+
export enum NodeType {
28+
Root = 'ROOT',
29+
Component = 'COMPONENT',
30+
Element = 'ELEMENT',
31+
Effect = 'EFFECT',
32+
Render = 'RENDER',
33+
Memo = 'MEMO',
34+
Computation = 'COMPUTATION',
35+
Refresh = 'REFRESH',
36+
Context = 'CONTEXT',
37+
CatchError = 'CATCH_ERROR',
38+
Signal = 'SIGNAL',
39+
Store = 'STORE',
40+
CustomValue = 'CUSTOM_VALUE',
41+
}
42+
43+
export const NODE_TYPE_NAMES: Readonly<Record<NodeType, string>> = {
44+
[NodeType.Root]: 'Root',
45+
[NodeType.Component]: 'Component',
46+
[NodeType.Element]: 'Element',
47+
[NodeType.Effect]: 'Effect',
48+
[NodeType.Render]: 'Render Effect',
49+
[NodeType.Memo]: 'Memo',
50+
[NodeType.Computation]: 'Computation',
51+
[NodeType.Refresh]: 'Refresh',
52+
[NodeType.Context]: 'Context',
53+
[NodeType.CatchError]: 'CatchError',
54+
[NodeType.Signal]: 'Signal',
55+
[NodeType.Store]: 'Store',
56+
[NodeType.CustomValue]: 'Custom Value',
57+
}
58+
59+
export enum ValueItemType {
60+
Signal = 'signal',
61+
Prop = 'prop',
62+
Value = 'value',
63+
}
64+
65+
export const UNKNOWN = 'unknown'
66+
67+
export const OWNER_LOCATION_PROP = 'sdtLocation'
668

769
export type InspectedState = {
870
readonly ownerId: NodeID | null

packages/debugger/src/main/utils.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import '../setup.ts'
22

33
import * as s from 'solid-js'
44
import * as vi from 'vitest'
5-
import {NodeType} from './constants.ts'
6-
import {type Solid} from '../types.ts'
5+
import {NodeType, type Solid} from '../types.ts'
76
import * as utils from './utils.ts'
87
import setup from './setup.ts'
98

packages/debugger/src/main/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {trimString} from '@solid-devtools/shared/utils'
2-
import {NodeType} from './constants.ts'
3-
import {type Solid} from './types.ts'
2+
import {type Solid, NodeType} from './types.ts'
43
import setup from './setup.ts'
54

65
export const isSolidOwner = (o: Solid.SourceMapValue | Solid.Owner | Solid.Store | Solid.Signal): o is Solid.Owner =>

packages/debugger/src/structure/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import {throttle} from '@solid-primitives/scheduled'
22
import * as registry from '../main/component-registry.ts'
3-
import {DEFAULT_WALKER_MODE, DevtoolsMainView, NodeType, TreeWalkerMode} from '../main/constants.ts'
43
import {ObjectType, getSdtId} from '../main/id.ts'
54
import * as roots from '../main/roots.ts'
6-
import {type Mapped, type NodeID, type Solid} from '../main/types.ts'
5+
import {type Mapped, type NodeID, type Solid, DEFAULT_WALKER_MODE, DevtoolsMainView, NodeType, TreeWalkerMode} from '../main/types.ts'
76
import {isDisposed, markOwnerType} from '../main/utils.ts'
87
import {type ComputationUpdateHandler, walkSolidTree} from './walker.ts'
98

0 commit comments

Comments
 (0)