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

overload-cli

v1.0.1

Published

A simple cli for skeleton

Downloads

3

Readme

overload-cli

一个生成骨架屏的 cli

快速开始

sudo npm install -g puppeteer --unsafe-perm=true
sudo npm install -g overload-cli
sudo overload-cli start skeleton.config.js

About skeleton.config.js

interface SkeletonConfigRoute {
  path: string; // 页面路径
  query?: { [props: string]: string }; // 访问当前页面需要拼接的页面参数
  clip?: { // skeleton 生成时的截取视口
    x: number;
    y: number;
    width: number;
    height: number;
  };
  cookies?: SkeletonConfigCookie[]; // 访问当前页面需要带的 cookie
  excludes?: string[]; // 生成 skeleton 时,页面上需要过滤(不显示在 skeleton 中)的元素(填 className)
  focusTag?: { // 生成 skeleton 时,页面上部分需要强行使用其他元素的转化模式的元素(ex:<p> 标签实现了 <button> 的样式,正常情况下 cli 只会识别它为文本,并转化为文本的样式,这时就需要把当前 <p> 元素的 className 填入下述 singleBlock 的数组中,来生成正确的 <button> 样式的 skeleton)
    singleBlock?: string[];
  };
}

interface SkeletonConfig {
  isMobile?: boolean; // true 表示 h5 端,false 表示 pc 端(默认为 true)
  rootID: string; // 需要生成的根结点 id
  originUrl: string; // 应用根地址
  routes: SkeletonConfigRoute[]; // 应用的不同页面规则 
  routeMode?: 'hash' | 'history'; // 应用路由模式,默认 hash
}

const skeletonConfig: SkeletonConfig = {};
module.exports = skeletonConfig;

config 示例

module.exports = {
  isMobile: true,
  rootID: 'root',
  originUrl: 'https://a.com/test/dist/',
  routeMode: 'hash',
  routes: [
    {
      path: '/about',
      query: { im: 'about' },
    },
    {
      path: '/home',
      query: { im: 'home' },
      cookies: [
        { name: 'uid', value: '1234', domain: 'a.com' },
      ],
    }
  ],
};

最终产物

在当前 cli 运行目录下,会新建一个「overload-cli-output」的文件夹,包含如下内容:

  • runtime-script.html:内容可以直接全量复制,放置到我们自己应用的 html 文件的 root 根结点中,用来针对 「html 返回后」 - 「script解析完毕,对 root 元素内容进行 render」之间 时间段的页面占位;
  • 如果需要针对 「发起接口请求」-「业务数据返回,render 到页面完毕」之间 时间段进行页面占位,使用 runtime-script 肯定不合时宜,可以直接使用对应页面的 jpeg 图片;