Skip to content

Conversation

@thetarnav
Copy link
Owner

@thetarnav thetarnav commented Mar 28, 2025

Closes #343

By default the debugger assumes you are using "solid-js/web" as jsx renderer and that the rendered elements are HTMLElements.

If you are using a custom renderer—such as Three.js, Pixi.js, or Lightning.js—you need to provide the debugger with an ElementInterface implementation.

import * as debug from '@solid-devtools/debugger/types'
import {setElementInterface} from '@solid-devtools/debugger/setup' // or 'solid-devtools/setup'

/** ElementInterface implementation for DOM Element */
let element_interface: debug.ElementInterface<Element> = {
    isElement:    obj => obj instanceof Element,
    getElementAt: e => e.target as Element | null,
    getName:      el => el.localName,
    getChildren:  el => el.children,
    getParent:    el => el.parentElement,
    getRect:      el => el.getBoundingClientRect(),
    getLocation:  el => {
        let attr = debug.getLocationAttr(el)
        return attr && debug.parseLocationString(attr) || null
    },
}

setElementInterface(element_interface)

@changeset-bot
Copy link

changeset-bot bot commented Mar 29, 2025

🦋 Changeset detected

Latest commit: e364a4e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@solid-devtools/debugger Minor
solid-devtools Minor
@solid-devtools/shared Patch
@solid-devtools/extension Patch
@solid-devtools/frontend Patch
@solid-devtools/logger Patch
@solid-devtools/overlay Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@thetarnav thetarnav marked this pull request as ready for review April 1, 2025 09:51
@thetarnav thetarnav merged commit e28f37a into main Apr 1, 2025
5 checks passed
@thetarnav thetarnav deleted the element-interface branch April 2, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support custom renderers

2 participants