Skip to content

Commit 4ec01c3

Browse files
committed
Rename to solid-usage.md, add more info
1 parent 3770426 commit 4ec01c3

1 file changed

Lines changed: 66 additions & 39 deletions

File tree

used-solid.md renamed to solid-usage.md

Lines changed: 66 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,36 @@
11
# Current usage
22

3-
## Props
4-
5-
- `solid.$PROXY` is used to check if the props object is a proxy
3+
## Node types
64

7-
- If it's not a proxy, I can patch it with `Object.defineProperty(props, key, {get})` to intercept accessing props—since accessing props might cause side-effects I have to wait for the user.
8-
- [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/inspector.ts#L98-L113)
9-
- `solid.getListener() + solid.onCleanup()` is useful there to know when the prop is no longer being listened to—I might not have the latest value anymore.
5+
By node I mean any solid internal object, like owners, signals, roots, store-nodes, and anything user registers with `solid.DEV.registerGraph()`.
106

11-
- For proxy props I can only get keys with `Object.keys(props)`
7+
There are many internal owner properties that are inspected to determine kind of node. — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/utils.ts#L5-L86)
128

139
### Issues
1410

15-
- I cannot intercept proxy props—users just see `foo: unknown` without the value
11+
This is super brittle, some properties are set some time after the owner is created, most of the properties accessed are not used for anything else.
1612

17-
- props object cannot be changed, just monkeypatched—replacing it would probably let me intercept reads to proxy props
13+
## Node names
1814

19-
- `solid.DEV.hooks.afterCreateOwner()` gets called before `props` are attached to the owner, so I cannot get to them then.
15+
- `owner.name` or `signal.name` or `owner.component.name` or `owner.component.displayName`
2016

21-
- so currently I cannot intercept the initial reads from props—which are the most common
22-
- I would have to do `Object.defineProperty(owner, "props", {set})` to be able to patch props before component function executes probably
23-
- [source code](https://github.com/solidjs/solid/blob/main/packages/solid/src/reactive/signal.ts#L1115-L1133)
24-
25-
## Store
17+
### Issues
2618

27-
- `store.unwrap()` with type reflection when serializing and reading stores
19+
No one good way to give custom names to components.
2820

29-
- `store.isWrappable()`
21+
This works but it's a side-effect.
3022

31-
- `store.DEV.hooks.onStoreNodeUpdate()` for observing changes to stores
32-
- [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/store.ts#L27-L49)
23+
```js
24+
Bar.displayName = "Foo.Bar"
25+
```
3326

34-
### Issues
27+
While this is ugly
3528

36-
There is no connection between signals and the store-nodes they are being used in.\
37-
So if there is an effect that listens to some store property *(e.g. `createEffect(() => store.foo)`)*, from devtools perspective this is just some random signal being observed in `owner.sources`.
29+
```ts
30+
if (isDev) {
31+
getOwner()!.name = "Foo.Bar"
32+
}
33+
```
3834

3935
## Roots
4036

@@ -52,41 +48,72 @@ Any root created before `solid.DEV.hooks.afterCreateOwner` is set will be missed
5248
This is annoying because the extension's content-script isn't garanteed to run before user scripts. Making the `solid-devtools` npm package and `import "solid-devtools"` required to capture all the roots.\
5349
If there was access to any unowned root, the extension would work with any solid app with no setup.
5450

55-
## Node types
51+
## Computation updates
5652

57-
By node I mean any solid internal object, like owners, signals, roots, store-nodes, and anything user registers with `solid.DEV.registerGraph()`.
53+
- `owner.fn` is patched to observe when the computration reruns — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/observe.ts#L50-L88)
5854

59-
There are many internal owner properties that are inspected to determine kind of node.
60-
- [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/utils.ts#L5-L86)
55+
- `owner.value` is read to get the current owner value and patched to listen to changes — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/observe.ts#L98-L123)
56+
- signals are being observed the same way
57+
- this is also separate from observing `owner.fn` because not every rerun will cause the value to update *(thanks to `equals` option)*
6158

62-
### Issues
59+
- `owner.sources` — by listening to each of the sources, I'm able to tell which source caused the computation to rerun. — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/logger/src/index.ts#L117-L180)
6360

64-
This is super brittle, some properties are set some time after the owner is created, most of the properties accessed are not used for anything else.
61+
## Owners tree
62+
63+
Reads `owner.owner` and `owner.owned` to walk the tree in both directions
6564

66-
## Owners
65+
## Owner disposing
6766

68-
patching `owner.cleanups` to listen to cleanup of any owner
69-
- [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/utils.ts#L205-L227)
67+
Patching `owner.cleanups` to listen to cleanup of any owner — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/utils.ts#L205-L227)
7068

7169
### Issues
7270

7371
The cleanups are executed depth first—if I try to walk the tree on child's cleanup, I cannot tell if the parent is getting cleaned up as well or not. There is no `isDisposed` property.
7472

75-
## Computation updates
73+
## Dependency graph
7674

77-
- `owner.fn` is patched to observe when the computration reruns — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/observe.ts#L50-L88)
75+
- `owner.sources` and `owner.observers`
7876

79-
- `owner.value` is read to get the current owner value and patched to listen to changes — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/observe.ts#L98-L123)
80-
- signals are being observed the same way
77+
- `sourceValue.graph` — for signals to know to which owner they "belong to"
8178

82-
- `owner.sources` — by listening to each of the sources, I'm able to tell which source caused the computation to rerun. — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/logger/src/index.ts#L117-L180)
79+
## Props
80+
81+
- `solid.$PROXY` is used to check if the props object is a proxy
82+
83+
- If it's not a proxy, I can patch it with `Object.defineProperty(props, key, {get})` to intercept accessing props—since accessing props might cause side-effects I have to wait for the user.
84+
- [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/inspector.ts#L98-L113)
85+
- `solid.getListener() + solid.onCleanup()` is useful there to know when the prop is no longer being listened to—I might not have the latest value anymore.
86+
87+
- For proxy props I can only get keys with `Object.keys(props)`
88+
89+
### Issues
90+
91+
- I cannot intercept proxy props—users just see `foo: unknown` without the value
92+
93+
- props object cannot be changed, just monkeypatched—replacing it would probably let me intercept reads to proxy props
8394

95+
- `solid.DEV.hooks.afterCreateOwner()` gets called before `props` are attached to the owner, so I cannot get to them then.
96+
97+
- so currently I cannot intercept the initial reads from props—which are the most common
98+
- I would have to do `Object.defineProperty(owner, "props", {set})` to be able to patch props before component function executes probably
99+
- [source code](https://github.com/solidjs/solid/blob/main/packages/solid/src/reactive/signal.ts#L1115-L1133)
100+
101+
## Store
102+
103+
- `store.unwrap()` with type reflection when serializing and reading stores
84104

85-
## Computations
105+
- `store.isWrappable()`
106+
107+
- `store.DEV.hooks.onStoreNodeUpdate()` for observing changes to stores — [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/store.ts#L27-L49)
86108

87-
- `owner.owned`
109+
### Issues
88110

89-
- `owner.observers`
111+
There is no connection between signals and the store-nodes they are being used in.\
112+
So if there is an effect that listens to some store property *(e.g. `createEffect(() => store.foo)`)*, from devtools perspective this is just some random signal being observed in `owner.sources`.
113+
114+
## Source Map
115+
116+
- `owner.sourceMap`
90117

91118
## Source Map
92119

0 commit comments

Comments
 (0)