cursedbelt 6.24.0 → 6.26.0

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.
@@ -12,7 +12,7 @@
12
12
  * many requests met it, and it is over when that host answers again — so the issue is keyed by
13
13
  * host and the next good answer from it resolves it.
14
14
  */
15
- import { isStaleChunkText } from '../lazy/staleChunk.js';
15
+ import { isChunkEvictRequest, isStaleChunkText } from '../lazy/staleChunk.js';
16
16
  import { raiseIssue, recordDiagnostic, resolveIssue } from './issues.js';
17
17
  import { REDACTED_QUERY_KEY, redactQueryValues, redactUrl } from 'cursedbelt-core/redact';
18
18
 
@@ -65,6 +65,8 @@ export function ignoreIssueRequests(match: (url: URL) => boolean): () => void {
65
65
  }
66
66
 
67
67
  function ignoredByKit(url: URL): boolean {
68
+ // The stale-chunk healer's own re-fetches: failing, they are the page leaving (`staleChunk.ts`).
69
+ if (isChunkEvictRequest(url.href)) return true;
68
70
  for (const match of builtInIgnores) if (match(url)) return true;
69
71
  return false;
70
72
  }
@@ -2,6 +2,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, mock, test } from '
2
2
  import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';
3
3
  import { useState } from 'react';
4
4
  import { Button } from '../components/Button.js';
5
+ import { useKeyboardInset } from '../hooks/useKeyboardInset.js';
5
6
  import { InfoHint } from '../components/InfoHint.js';
6
7
  import { createNotificationSource, type ShellNotification } from './notificationSource.js';
7
8
  import { PlaceHeader } from './PlaceHeader.js';
@@ -545,3 +546,52 @@ describe('PlaceHeader', () => {
545
546
  expect(document.querySelector('[data-cb-place-header] button')).toBeNull();
546
547
  });
547
548
  });
549
+
550
+ describe('iOS’s keyboard (forge task 5717)', () => {
551
+ const realVV = Object.getOwnPropertyDescriptor(window, 'visualViewport');
552
+ afterEach(() => {
553
+ if (realVV) Object.defineProperty(window, 'visualViewport', realVV);
554
+ else Reflect.deleteProperty(window, 'visualViewport');
555
+ document.documentElement.style.removeProperty('--keyboard-inset');
556
+ });
557
+
558
+ /** The visible viewport loses `px` from the bottom, as iOS's keyboard takes it. */
559
+ function standInKeyboard() {
560
+ const vv = new EventTarget() as EventTarget & { height: number; offsetTop: number };
561
+ vv.height = window.innerHeight;
562
+ vv.offsetTop = 0;
563
+ Object.defineProperty(window, 'visualViewport', { configurable: true, get: () => vv });
564
+ return (px: number) => {
565
+ vv.height = window.innerHeight - px;
566
+ act(() => {
567
+ vv.dispatchEvent(new Event('resize'));
568
+ });
569
+ };
570
+ }
571
+ const inset = () => document.documentElement.style.getPropertyValue('--keyboard-inset');
572
+
573
+ test('the shell publishes the keyboard’s height, so a place’s ScrollArea pads its end above the keys', () => {
574
+ const raise = standInKeyboard();
575
+ shell();
576
+ expect(inset(), 'a shell that does not install useKeyboardInset leaves every ScrollArea’s end under the keys').toBe('0px');
577
+ raise(336);
578
+ expect(inset()).toBe('336px');
579
+ raise(0);
580
+ expect(inset()).toBe('0px');
581
+ });
582
+
583
+ test('an app that installs it too keeps it when the shell leaves first', () => {
584
+ const raise = standInKeyboard();
585
+ function AppAlsoInstalls() {
586
+ useKeyboardInset();
587
+ return null;
588
+ }
589
+ const app = render(<AppAlsoInstalls />);
590
+ const { unmount } = shell();
591
+ raise(300);
592
+ unmount();
593
+ expect(inset(), 'the first install to leave zeroed the variable under the one still mounted').toBe('300px');
594
+ app.unmount();
595
+ expect(inset()).toBe('0px');
596
+ });
597
+ });
@@ -24,7 +24,8 @@
24
24
  * through {@link useShellFocus}. Grown from the retired `AppShell`'s `immersive`, which an app set; this one is the reader's.
25
25
  * A surface that is full screen by nature (the player) holds it while it stands through {@link useShellFocusSurface}.
26
26
  *
27
- * The page never scrolls: `children` fills what is left and scrolls inside itself.
27
+ * The page never scrolls: `children` fills what is left and scrolls inside itself. The shell installs `useKeyboardInset`,
28
+ * so every `ScrollArea` inside it keeps its end above iOS's keyboard; an app never installs it again.
28
29
  */
29
30
  import { type ComponentPropsWithoutRef, createContext, type MouseEvent, type ReactNode, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
30
31
  import { initUiScale } from 'cursedbelt-core/ui-scale';
@@ -39,6 +40,7 @@ import { cn } from '../lib/cn.js';
39
40
  import { releaseAfterPointer } from '../lib/press.js';
40
41
  import { Kbd } from '../palette/Kbd.js';
41
42
  import type { ShortcutSheetGroup } from '../palette/ShortcutSheet.js';
43
+ import { useKeyboardInset } from '../hooks/useKeyboardInset.js';
42
44
  import { useShellBottomChrome } from './bottomChrome.js';
43
45
  import { focusedNow, useFocusChoice, useFocusSettings, useSideways } from './focusView.js';
44
46
  import { useKeyChoice } from './keyChoice.js';
@@ -629,6 +631,11 @@ export function WorkspaceShell({
629
631
  // one boot every app shares, so it applies the saved size before its first paint. Before, no app but desk did, and a
630
632
  // reload drew 100% while the control read 115% (forge task 5097).
631
633
  useLayoutEffect(initUiScale, []);
634
+ // The page never scrolls, so a field near the end of a place's ScrollArea is reached only through that ScrollArea, and
635
+ // with iOS's keyboard up its last lines are under the keys unless the scroll pads by `--keyboard-inset`. Only
636
+ // `useKeyboardInset` writes that, and before, family alone installed it: in eleven apps a scroll with the keyboard up
637
+ // stopped with the end of the page behind the keys (forge task 5717).
638
+ useKeyboardInset();
632
639
 
633
640
  const sheetGroups: ShortcutSheetGroup[] = [
634
641
  {