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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@actview/store

v0.0.4

Published

Readme

@actview/store

ActView 的组合式状态管理库。对齐 Pinia setup store,但保持 TSX + 组合式 API 风格:用 reactive/computed 定义状态,defineStore 提供单例与类型推导。

安装

pnpm add @actview/store

快速开始

import { reactive, computed } from 'actview'
import { defineStore } from '@actview/store'

export const useCounter = defineStore('counter', () => {
  const state = reactive({ count: 0 })
  const double = computed(() => state.count * 2)
  function inc() {
    state.count++
  }
  return { state, double, inc }
})

组件中使用:

function Counter() {
  const counter = useCounter() // 单例:多次调用返回同一实例
  return (
    <button onClick={() => counter.inc()}>
      {counter.state.count}(double: {counter.double.value})
    </button>
  )
}

API

| 导出 | 说明 | |---|---| | defineStore(id, setup) | 定义 store,返回 useStore(懒创建单例) | | applyPlugin(fn) | 注册插件,store 创建时调用 fn({ id, state }) | | resetStore(id) | 重置指定 store(下次 useStore 重新执行 setup) | | resetAllStores() | 重置全部 | | getActiveStoreIds() | 已创建的 store id 列表 | | getStore(id) | 获取 store 实例(未创建返回 undefined) |

插件示例:持久化

import { watch } from 'actview'
import { applyPlugin } from '@actview/store'

applyPlugin(({ id, state }) => {
  // 恢复
  const saved = localStorage.getItem(id)
  if (saved) Object.assign(state, JSON.parse(saved))
  // 订阅持久化
  watch(state, () => localStorage.setItem(id, JSON.stringify(state)), { deep: true })
})

特点

  • 零样板:useStore() 返回类型由 setup 返回类型自动推导
  • 响应式:reactive 状态 + computed 派生,组件读取自动追踪
  • 单例:同 id 跨模块复用,避免重复创建
  • 可测试:resetAllStores() 清理,测试间隔离