@@ -3,7 +3,7 @@ import {parseLocationString} from '../locator/index.ts'
33import { ObjectType , getSdtId } from '../main/id.ts'
44import { observeValueUpdate , removeValueUpdateObserver } from '../main/observe.ts'
55import setup from '../main/setup.ts'
6- import { type Mapped , type NodeID , type Solid , type SourceLocation , type ValueItemID , NodeType , ValueItemType } from '../main/types.ts'
6+ import { type ElementInterface , type Mapped , type NodeID , type Solid , type SourceLocation , type ValueItemID , NodeType , ValueItemType } from '../main/types.ts'
77import * as utils from '../main/utils.ts'
88import { UNOWNED_ROOT } from '../main/roots.ts'
99import { encodeValue } from './serialize.ts'
@@ -163,9 +163,10 @@ let PropsMap: ObservedPropsMap
163163
164164const $INSPECTOR = Symbol ( 'inspector' )
165165
166- function mapSourceValue (
166+ function mapSourceValue < TEl extends object > (
167167 node_raw : Solid . SourceMapValue | Solid . Computation ,
168168 handler : ( nodeId : NodeID , value : unknown ) => void ,
169+ eli : ElementInterface < TEl > ,
169170) : Mapped . SourceValue | null {
170171
171172 let node = utils . getNode ( node_raw )
@@ -194,11 +195,14 @@ function mapSourceValue(
194195 type : node . kind ,
195196 name : utils . getNodeName ( node . data ) ,
196197 id : id ,
197- value : encodeValue ( value , false ) ,
198+ value : encodeValue ( value , false , eli ) ,
198199 }
199200}
200201
201- function mapProps ( props : Solid . Component [ 'props' ] ) {
202+ function mapProps < TEl extends object > (
203+ props : Solid . Component [ 'props' ] ,
204+ eli : ElementInterface < TEl > ,
205+ ) {
202206 // proxy props need to be checked for changes in keys
203207 const isProxy = ! ! ( props as any ) [ setup . solid . $PROXY ]
204208 const record : Mapped . Props [ 'record' ] = { }
@@ -232,14 +236,14 @@ function mapProps(props: Solid.Component['props']) {
232236 const lastValue = getValue ( )
233237 record [ key ] = {
234238 getter : isStale ? PropGetterState . Stale : PropGetterState . Live ,
235- value : lastValue !== $NOT_SET ? encodeValue ( getValue ( ) , false ) : null ,
239+ value : lastValue !== $NOT_SET ? encodeValue ( getValue ( ) , false , eli ) : null ,
236240 }
237241 }
238242 // VALUE
239243 else {
240244 record [ key ] = {
241245 getter : false ,
242- value : encodeValue ( desc . value , false ) ,
246+ value : encodeValue ( desc . value , false , eli ) ,
243247 }
244248 // non-object props cannot be inspected (won't ever change and aren't deep)
245249 if ( Array . isArray ( desc . value ) || misc . is_plain_object ( desc . value ) )
@@ -251,18 +255,19 @@ function mapProps(props: Solid.Component['props']) {
251255 return { props : { proxy : isProxy , record} , checkProxyProps}
252256}
253257
254- export type CollectDetailsConfig = {
258+ export type CollectDetailsConfig < TEl extends object > = {
255259 onPropStateChange : Inspector . OnPropStateChange
256260 onValueUpdate : Inspector . OnValueUpdate
257261 observedPropsMap : ObservedPropsMap
262+ eli : ElementInterface < TEl > ,
258263}
259264
260- export function collectOwnerDetails (
265+ export function collectOwnerDetails < TEl extends object > (
261266 owner : Solid . Owner ,
262- config : CollectDetailsConfig ,
267+ config : CollectDetailsConfig < TEl > ,
263268) {
264269
265- const { onValueUpdate} = config
270+ const { onValueUpdate, eli } = config
266271
267272 // Set globals
268273 ValueMap = new ValueNodeMap ( )
@@ -308,7 +313,7 @@ export function collectOwnerDetails(
308313 details . hmr = true
309314 }
310315
311- ; ( { checkProxyProps, props : details . props } = mapProps ( owner . props ) )
316+ ; ( { checkProxyProps, props : details . props } = mapProps ( owner . props , eli ) )
312317
313318 let location : string | SourceLocation | undefined
314319 if ( (
@@ -326,21 +331,21 @@ export function collectOwnerDetails(
326331 observeValueUpdate ( owner , ( ) => onValueUpdate ( ValueItemType . Value ) , $INSPECTOR )
327332 }
328333
329- details . value = encodeValue ( getValue ( ) , false )
334+ details . value = encodeValue ( getValue ( ) , false , eli )
330335 }
331336
332337 const onSignalUpdate = ( signalId : NodeID ) =>
333338 onValueUpdate ( `${ ValueItemType . Signal } :${ signalId } ` )
334339
335340 // map signals
336341 if ( sourceMap ) for ( let signal of sourceMap ) {
337- let mapped = mapSourceValue ( signal , onSignalUpdate )
342+ let mapped = mapSourceValue ( signal , onSignalUpdate , eli )
338343 if ( mapped ) details . signals . push ( mapped )
339344 }
340345
341346 // map memos
342347 if ( owned ) for ( let node of owned ) {
343- let mapped = mapSourceValue ( node , onSignalUpdate )
348+ let mapped = mapSourceValue ( node , onSignalUpdate , eli )
344349 if ( mapped ) details . signals . push ( mapped )
345350 }
346351
@@ -351,7 +356,7 @@ export function collectOwnerDetails(
351356 let signal = signal_ref . deref ( )
352357 if ( signal == null ) continue
353358
354- let mapped = mapSourceValue ( signal , onSignalUpdate )
359+ let mapped = mapSourceValue ( signal , onSignalUpdate , eli )
355360 if ( mapped == null ) continue
356361
357362 details . signals . push ( mapped )
0 commit comments