@advwebrec/grainloading 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,17 +13,81 @@ New TypeScript consumers should use `YuriRTCClient` and `YuriRTCConfig`.
13
13
  `LoaderClient` and `LoaderConfig` remain compatibility aliases for existing
14
14
  integrations.
15
15
 
16
- The loader implements YuriRTC wire protocol v3. It keeps one interactive
17
- channel open, opens three asset channels only while needed, uses 128 KiB frames,
18
- streams Fetch request bodies through transferable streams, and bounds both
19
- directions with consumption-driven credits. A loader that changes the wire
20
- version must be published only after a compatible content node is deployed.
16
+ The loader implements YuriRTC wire protocol v3. It negotiates the interactive
17
+ lane first, then establishes all four lanes before the initial application
18
+ waterfall. Lanes 1-3 retire after 15 seconds without asset work and reopen on
19
+ demand. The transport uses 128 KiB frames, streams Fetch request bodies through
20
+ transferable streams, and bounds both directions with consumption-driven
21
+ credits. A loader that changes the wire version must be published only after a
22
+ compatible content node is deployed.
23
+
24
+ Lane 0 carries navigations, API/mutation traffic, and carried WebSockets. Lane
25
+ 1 is reserved for small render-critical scripts, styles, fonts, and documents.
26
+ Normal and incremental assets use lanes 2 and 3 with one active start per lane
27
+ and FIFO admission, so a large game payload cannot occupy every ordered stream
28
+ ahead of bootstrap files. The lanes share one ICE/DTLS/SCTP association and
29
+ congestion window; they separate scheduling and SCTP stream ordering rather
30
+ than creating four network connections.
21
31
 
22
32
  When a restarted worker discovers several controlled tabs, the first completed
23
33
  attachment becomes the carrier and later responders remain live standbys. Wake
24
34
  discovery never crosses into pages still controlled by a predecessor worker, so
25
35
  an in-place upgrade cannot cancel that older worker's valid transfers.
26
36
 
37
+ Without an unexpired session preference, the loader connects ordinary ICE and
38
+ forced TCP in parallel. Once both are ready, each receives the same private,
39
+ incompressible 1 MiB probe. TCP is selected only when it is at least 15 percent
40
+ faster; if only one route connects, that route is used. An older node that does
41
+ not return the exact probe marker safely leaves ordinary ICE selected. The
42
+ result is remembered for ten minutes and cleared after a network change.
43
+
44
+ On a selected UDP route, the page aggregates response bytes across concurrent
45
+ GETs after the first body frame arrives. If at least 8 MiB over at least four
46
+ seconds remains below 15 Mbit/s, it warms one TCP-only connection without
47
+ detaching UDP. Once TCP is ready, new requests use it while existing HTTP
48
+ requests and carried WebSockets drain on their original route; the predecessor
49
+ is retired only after that drain. A failed warm-up leaves the working UDP route
50
+ untouched. The thresholds can be tuned, or the behavior disabled, without
51
+ changing the wire:
52
+
53
+ ```ts
54
+ transport: {
55
+ adaptiveTcp: {
56
+ enabled: true,
57
+ minBytes: 8 * 1024 * 1024,
58
+ minSampleMs: 4_000,
59
+ maxGoodputMbps: 15
60
+ }
61
+ }
62
+ ```
63
+
64
+ Candidate filtering uses standard SDP and `RTCIceCandidateInit` data and does
65
+ not patch browser APIs, so the baseline and forced-route paths remain usable in
66
+ Chrome, Firefox, and Safari. Browsers that cannot report a selected pair keep
67
+ ordinary ICE behavior and simply skip the optional goodput recommendation.
68
+
69
+ A self-contained carrier may set `recovery.clientUrls` to durable module URLs.
70
+ The loader persists those ahead of its own `import.meta.url` and the two npm CDN
71
+ fallbacks, allowing service-worker-injected documents to recover from a
72
+ same-origin `client.js` even when the first client was imported from a temporary
73
+ inline Blob.
74
+
75
+ For eligible complete static GET responses, a capable browser sends
76
+ `x-yurirtc-accept-wire-encoding: gzip`; the node marks compressed transport
77
+ bytes with `x-yurirtc-wire-encoding: gzip`. These are private YuriRTC hop
78
+ headers, not HTTP `Accept-Encoding` or `Content-Encoding`, and the loader strips
79
+ them after decompression. Browsers without `DecompressionStream("gzip")` omit
80
+ the capability. Range, API, SSE, already-compressed media, and `no-transform`
81
+ responses remain unencoded.
82
+
83
+ The service worker also gives unknown static paths conservative, bounded cache
84
+ reuse instead of assuming EDUrocks-specific names. It sends `If-None-Match`
85
+ and `If-Modified-Since` for stored validator-backed responses, combines a 304
86
+ with the stored body, and can use that body as an offline fallback. It never
87
+ admits authenticated, ranged/partial, event-stream, `no-store`, `private`, or
88
+ `Vary: *` responses; a 404, 410, or newly non-storable answer invalidates an
89
+ older fallback.
90
+
27
91
  The font in `dist/assets/rot13.woff` is derived from Google Sans and is licensed
28
92
  under the SIL Open Font License 1.1; its license text is shipped beside it as
29
93
  `dist/assets/OFL.txt`.