Skip to content

Commit e0460fe

Browse files
committed
chore: Remove get-id module
1 parent af7b30f commit e0460fe

6 files changed

Lines changed: 4 additions & 35 deletions

File tree

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ import setup from '../main/setup.ts'
88
import type {NodeID, Solid} from '../main/types.ts'
99
import {type SerializedDGraph, collectDependencyGraph} from './collect.ts'
1010

11-
let mockLAST_ID = 0
12-
test.beforeEach(() => {
13-
mockLAST_ID = 0
14-
})
15-
test.vi.mock('../main/get-id.ts', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
1611

1712
test.describe('collectDependencyGraph', () => {
1813
test.it('should collect dependency graph', () => {

packages/debugger/src/inspector/serialize.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import {ObjectType, getObjectById} from '../main/id.ts'
77
import {encodeValue} from './serialize.ts'
88
import {type EncodedValue, INFINITY, NAN, NEGATIVE_INFINITY, UNDEFINED, ValueType} from './types.ts'
99

10-
let mockLAST_ID = 0
11-
vi.mock('../main/get-id.ts', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
12-
1310
type Expectations = [name: string, data: unknown, encoded: EncodedValue[]][]
1411

1512
const div1 = document.createElement('div')
@@ -24,7 +21,6 @@ const [state] = createStore({a: 1, b: 2, c: 3})
2421
const mutable = createMutable({a: 1, b: 2, c: 3})
2522

2623
describe('encodeValue Preview', () => {
27-
mockLAST_ID = 0
2824

2925
const encodePreviewExpectations: Expectations = [
3026
['Infinity', Infinity, [[ValueType.Number, INFINITY]]],
@@ -86,7 +82,6 @@ describe('encodeValue Preview', () => {
8682
})
8783

8884
describe('encodeValue Deep', () => {
89-
mockLAST_ID = 0
9085

9186
const encodeDeepExpectations: Expectations = [
9287
['Array empty', [], [[ValueType.Array, []]]],
@@ -163,7 +158,6 @@ describe('encodeValue Deep', () => {
163158
})
164159

165160
describe('save elements to a map', () => {
166-
mockLAST_ID = 0
167161

168162
const elMapExpectations: Expectations = [
169163
['Element div', div1, [[ValueType.Element, '#0:div']]],
@@ -193,7 +187,6 @@ describe('save elements to a map', () => {
193187
})
194188

195189
describe('encodeValue with repeated references', () => {
196-
mockLAST_ID = 0
197190

198191
const one: any = {a: 1}
199192
one.b = one
@@ -240,7 +233,6 @@ describe('encodeValue with repeated references', () => {
240233
})
241234

242235
describe('finding stores in values', () => {
243-
mockLAST_ID = 0
244236

245237
const [state1] = createStore({a: 1})
246238
const [state2] = createStore({ref: state1})

packages/debugger/src/inspector/store.test.ts

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

33
import {createRoot} from 'solid-js'
44
import {createMutable, createStore, modifyMutable, produce, reconcile, unwrap} from 'solid-js/store'
5-
import {beforeEach, describe, expect, it, vi} from 'vitest'
5+
import {describe, expect, it, vi} from 'vitest'
66
import {ObjectType, getSdtId} from '../main/id.ts'
77
import setup from '../main/setup.ts'
88
import {isSolidStore} from '../main/utils.ts'
@@ -21,12 +21,6 @@ const getOwnerStore = () => {
2121
const getNodeProp = (node: Solid.StoreNode, prop: string): StoreNodeProperty =>
2222
`${getSdtId(unwrap(node), ObjectType.StoreNode)}:${prop}`
2323

24-
let mockLAST_ID = 0
25-
beforeEach(() => {
26-
mockLAST_ID = 0
27-
})
28-
vi.mock('../main/get-id.ts', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
29-
3024
type UpdateParams = Parameters<OnNodeUpdate>
3125

3226
describe('observeStoreNode2', () => {

packages/debugger/src/main/get-id.ts

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

packages/debugger/src/main/id.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {getNewSdtId} from './get-id.ts'
21
import {type NodeID, type Solid} from './types.ts'
32

43
export const enum ObjectType {
@@ -36,6 +35,9 @@ const CleanupRegistry = new FinalizationRegistry((data: {map: ObjectType; id: No
3635
RefMapMap[data.map].delete(data.id)
3736
})
3837

38+
let LastId = 0
39+
export const getNewSdtId = (): NodeID => `#${(LastId++).toString(36)}`
40+
3941
export function getSdtId<T extends ObjectType>(obj: ValueMap[T], objType: T): NodeID {
4042
let id = WeakIdMap.get(obj)
4143
if (!id) {

packages/debugger/src/structure/walker.test.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ test.beforeAll(() => {
1414
initRoots()
1515
})
1616

17-
let mockLAST_ID = 0
18-
test.beforeEach(() => {
19-
mockLAST_ID = 0
20-
})
21-
test.vi.mock('../main/get-id.ts', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
22-
2317
test.describe('TreeWalkerMode.Owners', () => {
2418
test.it('default options', () => {
2519
{

0 commit comments

Comments
 (0)