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

asai-js-as

v0.2.10

Published

asai for you

Readme

asai-js-as — 通信与模型加载核心

包信息

| 建议 npm 名 | 入口文件 | $fn / 注入键 | 类型 | |------------|---------|-------------|------| | @estun/asai-js-as | AsaiJsAs.ts / src/index.ts | AsaiWorker AsaiApi AsaiWs AsaiModel(展开 4 键) | Feature |

概述

asai-js-as 是前端引擎的通信与数据层插件,聚合 Worker 任务池、HTTP API、WebSocket 与 webmodel 静态模型加载。通过 App.vue 展开注入 $fn,供 Host 与各业务模块使用。

集成方式

// monorepo — webclient/src/App.vue
import AsaiJsAs from './plugs/asai-js-as/AsaiJsAs';
// npm
// import AsaiJsAs from '@estun/asai-js-as';

useProvide({
  plugs: { ...AsaiJsAs },
});

独立性约束

  • 禁止 import 其它 plugs/* 插件。
  • AsaiApi / AsaiWs 依赖 Host 初始化后的 ujt 上下文,通过运行时注入使用,不在本包内引用 host 源码。

主要 API / 导出

| 导出 | 说明 | |------|------| | AsaiWorker | Web Worker 任务队列,按 CPU 核心数限并发 | | AsaiApi | HTTP fetch 封装(需 ujt) | | AsaiWs | WebSocket 连接与 wsApi(需 ujt) | | AsaiModel | webmodel 目录递归加载到 $model | | deonmessage | src/ws-message-filter.ts,WS 消息过滤(按需 import) |

性能说明

  • 首屏同步注册,体积相对可控(无大型 UI chunk)。
  • AsaiWorker:每任务独立 Worker,完成后 terminate,适合短任务 burst;长驻计算请自建 Worker 池。
  • 大数据 postMessage 注意结构化克隆开销,可考虑 Transferable。

peerDependencies 建议

{
  "peerDependencies": {
    "vue": "^3.4.0"
  }
}

模块说明

| 模块 | 文件 | 职责 | |------|------|------| | AsaiWorker | src/AsaiWorker.ts | Web Worker 任务队列 | | AsaiApi | src/AsaiApi.ts | HTTP 封装 | | AsaiWs | src/AsaiWs.ts | WebSocket | | AsaiModel | src/AsaiModel.ts | 静态模型加载 |

文件结构

asai-js-as/
├── AsaiJsAs.ts              # App.vue 聚合导出
├── src/
│   ├── index.ts
│   ├── AsaiWorker.ts / AsaiApi.ts / AsaiWs.ts / AsaiModel.ts
│   └── ws-message-filter.ts
└── README.md

AsaiWorker

构造函数

| 参数 | 类型 | 默认值 | 说明 | |------|------|--------|------| | workerScript | string | — | Worker 脚本 URL | | maxWorkers | number | navigator.hardwareConcurrency \|\| 4 | 最大并发 |

方法

| 方法 | 说明 | |------|------| | execute(taskData) | 提交任务,返回 Promise<any> | | terminateAll() | 终止所有 Worker |

使用示例

const pool = new $fn.AsaiWorker('/workers/compute.js');
const result = await pool.execute({ op: 'hash', data: buffer });

AsaiModel

递归加载 webmodel 配置目录,填充 $ujtasai.$model,与 useProvide$model.webmodels 路由索引配合。

注意事项

  1. Worker 脚本需同源或通过 blob URL 加载。
  2. AsaiApi / AsaiWs 勿在 useProvide 之前调用。
  3. 更多 Host 生命周期见 plugs/README.md