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

webwindowui-bridge

v0.1.7

Published

WebWindowUI 前后端 protobuf 双向绑定桥(Vue + WebView2 / WebKitGTK / WKWebView)。

Readme

webwindowui-bridge

WebWindowUI 前后端 protobuf 双向绑定桥(Vue3 + WebView2 / WebKitGTK / WKWebView / CEF)。纯 TS,peerDependencies = vue ^3.2 + protobufjs ^7.6。已发布到 npm(当前 0.1.6)。

用法

前端工程 npm install webwindowui-bridge,在窗口页里:

import { bindModel } from 'webwindowui-bridge'
import generatedJson from '../bridge/main_window_model.json' // 生成器产出的完整模型 descriptor(信封已内联、自包含)

const model = bindModel({ title: '' }, generatedJson)

每个模型实例调用一次。TS 模型镜像(生成器产出)在文件末尾封装 bindXxx() 绑定助手(含 descriptor import)。

组成

| 文件 | 职责 | |------|------| | channel.ts | 平台自适应消息通道:WebView2(chrome.webview)/ WebKitGTK、WKWebView(window.webkit.messageHandlers.wwui)/ CEF(同源 app://<host>/__wwui 的 fetch POST)。发送通道每次重新探测(WebKitGTK 把 script message handler 同步进 web 进程有延迟,模块作用域一次性解析缓存会永远拿 null);下行回调经 window.wwuiReceive / chrome.webview 'message' 事件 | | codec.ts | NUL 转义 Latin-1 载荷(WebView2 消息通道在 NUL 处截断,protobuf 字节普遍含 0x00,须转义无损通过;WebKit/WKWebView 一并统一) | | value.ts | ModelValue 值树 ↔ JS 值转换(modelValueToJs/jsToModelValue_modelInstanceId 不可枚举收敛) | | protocol.ts | 信封类型常量(WebMessage oneof 成员、CollectionPatch action)+ ModelCommandHost 基类(承载 _commandChannel 契约,命令模型继承;桥用 Object.defineProperty 注入不可枚举 _commandChannel) | | bind-model.ts | bindModel(model, generatedJson):Vue reactive + watch 双向绑定、深 watch 回写、typed-repeated 元素级(构建期烘焙 __repeatedFields)、集合差量 applyPatch 原地 splice、实例 ID 防串守卫 | | index.ts | 导出入口 |

协议要点

  • 无消息名modelId = 完整消息名 FNV-1a 哈希、commandId = [RelayCommand] 声明序(.NET 与 TS 两侧同函数产出)。
  • 消息流:.NET → JS full(初始快照)/snapshot(通用回退)/update(单属性增量)/patch(集合差量);JS → .NET ready/set(回写,含元素级)/invoke(命令)。
  • modelInstanceId(信封级 int64):桥从首个 full/snapshot 捕获为不可枚举 model._modelInstanceId(不进 Object.keys watch 循环),对后续消息防串守卫(窗口换绑后旧实例在途消息丢弃,0 = 旧桥容忍)。

durable 坑

  • 协议契约一律构建期定死为字符串字面量:typed-repeated 的字段表烘焙成模型镜像类 static ['__repeatedFields'](字符串字面量键)。不要用运行时 constructor.namelookupType 反射取元素字段表——Release minified bundle(vite 8 / rolldown)会把 class 绑定名改名,typed-repeated 补丁退化成序数键挂掉。
  • 元素级 patch.elementInstanceId 是 protobufjs Long,与元素 _modelInstanceId(JS number)比较须先 normalize()(→toNumber),直接 === 恒 false → 元素级补丁静默不落。
  • 结构回写(push/splice/替换 → 整列 ModelSet)须给每个元素补 _modelInstanceIdsendElementList),否则 .NET 按 Clear+Add 重建、元素实例全换新、旧 id 失效。
  • 本地调试:纯浏览器场景无通道,postMessage 返回 false,不发不崩。

升级/本地迭代

  • 升级:npm install webwindowui-bridge@^0.1.6,升级后 touch vite.config.ts 强制 vite 重建。
  • 未发布的本地桥迭代:物理拷进 node_modules/webwindowui-bridge(npm link 符号链接被 rolldown 解析到真实路径、无依赖报 Failed to resolve import "protobufjs")+ touch vite.config.ts 强制重建,再 grep bundle 验证。桥是 code-split 的(bind-model-*.js 大 chunk),grep main-*.js 查不到桥逻辑、须 grep bind-model-*.js