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

pure-frontend

v1.3.4

Published

支持单页面应用的前端框架

Downloads

112

Readme

pure-frontend

解决单页面应用开发中常见的问题,比如不同视图间的样式隔离、JS隔离等。

安装依赖

npm install pure-frontend

添加依赖

依赖 jQuery,Bootstrap v4。

<link href="pure-frontend.css" rel="stylesheet" />
  
<script src="pure-frontend.js" type='text/javascript'></script>

代码示例

比如有这么一段 HTML 代码。

<body>
  ...
  <div class="pure-app">
  </div>
  ...
</body>

加载的视图会渲染到包含 pure-app 样式类名的标签下。

/**
 * @description 加载视图
 * @param {string} url URL字符串
 */
Pure.app.loadView(url);     

/**
 * @description 注册视图的入口函数
 * @param {string} viewName 
 * @param {function} mainFn 
 */
Pure.app.viewMain(viewName, function (scope, view) {
  // 加载完视图后会自动执行该函数
  ...
});

/**
 * @description 调用远程接口
 * @param {string} url 
 * @param {*} [data] 
 * @param {PlainObject} [opts] 
 * @returns {AjaxResult}
 */
Pure.fn.Ajax.callService(url, data, opts);

提供访问视图的方法描述。

class View {
  /**
   * @param {(Document|Element)} viewElement 
   * @param {ViewInfo} viewInfo 
   */
  constructor(viewElement: any, viewInfo: any, viewScope: any);

  /**
   * @description 返回视图对应的 DOM 元素
   * @returns {(Document|Element)}
   */
  getViewElement(): any;

  /**
   * @description 返回视图信息
   * @returns {ViewInfo}
   */
  getViewInfo(): any;

  /**
   * @description 返回视图对应的数据模型
   * @returns {uiData.Model}
   */
  getDataModel(): any;

  /**
   * @description 返回 URL 参数
   * @param {string} name 
   * @returns {string}
   */
  getUrlParam(name: any): any;

  /**
   * @description 查找视图下的指定元素,参数格式与 jQuery.find() 相同
   * @param {...any} args
   * @returns {jQuery}
   */
  $find(...args: any[]): any;

  /**
   * @description 查找视图下的指定元素,通过配置 Global.config.uiNameAttributeName 指定的属性
   * @param {string} name
   * @returns {jQuery}
   */
  $ui(name: any): any;

  ...
}

开源协议

MIT