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

@univa/core

v0.0.6

Published

🚀 开箱即用的 uni-app Vite 插件集,提供完整的开发体验

Readme

@univa/core

🚀 开箱即用的 uni-app Vite 插件集,提供完整的开发体验

npm downloads bundle size license

特性

  • 📦 开箱即用 - 零配置即可开始开发
  • 🎯 自动导入 - 自动导入 Vue、uni-app API
  • 🧩 组件自动注册 - 自动注册组件,无需手动 import
  • 📄 页面管理 - 增强的页面配置和管理
  • 🎨 布局系统 - 灵活的布局系统
  • 🎭 UnoCSS - 即时按需原子化 CSS 引擎
  • 📱 自定义 TabBar - 支持自定义 tabBar 配置
  • 🌳 根组件 - 自动创建和管理根组件

安装

# npm
npm install @univa/core

# pnpm
pnpm add @univa/core

# yarn
yarn add @univa/core

快速开始

1. 配置 Vite

vite.config.ts 中使用:

import { Univa } from '@univa/core'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    Univa(),
  ],
})

2. 配置 TypeScript

tsconfig.json 中添加类型支持:

{
  "compilerOptions": {
    "types": [
      "@univa/core/client"
    ]
  }
}

功能详解

自动导入

自动导入 Vue、Pinia、uni-app 等 API,无需手动 import:

// 无需 import,直接使用
const count = ref(0)
const router = useRouter()
const store = useStore()

自动扫描目录

  • src/hooks/** - 自动导入 hooks
  • src/store/** - 自动导入 store
  • src/constants/** - 自动导入常量

组件自动注册

自动注册 components 目录下的组件,无需手动 import:

src/
├── components/
│   ├── MyButton.vue
│   └── common/
│       └── Icon.vue
└── components-biz/
    └── Card.vue

在页面中直接使用:

<template>
  <MyButton />
  <Icon />
  <BizCard />
</template>

特性

  • components/common/ 是全局命名空间,不添加前缀
  • components-biz/ 会自动添加 Biz 命名空间前缀
  • 自动生成类型声明文件

页面管理

定义页面配置

方式 1:在 pages.config.ts 中定义

// pages.config.ts
import { definePagesConfig } from '@univa/core'

export default definePagesConfig({
  tabBarMode: 'CUSTOM', // 'NONE' | 'NATIVE' | 'CUSTOM'
  tabBar: {
    list: [
      {
        pagePath: 'pages/index',
        text: '首页',
        iconPath: 'images/tabbar/home.png',
        selectedIconPath: 'images/tabbar/home_selected.png',
      },
    ],
  },
})

方式 2:在 vite.config.ts 中直接定义

// vite.config.ts
import { Univa } from '@univa/core'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    Univa({
      pages: {
        config: {
          tabBarMode: 'CUSTOM',
          tabBar: {
            list: [
              {
                pagePath: 'pages/index',
                text: '首页',
              },
            ],
          },
        },
      },
    }),
  ],
})

获取 Pages 配置

在组件中获取 Pages 配置:

import { pages, subPackages, tabBar } from 'virtual:univa-pages'

if (tabBar) {
  console.log(tabBar.list) // TabBar 列表
}

类型支持:确保在 tsconfig.json 中添加了 @univa/core/client 类型,以获得 virtual:univa-pages 的类型提示。

UnoCSS 预设

内置 UnoCSS 预设,提供开箱即用的原子化 CSS:

内置预设

  • presetUni() - uni-app 专属预设
  • presetIcons() - 图标预设(scale: 1.2)
  • presetLegacyCompat() - 兼容性预设(处理低端安卓机)

内置快捷方式

| 快捷方式 | 展开后 | |---------|--------| | border-s | border border-solid | | wh-full | w-full h-full | | f-c-c | flex justify-center items-center | | f-col-c | flex-col justify-center items-center | | flex-items | flex items-center | | flex-justify | flex justify-center | | flex-col | flex flex-col |

安全区域规则

<div class="p-safe">安全区域内边距</div>
<div class="pt-safe">顶部安全区域</div>
<div class="pb-safe">底部安全区域</div>

根组件

自动创建和管理 App.univa.vue 根组件:

<script setup lang="ts">
</script>

<template>
  <UnivaPageMeta background-color="#ff0000" page-style="color: green" />
  <view class="container">
    <UnivaRootView />
  </view>
</template>

特性

  • 自动创建根组件文件
  • 支持虚拟节点(virtualHost
  • 支持全局 ref
  • 支持 <UnivaPageMeta> 组件配置页面元信息
  • 支持 <UnivaRootView /> 组件作为根视图

Manifest 配置

vite.config.ts 中直接配置 manifest:

import { Univa } from '@univa/core'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    Univa({
      manifest: {
        name: 'my-app',
        appid: '__UNI__XXXXXX',
        description: 'My Application',
        versionName: '1.0.0',
        versionCode: '100',
      },
    }),
  ],
})

配置选项

import type { UnivaUserConfig } from '@univa/core'

const config: UnivaUserConfig = {
  // 自动导入配置(默认 true)
  autoImport: true,

  // 组件自动注册配置(默认 true)
  components: true,

  // 页面配置
  pages: {
    config: {
      // TabBar 模式:'NONE' | 'NATIVE' | 'CUSTOM'
      tabBarMode: 'NATIVE',
      tabBar: {
        color: '#A6A6A6',
        selectedColor: '#003594',
        list: [
          {
            pagePath: 'pages/index',
            text: '首页',
            iconPath: 'images/tabbar/home.png',
            selectedIconPath: 'images/tabbar/home_selected.png',
          },
        ],
      },
      // 全局样式配置
      globalStyle: {
        navigationBarBackgroundColor: '#000000',
        navigationBarTextStyle: 'black',
        navigationBarTitleText: 'My App',
        navigationStyle: 'custom',
        enablePullDownRefresh: false,
        onReachBottomDistance: 50,
        animationType: 'pop-in',
        animationDuration: 300,
      },
    },
    // 排除的页面
    exclude: ['pages/exclude/**'],
    // 分包配置
    subPackages: ['pages-sub'],
  },

  // 根组件配置(默认 true)
  appRoot: true,

  // Manifest 配置
  manifest: {
    name: 'my-app',
    appid: '__UNI__XXXXXX',
    description: 'My Application',
    versionName: '1.0.0',
    versionCode: '100',
  },
}

依赖

本包集成了以下优秀的插件:

  • @uni-helper/plugin-uni - uni-app Vite 插件
  • @uni-helper/vite-plugin-uni-components - 组件自动注册
  • @uni-helper/vite-plugin-uni-pages - 页面管理
  • @uni-helper/vite-plugin-uni-layouts - 布局系统
  • unplugin-auto-import - 自动导入
  • unocss - 原子化 CSS 引擎
  • @univa/root - 根组件管理
  • @univa/manifest - manifest 配置
  • @uni-ku/bundle-optimizer - 打包优化
  • vite-plugin-uni-polyfill - Polyfill

致谢

  • 感谢 uni-helper 社区提供的优秀插件
  • 感谢 uni-ku 提供的优秀插件

License

MIT

Contact

📧 Email: [email protected]