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

akey-core-web

v1.0.2

Published

Chathoo Web 端核心 SDK,封装浏览器端基础能力

Readme

akey-core-web

Chathoo Web 端核心 SDK:提供 Go WebAssembly 运行时(Go 1.19.x wasm_exec)注入、wasm 加载/启动封装,以及对 wasm 导出的全局函数的统一调用封装。

安装

yarn add akey-core-web

使用

1) 初始化整个 SDK(推荐)

import { initWebSdk } from 'akey-core-web'
import wasmUrl from 'akey-core-web/wasm/core.wasm?url'
import workerUrl from 'akey-core-web/worker/jsstore.worker.min.js?url'

const coreConfig = {
	// ... CoreSDKConfig
}

const [err] = await initWebSdk({
	coreConfig,
	// 由构建工具(如 Vite)在构建时把 wasm 复制到你的产物目录,并返回改写后的 URL
	wasmUrl,
	// 同上:由构建工具在构建时把 worker 复制到你的产物目录,并返回改写后的 URL
	workerUrl,
	// 会被挂载到 window.CoreListenerOn
	CoreListenerOn: (...args) => {
		console.log('CoreListenerOn', ...args)
	}
})

if (err) {
	console.error('initWebSdk failed', err)
}

// 也支持位置参数形式:initWebSdk(coreConfig, wasmUrl, workerUrl, CoreListenerOn)
await initWebSdk(coreConfig, wasmUrl, workerUrl, (...args) => {
	console.log('CoreListenerOn', ...args)
})

2) 仅初始化 SDK 内部功能(不加载 wasm)

import { initCoreSDK } from 'akey-core-web'

const [err, data] = initCoreSDK({
	// ... CoreSDKConfig
})

资源文件复制(可选快捷方式)

如果你的工程不支持通过 ?url 引入 wasm/worker,或者你希望把资源文件直接拷贝到自己的产物/静态目录中,可以使用本包自带的 CLI:

# 把本包的 dist/public/* 复制到你项目的 ./public 目录
npx akey-core-web copy-public ./public

# pnpm
pnpm dlx akey-core-web copy-public ./public

维护:新增类型/接口导出流程

有些能力的“实现”在 wasm/core 或 SDK 内部,这个包只负责把每个方法的接口(类型)提供给使用方查看与校验。推荐按下面流程新增并导出类型(不会引入任何运行时代码):

  1. src/ 下新增/维护类型文件
  • 推荐集中放在 src/sdk/apiTypes.ts(只写 export type / export interface
  • 文件内如果需要引用别的类型,用 import type { ... } from '...'
  1. 在公共入口重新导出(type-only 导出)
  • src/index.ts 使用 export type { Xxx } from './sdk/apiTypes'
  • 只导出类型:不要在这个类型文件里写 export const/let/function/class 之类的值导出
  1. 构建并验证声明文件
npm run build

构建完成后,确认:

  • dist/index.d.ts 中包含你新增的 export type { ... }
  • 对应的类型声明文件已生成(例如 dist/sdk/apiTypes.d.ts
  1. 使用方如何查看这些接口类型
import type { WebSdkWindowApi } from 'akey-core-web'

// 仅用于类型提示(不会产生运行时代码)
const api = window as unknown as WebSdkWindowApi

注意

  • 本 SDK 假设运行在浏览器/具备 DOM 的环境中,且需要:crypto.getRandomValuesperformance.nowTextEncoderTextDecoder
  • Go wasm 通常是“常驻运行”,initWebSdk/initCore 默认不会 await go.run()(避免阻塞)。