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

dart-skeleton

v0.0.3

Published

快速骨架屏片段生成器

Downloads

5

Readme

dart-skeleton

项目结构图:

项目由如图三块内容组成分别是:脚本,逻辑,CLI。 image.png

🥝脚本:

主要的功能就是对目标页面进行分析对指定的元素进行绘制为灰色块,并按条件跳过指定的干扰元素。因为我们的使用是在浏览器中所以在编译Ts的代码的时候我们将targetmodule分别设置成了es5es2015,为了方便逻辑块的调用我们没有导出函数而是直接挂在到window对象上。调试本地html文件的话可以直接将编译后的Js引入页面,当我们需要调试在线的一些页面的话可以在浏览器的开发者工具=>Sources=>Snippets中新建一个片段将我们编译后的Js放进去,直接Run来执行。

🥦逻辑:

主要的功能是使用**Puppeteer**来加载目标页面,并执行我们第一阶段调试的脚本,最终导出骨架片段并插入目标页面。逻辑块的代码由于我们后续想通过CLI的方式在Node环境执行,所以编译成了CommonJS模块。需要特殊记录一下的是脚本注入后的执行函数,如下:

// 执行脚本获取生成的html片段
html = await page.evaluate((res) => {
	return window.evalDOMScripts.apply(window, res);
}, opts);

🍦CLI:

这块的功能相对简单,主要是通过命令行的方式来收集用户的输入信息,构建初始化配置文件和执行逻辑部分导出的启动函数。

使用说明:

🍕构建说明:

  1. 全局安装Typescript,调试代码推荐一起安装ts-node:yarn global add typescript ts-node
  2. 安装项目配置的依赖:yarn

🍿脚本&源码编译:

  1. 编译脚本文件:yarn build:script
  2. 编译源码文件:yarn build:source

🥗链接模块到本地NPM:

  1. 建立连接命令:npm link
  2. 反建立连接命令:npm unlink

注:目前无法发布到NPM仓库,提示原因是由于模块的版本或依赖的版本存在低于1.2的情况,不再允许添加到NPM的注册表,稳定的项目有效的托管的话挺不错,练手的就别提交上去浪费资源了🤣。

🍝CLI使用说明:

  1. 初始化配置文件:ds init
  2. 执行生成函数:ds start

演示效果:

手机版百度页面:

image.pngimage.png

手机版京东页面:

image.pngimage.png

手机版哔哩哔哩页面:

image.pngimage.png