@@ -9,7 +9,7 @@ import {onOwnerDispose} from '../main/utils.ts'
99import { type ObservedPropsMap , ValueNodeMap , clearOwnerObservers , collectOwnerDetails } from './inspector.ts'
1010import { encodeValue } from './serialize.ts'
1111import { type StoreNodeProperty , type StoreUpdateData , observeStoreNode , setOnStoreNodeUpdate } from './store.ts'
12- import { type InspectorUpdate , type InspectorUpdateMap , PropGetterState } from './types.ts'
12+ import { GLOBAL_GET_VALUE , type InspectorUpdate , type InspectorUpdateMap , PropGetterState } from './types.ts'
1313
1414export * from './types.ts'
1515
@@ -24,13 +24,22 @@ export function createInspector(props: {
2424 resetInspectedNode : VoidFunction
2525 emit : OutputEmit
2626} ) {
27+
2728 let lastDetails : Mapped . OwnerDetails | undefined
2829 let inspectedOwner : Solid . Owner | null
2930 let valueMap = new ValueNodeMap ( )
3031 const propsMap : ObservedPropsMap = new WeakMap ( )
3132 /** compare props object with the previous one to see whats changed */
3233 let checkProxyProps : ( ( ) => InspectorUpdateMap [ 'propKeys' ] | null ) | null
3334
35+ /*
36+ For the extension for inspecting values through `inspect()`
37+ */
38+ function getValue ( id : ValueItemID ) : unknown {
39+ return valueMap . get ( id ) ?. getValue ?.( )
40+ }
41+ window [ GLOBAL_GET_VALUE ] = getValue
42+
3443 // Batch and dedupe inspector updates
3544 // these will include updates to signals, stores, props, and node value
3645 const { pushPropState, pushValueUpdate, pushInspectToggle, triggerPropsCheck, clearUpdates} =
@@ -156,11 +165,12 @@ export function createInspector(props: {
156165 } )
157166
158167 props . emit ( 'InspectedNodeDetails' , result . details )
159- valueMap = result . valueMap
160- lastDetails = result . details
168+
169+ valueMap = result . valueMap
170+ lastDetails = result . details
161171 checkProxyProps = result . checkProxyProps || null
162172 } else {
163- lastDetails = undefined
173+ lastDetails = undefined
164174 checkProxyProps = null
165175 }
166176
@@ -186,5 +196,9 @@ export function createInspector(props: {
186196 node . setSelected ( selected )
187197 pushInspectToggle ( id , selected )
188198 } ,
199+ consoleLogValue ( value_id : ValueItemID ) : void {
200+ // eslint-disable-next-line no-console
201+ console . log ( getValue ( value_id ) )
202+ }
189203 }
190204}
0 commit comments