@cplieger/web-terminal-ui 6.1.2 → 6.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cplieger/web-terminal-ui",
3
- "version": "6.1.2",
3
+ "version": "6.1.3",
4
4
  "type": "module",
5
5
  "description": "Reference touch-first browser UI for @cplieger/web-terminal-engine: a composable kernel + feature modules (tabs, activity monitor, mobile toolbar, context menu, IME, predictive echo, viewport handling) and CSS. One createTerminal() call.",
6
6
  "license": "MPL-2.0",
@@ -56,7 +56,7 @@
56
56
  "eslint": "10.8.1",
57
57
  "fast-check": "4.9.0",
58
58
  "happy-dom": "20.11.2",
59
- "html-validate": "11.6.2",
59
+ "html-validate": "11.7.0",
60
60
  "knip": "6.32.2",
61
61
  "prettier": "3.9.6",
62
62
  "stylelint": "17.14.1",
@@ -152,7 +152,13 @@ export interface TabsOptions {
152
152
  *
153
153
  * Not every platform honours it: Safari caches the first icon it fetched and
154
154
  * ignores later changes, and an installed app has no tab icon at all. The
155
- * title count is not gated on this, so those cases lose nothing. */
155
+ * title count is not gated on this, so those cases lose nothing.
156
+ *
157
+ * The links are restored on `pagehide` as well as on teardown, because a
158
+ * browser remembers one icon per URL and renders it for the bookmark, the
159
+ * history row and the new-tab tile. Best-effort there, since the write races
160
+ * the unload. Deliberately not on `freeze`: a frozen background tab is still in
161
+ * the strip rendering its icon, which is the case this exists for. */
156
162
  attentionIcons?: boolean;
157
163
  }
158
164
 
@@ -601,6 +607,39 @@ export function tabs(opts: TabsOptions = {}): TerminalFeature<TabsApi> {
601
607
  }
602
608
  document.addEventListener("visibilitychange", onPageVisible);
603
609
 
610
+ // onPageGone hands the page's own icon back before the page GOES AWAY,
611
+ // which is a different question from the page being hidden and needs a
612
+ // different event. A browser remembers ONE icon per URL and renders it for
613
+ // the bookmark, the history row and the new-tab tile, so a tab closed while
614
+ // a cue was lit leaves a status variant standing in for the app until the
615
+ // page is next loaded.
616
+ //
617
+ // `pagehide`, and deliberately NOT `freeze`. freeze fires for a background
618
+ // tab the browser is conserving resources on (Android after five minutes in
619
+ // the background; desktop for a collapsed tab group and, since Chrome 133, a
620
+ // CPU-heavy tab under Energy Saver), and that tab is STILL in the strip
621
+ // rendering its icon — restoring there would blank the cue in exactly the
622
+ // case the cue exists for. pagehide fires on unload, tab close and bfcache
623
+ // entry, where no strip entry is left to render.
624
+ //
625
+ // Through apply() rather than the icon sink directly, because the sinks are
626
+ // change-gated on the last applied value: writing behind that memo would
627
+ // leave it believing the variant is still up, and a page restored from the
628
+ // bfcache would then never repaint it. Which is what onPageBack is for — a
629
+ // bfcache restore re-runs the fold, so the cue returns for a page that did
630
+ // not actually go away. Best-effort on a real unload, where the icon write
631
+ // races the teardown, and a no-op when nothing was lit.
632
+ function onPageGone(): void {
633
+ attention.apply(NO_ATTENTION);
634
+ }
635
+ function onPageBack(event: PageTransitionEvent): void {
636
+ if (event.persisted) {
637
+ paintAttention();
638
+ }
639
+ }
640
+ window.addEventListener("pagehide", onPageGone);
641
+ window.addEventListener("pageshow", onPageBack);
642
+
604
643
  // paintAttention re-derives the whole attention state from the tab list and
605
644
  // this viewer's acknowledgements, and hands it to the surfaces.
606
645
  //
@@ -4115,6 +4154,8 @@ export function tabs(opts: TabsOptions = {}): TerminalFeature<TabsApi> {
4115
4154
  offMenuKey();
4116
4155
  document.removeEventListener("click", onDocClickMenu);
4117
4156
  document.removeEventListener("visibilitychange", onPageVisible);
4157
+ window.removeEventListener("pagehide", onPageGone);
4158
+ window.removeEventListener("pageshow", onPageBack);
4118
4159
  document.removeEventListener("contextmenu", onDocContextMenu);
4119
4160
  document.removeEventListener("pointerup", onDocTapDismiss, true);
4120
4161
  document.removeEventListener("dragover", onDocTabDrop);