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 🙏

© 2025 – Pkg Stats / Ryan Hefner

webapp-core

v1.0.41

Published

webapp

Downloads

262

Readme

基于模块和应用的方式构建web应用

Get Started

    <script src="webapp-core.js"></script>

Module

Module继承Injector

  1. 创建模块 system,system.js
    var Module = HERE.FRAMEWORK.Module;
    Module.module('system',function(){
        this.resource = {
            js:[],//模块依赖的js
            css:[],//模块依赖的css
            langFiles:[]//模块依赖的多语文件,json格式
        };
    });
  1. 获取模块
    var system = Module.module('system');
  1. 定义模块service、factory、variable、provider
    Module.module('system').service('userService',function(){
        this.getUserInfo = function(){
            return {
                userName:'admin'
            };
        };
    });
    //获取service
    var userService = Module.module('system').getService('userService');
    var userInfo = userService.getUserInfo();
  1. 模块依赖,search.js,模块可以依赖一个或多个模块
    Module.module('search',function(){
        
    },'system');
    //或
    Module.module('search',function(){
            
    },['system']);
     //search service 中自动注入了system模块中定义的userService
     Module.module('search').service('searchService',['userService',function(userService){
     
        this.search = functtion(){
            
        };
     }]);
     var userService = Module.module('search').getService('userService');
     var searchService = Module.module('search').getService('');

Application

Application继承Module

  1. 创建Application
    Application.app('user',function(){
        
    });
  1. 获取应用
    var user = Application.app('user');
  1. 应用依赖,应用可以依赖应用和模块
    //依赖search模块和user应用
    Application.app('data',function(){},'search','user');

Register

用来注册模块和应用

  1. 注册模块,模块使用前首先需要注册模块
    var Register = HERE.FRAMEWORK.Register.getInstance();
    //第一个参数为模块名,第二个参数为模块声明文件
    Register.registerModule('system','system/index.js');
    //或
    Register.registerModule({
        name:'system',
        url:'system/index.js'
    });
    //注册多个模块
    Register.registerModule([{
        name:'system',
        url:'system/index.js'
    },{
        name:'search',
        url:'search/index.js'
    }]);
  1. 模块加载,模块使用前需要先加载模块,模块会加载依赖资源以及依赖模块的资源
    Module.module('system').load().then(function(){
        
    });
  1. 注册应用
    Register.registerApp('user','user/index.js');
  1. 应用加载
    Module.module('user').load().then(function(){
            
    });