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

@bale-web/jet

v1.0.5

Published

Front Jet Modal

Downloads

405

Readme

Jet

Jet 是一个 运行时调度器(Runtime Dispatcher), 负责 意图到页面 的运行时, 它接收高层语义性的 Intent(比如 导航到 /article打开外部 URL), 把 Intent 转成可执行的 ActionModel(或直接交给 handler 去做), 由注册的 ActionDispatcher 执行对应的 handler, handler 返回 Page (或另一个 action), 最终 jet 把这些 Page 提供给 UI层 渲染

实现原理

startApplication(STORES, navigate, user, callback)   ← 应用启动
   ↓
Jet.dispatch(intent)                                 ← 对外统一入口
   ↓
Jet.runtime.dispatch(intent)                         ← 核心调度
   ↓
Dispatcher.dispatch(intent, objectGraph)             ← 分发到具体 controller
   ↓
IntentController.perform(intent, objectGraph)        ← 触发具体 controller 中的 perform 方法
   ↓
metrics.asyncTime                                    ← 记录 dispatch 性能时间
Jet
 ├── dispatch(intent)          ← 对外统一入口
 ├── route(intent)             ← 路由专用入口
 ├── perform(intent)           ← 事件专用入口
 ├── onAction(kind, impl)      ← 注册 action handler
 └── runtime.dispatch(intent)  ← 核心调度
        ↓
     ActionDispatcher.perform(action)

执行过程

  1. 路由
 goto(route)
     ↓
 jet.onRoute(intent)                      ← intent.kind = "RouteUrlIntent" {kind: 'RouteUrlIntent', payload: {route: '/about'}}
     ↓
 jet.dispatch(intent)                     ← 通过 dispatch 转发
     ↓
 runtime.dispatch(intent)                 ← 找到 controller(RouteUrlIntentController), 返回 externalUrlAtion
     ↓
 ActionDispatcher.perform(action)         ← 找到已注册的 handler(externalActionHandler)
      ↓
 externalActionHandler(...)               ← 调用 external-url-action.ts 中注册的处理器
     ↓
 metrics.asyncTime                        ← 记录 dispatch 性能时间
  1. 事件
 perform(intent)
     ↓
 jet.dispatch(intent)                     ← intent.kind = "flowAction" {kind: 'flowAction', payload: {route: '/about'}}
     ↓
 ActionDispatcher.perform(action)         ← 找到已注册的 handler(flowActionHandler)
     ↓
 compoundActionHandler(...)               ← 调用 compound-action.ts 中注册的处理器
     ↓
 metrics.asyncTime                        ← 记录 dispatch 性能时间

使用方法

  1. 在项目中引入根目录下的 bootstrap.tsbrowser.tsglobal.tsprovider.tsx(使用 ReactContext 注入)

  2. 在项目启动时调用 browser.ts 中的 startApplication 方法, startApplication 中可以注入 storesnavigate

    • 使用 ReactContext 注入
    import { startApplication } from './browser'
    import { CONTEXT_NAME, Jet, LoggerFactory } from './jet/export'
    import { AppProvider, AppContextValue } from './provider'
    import { STORES } from './stores'
    
    const navigate = useNavigate()
    const [appValue, setAppValue] = useState<AppContextValue>({
      context: new Map(),
      logger: console,
      jet: undefined
    })
    
    useEffect(() => {
      startApplication(STORES, navigate, {}, (context: Map<string, unknown>, logger: LoggerFactory) => {
        const jet = context.get(CONTEXT_NAME) as Jet
        setAppValue({
          context,
          logger,
          jet
        })
      })
    }, [])
    
    return <AppProvider value={appValue}>{/* */}</AppProvider>
    • 普通注入
    import { startApplication } from './browser'
    import { STORES } from './stores'
    const navigate = useNavigate()
    
    useEffect(() => {
      startApplication(STORES, navigate, {}, () => {})
    }, [])
  3. ReactContext 中获取 jetcontext

import { AppContext } from '../provider'
import { getUniqueIdGenerator } from '@bale-web/jet/export'

const { jet: Jet, context } = useContext(AppContext)

// 页面 Id
const [pageId, setPageId] = useState('')

setPageId(getUniqueIdGenerator(context)())
  1. 普通获取 jetcontext
import { getJet, getContext } from './global'

const Jet = getJet()
const Context = getContext()
  1. 使用
// 路由
Jet?.route({
  $kind: 'RouteUrlIntent',
  payload: {
    route: '/xxx',
    replace: false
  }
})

// 事件
Jet?.perform(makeFlowIntent('/xxx', { id: 'xxx' }))

// 请求
await Jet()?.services.NetworkService?.request({ id: 'xxxx' })

// Stores
await Jet?.services.StoreService.xxxStore.xxx()