npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@solid-devtools/logger

v0.8.4

Published

Solid debugging utilities for logging the state of the reactivity graph to the console.

Downloads

931

Readme

@solid-devtools/logger

pnpm version npm

For debugging only the pinpoint places parts of the Solid's reactivity graph you are concerned with, right in the console you use all the time.

Provides a variaty of debugging utilities for logging the state and lifecycle of the nodes of reactivity graph to the browser console.

API:

Installation

The Logger package is currently not a part of the main solid-devtools library — it has to be installed on it's own.

npm i @solid-devtools/logger
# or
yarn add @solid-devtools/logger
# or
pnpm add @solid-devtools/logger

Usage guide

This package provides multiple different hooks to be used depending on the situation, and the information that you currently need.

Warning The hooks aren't being designed to be placed and forgotten about. They will actively spam your console. But I guess I cannot stop you.

Most of the hooks don't require any arguments to work and are very easy to use.

debugComputation

Debug the current computation owner by logging it's lifecycle state to the browser console.

Accepts following arguments:

  • owner - The owner to debug. If not provided, the current owner will be used.
  • options - Options for the debug. (optional)

Following information will be tracked and displayed in the console:

  • The computation's initial state. (value, name, dependencies, execution time, etc.)
  • The computation's state after each rerun. (value, previous value, dependencies, sources that have caused the rerun, execution time, etc.)
  • The computation disposal.
import { debugComputation } from '@solid-devtools/logger'

createEffect(() => {
  debugComputation()
  // ...
})

debugOwnerComputations

Debug the computations owned by the provided owner by logging their lifecycle state to the browser console.

Accepts following arguments:

  • owner - The owner to debug. If not provided, the current owner will be used.
  • options - Options for the debug. (optional)

Following information will be tracked and displayed in the console:

  • The computations initial state. (value, name, dependencies, execution time, etc.)
  • The computations state after each rerun. (value, previous value, dependencies, sources that have caused the rerun, execution time, etc.)
  • The computations disposal.
import { debugOwnerComputations } from "@solid-devtools/logger"

const Button = props => {
	debugOwnerComputations()
	createEffect(() => {...})
	return <button {...props} />
}

debugSignal

Debug the provided source by logging its lifecycle state to the browser console.

Accepts following arguments:

  • source - The signal to debug. (a function that will be executed to get the signal node)
  • options - Options for the debug. (optional)

Following information will be tracked and displayed in the console:

  • The signal's initial state. (value, name, observers, etc.)
  • The signal's state after each value update. (value, previous value, observers, caused reruns, etc.)
import { debugSignal } from '@solid-devtools/logger'

const [count, setCount] = createSignal(0)

debugSignal(count)

debugSignals

Same as debugSignal but for multiple signals.

The source argument can be an array of signals or a function that calls multiple signals. (Similar to Solid's on helper)

import { debugSignals } from '@solid-devtools/logger'

const [count, setCount] = createSignal(0)
const double = createMemo(() => count() * 2)

debugSignals([count, double])
// or
debugSignals(() => {
  count()
  double()
})

debugOwnerSignals

Debug the signals created under given reactive owner by logging their lifecycle state to the browser console.

Accepts following arguments:

  • owner - owner to get the signals from.
  • options - Options for the debug. (optional)

Following information will be tracked and displayed in the console:

  • The signals initial state. (value, name, observers, etc.)
  • The signals state after each value update. (value, previous value, observers, caused reruns, etc.)
import { debugOwnerSignals } from '@solid-devtools/logger'

const Button = props => {
  const [count, setCount] = createSignal(0)
  const double = createMemo(() => count() * 2)
  debugOwnerSignals()
  return <button onClick={() => setCount(p => ++p)}>{count}</button>
}

debugProps

Debug the provided props object by logging their state to the console.

Accepts following arguments:

  • props - The component's props object to debug. (optional)
import { debugProps } from '@solid-devtools/logger'

const Button = props => {
  debugProps(props)
  const [count, setCount] = createSignal(0)
  return <button onClick={() => setCount(p => ++p)}>{count()}</button>
}

Demo video

https://user-images.githubusercontent.com/24491503/176549151-c06a1d14-2d99-4211-9f9e-74392be8890a.mp4

More hook ideas

There is still a lot of places this package could be extended or improved.

If you have any ideas or needs for features that might be helpful, let me know! :)

Changelog

See CHANGELOG.md.