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

@liu_jimmy/blocks-compiler

v1.1.5

Published

Compile BlockSpec to Vue/React/Svelte source. Part of fe-kit AI Code Cache.

Readme

@liu_jimmy/blocks-compiler

BlockSpec 编译为 Vue / React / Svelte 组件源码,仅使用 fe-kit 语义类(bg-bgtext-fgborder-borderbg-primaryrounded-xl 等)。fe-kit AI Code Cache 的编译层。

安装

pnpm add @liu_jimmy/blocks-spec @liu_jimmy/blocks-compiler

API

compile(spec, framework, options?)

  • spec: 符合 block.v1 的 BlockSpec(对象即可,内部会校验)
  • framework: 'vue' | 'react' | 'svelte'
  • options: 可选,如 { componentName?: string }
  • 返回: 组件源码字符串(.vue / .tsx / .svelte 文件内容)

编译前会调用 assertBlockSpec(spec),不符合 schema 会抛错。

按框架的编译函数

  • compileToVue(spec) → Vue SFC 字符串
  • compileToReact(spec) → React TSX 字符串
  • compileToSvelte(spec) → Svelte 组件字符串

当前支持的块

| name | variant | 说明 | |--------|-----------|------| | hero | split | 标题、副标题、主/次 CTA | | faq | accordion | 标题 + 手风琴列表 | | footer | default | 版权 + 链接列表 |

未支持的 name/variant 会走通用占位模板(展示 props JSON)。

示例

import { compile } from "@liu_jimmy/blocks-compiler";
import heroSpec from "@liu_jimmy/blocks-spec/registry/hero.spec.json";

const vueSource = compile(heroSpec, "vue");
const reactSource = compile(heroSpec, "react");
const svelteSource = compile(heroSpec, "svelte");
// 可将 vueSource 写入 .vue 文件,在已接入 fe-kit preset 的项目中直接使用

带缓存的编译(测是否命中)

import { compileWithCache, cacheKey } from "@liu_jimmy/blocks-compiler";
import { memoryCache } from "@liu_jimmy/fe-kit-cache";
import heroSpec from "@liu_jimmy/blocks-spec/registry/hero.spec.json";

const r1 = compileWithCache(heroSpec, "vue", memoryCache);
console.log(r1.fromCache); // false,首次编译

const r2 = compileWithCache(heroSpec, "vue", memoryCache);
console.log(r2.fromCache); // true,从缓存读取
  • 传入任意实现 BlockCache(get/set)的对象即可;可用 @liu_jimmy/fe-kit-cachememoryCachecreateMemoryCache()
  • 缓存 key 仅含 name + variant + framework,不含 props,便于同结构命中。

依赖

  • @liu_jimmy/blocks-spec:类型与校验
  • 生成的项目需使用 Tailwind v3 + @liu_jimmy/fe-kit-tailwind-preset,才能正确解析语义类。