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

@spark-view/spark-component

v0.4.2

Published

SPARK Component System - 组件核心(能力系统、组件管理器、组件注册表)

Readme

@spark-view/spark-component

SPARK 组件系统核心 - 提供组件管理、能力系统和生命周期控制

TypeScript Vue

特性

  • 组件注册 - 统一的组件注册和管理机制
  • 能力系统 - Provider/Consumer 模式的依赖注入
  • 懒加载 - 支持动态导入和按需加载
  • 生命周期 - 完整的组件生命周期管理
  • 命名空间 API - 统一的 Spark 命名空间

安装

pnpm add @spark-view/spark-component

快速开始

1. 注册组件

import { Spark } from '@spark-view/spark-component'
import MyGridComponent from './MyGridComponent.vue'

// 静态注册
Spark.register('my-grid', MyGridComponent)

// 懒加载注册
Spark.register('my-chart', () => import('./MyChartComponent.vue'))

// 批量注册(推荐)
const reg = Spark.createRegister(import.meta.glob('./*.vue'))
reg.registerAll({
  'my-grid': './MyGridComponent.vue',
  'my-chart': './MyChartComponent.vue'
})

2. 安装插件

import { createApp } from 'vue'

const app = createApp(App)
// 使用全局单例(推荐)
app.use(Spark.createPlugin())

3. 使用组件

<script setup lang="ts">
import { useSparkComponent } from '@spark-view/spark-component'

const { provide, consume } = useSparkComponent({
  type: 'my-grid'
})

// 提供能力(必须在 setup 同步阶段调用)
provide('dataSource', {
  getData: () => fetchData()
})

// 消费能力(必须在 setup 同步阶段调用)
const logger = consume('logger')
</script>

核心概念

能力系统

组件间通过能力系统通信,避免紧耦合:

// Provider 提供能力(setup 同步阶段)
provide('columnManager', {
  addColumn: (col) => columns.value.push(col),
  removeColumn: (id) => columns.value = columns.value.filter(c => c.id !== id)
})

// Consumer 消费能力(setup 同步阶段)
const columnManager = consume('columnManager')
// ⚠️ provide/consume 必须在 setup() 同步阶段调用,不要在 onMounted/watch/async 中使用

命名空间 API

所有 API 通过 Spark 命名空间统一访问:

import { Spark } from '@spark-view/spark-component'

// 注册组件
Spark.register('my-component', MyComponent)

// 安装 Vue 插件(使用全局单例)
app.use(Spark.createPlugin())

// 类型定义
import type { ComponentContext } from '@spark-view/spark-component'

API 文档

完整 API 文档请查看 API.md

依赖

{
  "@spark-view/spark-utils": "workspace:*",
  "vue": "^3.4.0"
}

开发命令

pnpm run typecheck   # 类型检查
pnpm run test        # 运行测试
pnpm run build       # 构建包

License

MIT