@advwebrec/grainloading

中文文档
0.5.5发布于 2026/09/28AGPL-3.0-onlyTypeScriptES Module零依赖近 30 天下载 1.2万

YuriRTC browser client and service worker transport.

原始使用文档

YuriRTC browser transport

This package is YuriRTC's browser client and service worker, published as @advwebrec/grainloading. Existing carriers select an immutable version through the separately signed shaintloadingcheckpak pointer.

The published package contains only obfuscated browser bundles, a self-contained type declaration, and the ROT13 display font. Readable TypeScript lives in the YuriRTC source repository. Obfuscation is a distribution deterrent, not a security boundary.

New TypeScript consumers should use YuriRTCClient and YuriRTCConfig. LoaderClient and LoaderConfig remain compatibility aliases for existing integrations.

The loader implements YuriRTC wire protocol v3. It negotiates the interactive lane first, then establishes all four lanes before the initial application waterfall. Lanes 1-3 retire after 15 seconds without asset work and reopen on demand. The transport uses 128 KiB frames, streams Fetch request bodies through transferable streams, and bounds both directions with consumption-driven credits. A loader that changes the wire version must be published only after a compatible content node is deployed.

Lane 0 carries navigations, API/mutation traffic, and carried WebSockets. Lane 1 is reserved for small render-critical scripts, styles, fonts, and documents. Normal and incremental assets use lanes 2 and 3 with one active start per lane and FIFO admission, so a large game payload cannot occupy every ordered stream ahead of bootstrap files. The lanes share one ICE/DTLS/SCTP association and congestion window; they separate scheduling and SCTP stream ordering rather than creating four network connections.

When a restarted worker discovers several controlled tabs, the first completed attachment becomes the carrier and later responders remain live standbys. Wake discovery never crosses into pages still controlled by a predecessor worker, so an in-place upgrade cannot cancel that older worker's valid transfers.

Without an unexpired session preference, the loader connects ordinary ICE and forced TCP in parallel. Once both are ready, each receives the same private, incompressible 1 MiB probe. TCP is selected only when it is at least 15 percent faster; if only one route connects, that route is used. An older node that does not return the exact probe marker safely leaves ordinary ICE selected. The result is remembered for ten minutes and cleared after a network change.

On a selected UDP route, the page aggregates response bytes across concurrent GETs after the first body frame arrives. If at least 8 MiB over at least four seconds remains below 15 Mbit/s, it warms one TCP-only connection without detaching UDP. Once TCP is ready, new requests use it while existing HTTP requests and carried WebSockets drain on their original route; the predecessor is retired only after that drain. A failed warm-up leaves the working UDP route untouched. The thresholds can be tuned, or the behavior disabled, without changing the wire:

transport: {
  adaptiveTcp: {
    enabled: true,
    minBytes: 8 * 1024 * 1024,
    minSampleMs: 4_000,
    maxGoodputMbps: 15
  }
}

Candidate filtering uses standard SDP and RTCIceCandidateInit data and does not patch browser APIs, so the baseline and forced-route paths remain usable in Chrome, Firefox, and Safari. Browsers that cannot report a selected pair keep ordinary ICE behavior and simply skip the optional goodput recommendation.

A self-contained carrier may set recovery.clientUrls to durable module URLs. The loader persists those ahead of its own import.meta.url and the two npm CDN fallbacks, allowing service-worker-injected documents to recover from a same-origin client.js even when the first client was imported from a temporary inline Blob.

For eligible complete static GET responses, a capable browser sends x-yurirtc-accept-wire-encoding: gzip; the node marks compressed transport bytes with x-yurirtc-wire-encoding: gzip. These are private YuriRTC hop headers, not HTTP Accept-Encoding or Content-Encoding, and the loader strips them after decompression. Browsers without DecompressionStream("gzip") omit the capability. Range, API, SSE, already-compressed media, and no-transform responses remain unencoded.

The service worker also gives unknown static paths conservative, bounded cache reuse instead of assuming EDUrocks-specific names. It sends If-None-Match and If-Modified-Since for stored validator-backed responses, combines a 304 with the stored body, and can use that body as an offline fallback. It never admits authenticated, ranged/partial, event-stream, no-store, private, or Vary: * responses; a 404, 410, or newly non-storable answer invalidates an older fallback.

The font in dist/assets/rot13.woff is derived from Google Sans and is licensed under the SIL Open Font License 1.1; its license text is shipped beside it as dist/assets/OFL.txt.

“Google” and “Google Sans” are trademarks of Google LLC. The font is exposed to the shell under the distinct CSS family name YuriRTCDisplay; this project is not endorsed by Google LLC.

版本与发布记录

@advwebrec/grainloading 共发布 5 个版本,首次发布于 2026/08/28;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.5.5latest2026/09/281 个月前
0.5.42026/09/241 个月前
0.5.32026/09/022 个月前
0.5.22026/09/022 个月前
0.5.12026/08/282 个月前

关于 @advwebrec/grainloading 的常见问题

@advwebrec/grainloading 是什么?

YuriRTC browser client and service worker transport.

如何安装 @advwebrec/grainloading?

在项目目录运行 npm install @advwebrec/grainloading,或使用 pnpm add / yarn add / bun add。

@advwebrec/grainloading 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@advwebrec/grainloading 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@advwebrec/grainloading 可以商用吗?

@advwebrec/grainloading 使用 AGPL-3.0-only 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@advwebrec/grainloading 的下载量有多少?

根据 npm 官方下载统计,@advwebrec/grainloading 在 2026/10/05 – 2026/11/03 这 30 天内被下载 12,236 次,日均约 408 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@advwebrec/grainloading 还在维护吗?

最新版本 0.5.5 发布于 2026/09/28(1 个月前);至今共发布 5 个版本,其中过去 12 个月发布了 5 个;首次发布于 2026/08/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。