|
5 | 5 | - `solid.$PROXY` is used to check if the props object is a proxy |
6 | 6 |
|
7 | 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 | | - - https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/inspector.ts#L98-L113 |
| 8 | + - [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/inspector.ts#L98-L113) |
9 | 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. |
10 | 10 |
|
11 | 11 | - For proxy props I can only get keys with `Object.keys(props)` |
|
20 | 20 |
|
21 | 21 | - so currently I cannot intercept the initial reads from props—which are the most common |
22 | 22 | - I would have to do `Object.defineProperty(owner, "props", {set})` to be able to patch props before component function executes probably |
23 | | - - https://github.com/solidjs/solid/blob/main/packages/solid/src/reactive/signal.ts#L1115-L1133 |
| 23 | + - [source code](https://github.com/solidjs/solid/blob/main/packages/solid/src/reactive/signal.ts#L1115-L1133) |
24 | 24 |
|
25 | 25 | ## Store |
26 | 26 |
|
|
29 | 29 | - `store.isWrappable()` |
30 | 30 |
|
31 | 31 | - `store.DEV.hooks.onStoreNodeUpdate()` for observing changes to stores |
32 | | - - https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/store.ts#L27-L49 |
| 32 | + - [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/inspector/store.ts#L27-L49) |
33 | 33 |
|
34 | 34 | ### Issues |
35 | 35 |
|
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` |
| 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`. |
38 | 38 |
|
39 | | -## Owner tree |
| 39 | +## Roots |
40 | 40 |
|
41 | 41 | - `solid.DEV.hooks.afterCreateOwner()` for attaching the debugger to roots |
42 | 42 | - to gather top-level roots like `render()` |
43 | 43 | - but also to "re-attach roots back to the owner tree" when `createRoot` is used under owners, like in `mapArray` |
44 | | - - https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/roots.ts#L147-L163 |
| 44 | + - [source code](https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/roots.ts#L147-L163) |
45 | 45 | - access to `owner.owner` and `owner.cleanups` to listen to parent's *(root's detached owner)* cleanup |
46 | 46 | - so that if the root's parent disposes before the root, the root will need to be "reattached" to first found "alive" owner |
47 | 47 | - this is rather uncommon |
48 | 48 |
|
49 | | -- patching `owner.cleanups` to listen to cleanup of any owner |
50 | | - - https://github.com/thetarnav/solid-devtools/blob/main/packages/debugger/src/main/utils.ts#L205-L227 |
| 49 | +### Issues |
| 50 | + |
| 51 | +Any root created before `solid.DEV.hooks.afterCreateOwner` is set will be missed.\ |
| 52 | +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.\ |
| 53 | +If there was access to any unowned root, the extension would work with any solid app with no setup. |
| 54 | + |
| 55 | +## Node types |
| 56 | + |
| 57 | +By node I mean any solid internal object, like owners, signals, roots, store-nodes, and anything user registers with `solid.DEV.registerGraph()`. |
| 58 | + |
| 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) |
| 61 | + |
| 62 | +### Issues |
| 63 | + |
| 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. |
| 65 | + |
| 66 | +## Owners |
| 67 | + |
| 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) |
| 70 | + |
| 71 | +### Issues |
| 72 | + |
| 73 | +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. |
| 74 | + |
| 75 | +## Computation updates |
| 76 | + |
| 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) |
| 78 | + |
| 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 |
| 81 | + |
| 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) |
51 | 83 |
|
52 | | -- `owner.owned` |
53 | 84 |
|
54 | 85 | ## Computations |
55 | 86 |
|
56 | | -- `owner.value` + patching the value |
57 | | -- `owner.sources` |
| 87 | +- `owner.owned` |
| 88 | + |
58 | 89 | - `owner.observers` |
59 | 90 |
|
60 | 91 | ## Source Map |
|
64 | 95 | - `owner.sourceMap` |
65 | 96 |
|
66 | 97 | ## List |
| 98 | + |
67 | 99 | - `solid.$PROXY` in [props](#props) |
68 | 100 | - `Object.defineProperty(props, key, {get})` in [props](#props) |
69 | 101 | - `solid.getListener() + solid.onCleanup()` in [props](#props) |
|
0 commit comments