@estiva-app/ui 0.123.0 → 0.123.1

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": "@estiva-app/ui",
3
- "version": "0.123.0",
3
+ "version": "0.123.1",
4
4
  "description": "Estiva's design tokens (the contract) and a small set of primitives (a convenience) for every Estiva app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/registry.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "kind": "package",
5
5
  "repo": "estiva-ui",
6
6
  "package": "@estiva-app/ui",
7
- "packageVersion": "0.123.0",
8
- "exports": 256,
7
+ "packageVersion": "0.123.1",
8
+ "exports": 257,
9
9
  "typeExports": 270,
10
10
  "files": null
11
11
  },
@@ -10160,6 +10160,25 @@
10160
10160
  "app": null,
10161
10161
  "looks": []
10162
10162
  },
10163
+ {
10164
+ "name": "reportCrashesTo",
10165
+ "repo": "estiva-ui",
10166
+ "kind": "helper",
10167
+ "importPath": "@estiva-app/ui",
10168
+ "sourceFile": "src/ErrorBoundary.tsx",
10169
+ "purpose": "Where every ErrorBoundary sends the crash it caught, set once by the app at start (Peek passes its error reporter, `@estiva-app/platform`).",
10170
+ "purposeFrom": "comment",
10171
+ "props": [],
10172
+ "variants": [],
10173
+ "ownsBehaviours": [],
10174
+ "status": "stable",
10175
+ "migrationStage": null,
10176
+ "docsId": "status-feedback-errorboundary--docs",
10177
+ "storyId": "status-feedback-errorboundary--in-a-panel",
10178
+ "docPage": null,
10179
+ "app": null,
10180
+ "looks": []
10181
+ },
10163
10182
  {
10164
10183
  "name": "ResolveDialog",
10165
10184
  "repo": "estiva-ui",
@@ -3,7 +3,7 @@
3
3
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
4
4
  import { cleanup, fireEvent, render, screen } from '@testing-library/react'
5
5
  import { useState } from 'react'
6
- import { ErrorBoundary } from './ErrorBoundary'
6
+ import { ErrorBoundary, reportCrashesTo } from './ErrorBoundary'
7
7
 
8
8
  afterEach(cleanup)
9
9
 
@@ -76,4 +76,24 @@ describe('ErrorBoundary', () => {
76
76
  render(<Harness />)
77
77
  expect(vi.mocked(console.error).mock.calls.some((call) => String(call[0]).startsWith('test panel crashed:'))).toBe(true)
78
78
  })
79
+
80
+ describe('reporting the crash', () => {
81
+ afterEach(() => reportCrashesTo(undefined))
82
+
83
+ it('hands the error it caught to the reporter the app set', () => {
84
+ const reported: unknown[] = []
85
+ reportCrashesTo((error) => reported.push(error))
86
+ render(<Harness />)
87
+ expect(reported).toHaveLength(1)
88
+ expect((reported[0] as Error).message).toBe('boom')
89
+ })
90
+
91
+ it('still shows the message when the reporter itself throws', () => {
92
+ reportCrashesTo(() => {
93
+ throw new Error('reporter broke')
94
+ })
95
+ render(<Harness />)
96
+ expect(screen.getByText(/Something went wrong in the test panel/)).toBeTruthy()
97
+ })
98
+ })
79
99
  })
@@ -24,6 +24,17 @@ interface ErrorBoundaryState {
24
24
  hasError: boolean
25
25
  }
26
26
 
27
+ let crashReporter: ((error: unknown) => void) | undefined
28
+
29
+ /**
30
+ * Where every ErrorBoundary sends the crash it caught, set once by the app at
31
+ * start (Peek passes its error reporter, `@estiva-app/platform`). Pass nothing
32
+ * to stop. A reporter that throws never breaks the message on screen.
33
+ */
34
+ export function reportCrashesTo(reporter: ((error: unknown) => void) | undefined): void {
35
+ crashReporter = reporter
36
+ }
37
+
27
38
  /** Keeps a crash inside what it holds: the rest of the page keeps working, and Try again draws it again. */
28
39
  export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
29
40
  state: ErrorBoundaryState = { hasError: false }
@@ -34,6 +45,11 @@ export class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundarySt
34
45
 
35
46
  componentDidCatch(error: unknown, info: { componentStack?: string | null }) {
36
47
  console.error(`${this.props.label ?? 'part of the page'} crashed:`, error, info.componentStack ?? '')
48
+ try {
49
+ crashReporter?.(error)
50
+ } catch {
51
+ // Reporting a crash must never become a second one.
52
+ }
37
53
  }
38
54
 
39
55
  render() {
package/src/index.ts CHANGED
@@ -76,7 +76,7 @@ export { Divider, type DividerProps } from './Divider'
76
76
  export { EditableText, type EditableTextAnswer, type EditableTextOutcome, type EditableTextProps } from './EditableText'
77
77
  export { EmptyState, type EmptyStateProps } from './EmptyState'
78
78
  export { EntryShell, type EntryShellProps } from './EntryShell'
79
- export { ErrorBoundary, type ErrorBoundaryProps } from './ErrorBoundary'
79
+ export { ErrorBoundary, reportCrashesTo, type ErrorBoundaryProps } from './ErrorBoundary'
80
80
  export { ProgressBar, type ProgressBarProps, type ProgressBarVariant } from './ProgressBar'
81
81
  export { SkeletonBar, SkeletonConversation, SkeletonList, SkeletonRow } from './Skeleton'
82
82
  export { Breadcrumb, type BreadcrumbProps, type Crumb } from './Breadcrumb'
@@ -48,20 +48,20 @@ describe('the registry builds', () => {
48
48
  expect(registry.entries.map((one) => one.name).sort()).toEqual(values.map((one) => one.name).sort())
49
49
  })
50
50
 
51
- it('counts 256 names over 131 files: 170 components, 78 helpers and 8 hooks (ListTable and ListTableRow, a list of things on a page under column headings, and ActivityLine, one thing that happened in a list of what is new, from the navigation prototype, on 16 November; useShortcut, a key that works from anywhere on the page, for Peek’s Ctrl/Cmd+O to Add to Open work (TOPI-7), on 10 November; CornerMenu, the "…" over a row’s or a card’s corner with Show as and Remove (TOPI-5), on 10 November; ConversationHeading, which place a comment is on in a list mixing several places (TOPI-2), on 9 November; FollowSwitch, LevelIcon and WhoFollowsDialog, how you follow a place and who follows it (TEA-6), on 6 November; goneWords and GONE_CLOSED, what stands in a gone comment’s place and under its thread in every app (ONE-9), on 6 November; DeletedNotice and NoAccessNotice, the cards on a deleted file and on one you cannot open (ALO-4), on 3 November; useFormBusy, whether a Form around it is sending, read by the editor’s DocumentField from the main entry, in the review of 2 November; useLeftAt, sendsInLayout, useSeenOnScreen, showInConversation and showInConversationWhenDrawn, where a conversation scrolls, what was seen and a link landing on a comment, moved from Peek for every app, on 2 November; useRememberedOpen, the fold a section remembers, read by the app, and NAV_TREE_PENDING_MS and isPlainClick, Peek’s Folder timer and plain-click check, moved in, on 2 November; FormDialog, MoveDialog and ArchiveDialog, the dialogs Peek wired by hand, on 2 November; ConversationPlace, the line saying where a comment was said, and DocumentField, a rich-text field of a form, moved from Peek, on 2 November; ArchivedNotice, the card on an archived file, from Peek, Ship and Leaf, on 31 October; caretOnOpen, the box at a thread’s foot taking the caret when a ConversationLayout opens it, without scrolling, on 31 October; the conversation from Peek for every app, with PageHeader and PinnedComment, on 31 October, and ResolutionNote and ResolutionHistory gone with the resolved looks not picked, on 1 November; useSidebarFold, a folded sidebar kept folded in every app, on 31 October; cardShapeMemory, a card’s last shape on this device, lifted from Peek and Ship for Leaf, and ReferenceCards and useReferenceCards gone with their deprecated page, in the widget review, on 30 October; inTheBox, a card or part in a box being written in, on the files’ fill and in words, on 29 October; archivedLine, the line on an archived file in every app (PEEKM-2), on 23 October; keepCommentBoxWarm, a box built ahead, exported as 0.84.0 promised (PEEKM-1), on 21 October;linkedFrom and linkStateFrom, one card for a file in every app (5ebf2756), on 21 October; ComposeBox, ComposeKeys and COMPOSE_EDITOR_CLASSES gone into CommentBox’s own frame (one box), on 21 October; LinkPlaces with linkPlaceAt and staysChip, a link in a document drawn where it sits (WBD-4), on 20 October; DocumentEditor, one document editor for every app, and PersonReference, `@` in a document (WBD-3), on 20 October; toggleTableHeaderRow, a table’s header row on and off (LEAF-12), on 19 October;EntryShell, the screen while nobody is signed in, moved from Peek (AUT-3), on 17 October; CommentBox with commentBoxRows, and ReactionRow with AddReactionButton and whoReacted, the shared comment box and reaction row (COMM-2), on 17 October; the link widgets — LinkChip, LinkRow, LinkCard, CardUnder, PartCard, LinkPreview and their parts, with useCanHover, chosenOf, loadingShapeOf and unavailableMemory — from the Widgets 2 prototype, on 16 October; InlineText, a title or the line under it edited where it stands (SUM-4), on 16 October; ComposeBox with ComposeKeys and its classes, CommentHighlights with its five helpers, and keepSelection and releaseSelection, from the Leaf prototype (LEAF-4), on 16 October;NavTree, NavTreeSection, the composer triggers and UnreadDot joined on 2 October; BlockHandle and EditorBlockHandle (RIC-18) on 2 October, moveBlock and blockDropCursor, the drop in the gutter, on 5 October, MembersPill and MembersDialog, moved from Peek (SHI-31), on 6 October, ShowMore on 7 October, AppProvider on 8 October, and KindIcon, thingKindOf and PastedImages with its two helpers, moved from Peek, on 8 October; CodeBlockColours, the coloured code block of the editor, on 9 October; Checklist, Callout, isChecklistTick and calloutLook (RIC-19) on 13 October; EditorTableControls and its four actions (RIC-21) on 13 October; ReferenceCards, useReferenceCards and its three helpers, the card a chip in a document asks for, on 14 October; LinkChips and its two helpers, a URL in a document read as its chip, on 14 October; ReferenceMenu, ReferenceMenuView and three helpers, the menu of a chip while writing, on 14 October; PastedMarkdown, markdown pasted as the blocks it spells (LEAF-10), on 15 October; turnIntoRows, turnListInto and turnQuoteInto, the block menu’s Turn into for a list and a quote (LEAF-11), on 15 October)', () => {
51
+ it('counts 257 names over 131 files: 170 components, 79 helpers and 8 hooks (reportCrashesTo, where every ErrorBoundary sends the crash it caught (PROD-2), on 18 November; ListTable and ListTableRow, a list of things on a page under column headings, and ActivityLine, one thing that happened in a list of what is new, from the navigation prototype, on 16 November; useShortcut, a key that works from anywhere on the page, for Peek’s Ctrl/Cmd+O to Add to Open work (TOPI-7), on 10 November; CornerMenu, the "…" over a row’s or a card’s corner with Show as and Remove (TOPI-5), on 10 November; ConversationHeading, which place a comment is on in a list mixing several places (TOPI-2), on 9 November; FollowSwitch, LevelIcon and WhoFollowsDialog, how you follow a place and who follows it (TEA-6), on 6 November; goneWords and GONE_CLOSED, what stands in a gone comment’s place and under its thread in every app (ONE-9), on 6 November; DeletedNotice and NoAccessNotice, the cards on a deleted file and on one you cannot open (ALO-4), on 3 November; useFormBusy, whether a Form around it is sending, read by the editor’s DocumentField from the main entry, in the review of 2 November; useLeftAt, sendsInLayout, useSeenOnScreen, showInConversation and showInConversationWhenDrawn, where a conversation scrolls, what was seen and a link landing on a comment, moved from Peek for every app, on 2 November; useRememberedOpen, the fold a section remembers, read by the app, and NAV_TREE_PENDING_MS and isPlainClick, Peek’s Folder timer and plain-click check, moved in, on 2 November; FormDialog, MoveDialog and ArchiveDialog, the dialogs Peek wired by hand, on 2 November; ConversationPlace, the line saying where a comment was said, and DocumentField, a rich-text field of a form, moved from Peek, on 2 November; ArchivedNotice, the card on an archived file, from Peek, Ship and Leaf, on 31 October; caretOnOpen, the box at a thread’s foot taking the caret when a ConversationLayout opens it, without scrolling, on 31 October; the conversation from Peek for every app, with PageHeader and PinnedComment, on 31 October, and ResolutionNote and ResolutionHistory gone with the resolved looks not picked, on 1 November; useSidebarFold, a folded sidebar kept folded in every app, on 31 October; cardShapeMemory, a card’s last shape on this device, lifted from Peek and Ship for Leaf, and ReferenceCards and useReferenceCards gone with their deprecated page, in the widget review, on 30 October; inTheBox, a card or part in a box being written in, on the files’ fill and in words, on 29 October; archivedLine, the line on an archived file in every app (PEEKM-2), on 23 October; keepCommentBoxWarm, a box built ahead, exported as 0.84.0 promised (PEEKM-1), on 21 October;linkedFrom and linkStateFrom, one card for a file in every app (5ebf2756), on 21 October; ComposeBox, ComposeKeys and COMPOSE_EDITOR_CLASSES gone into CommentBox’s own frame (one box), on 21 October; LinkPlaces with linkPlaceAt and staysChip, a link in a document drawn where it sits (WBD-4), on 20 October; DocumentEditor, one document editor for every app, and PersonReference, `@` in a document (WBD-3), on 20 October; toggleTableHeaderRow, a table’s header row on and off (LEAF-12), on 19 October;EntryShell, the screen while nobody is signed in, moved from Peek (AUT-3), on 17 October; CommentBox with commentBoxRows, and ReactionRow with AddReactionButton and whoReacted, the shared comment box and reaction row (COMM-2), on 17 October; the link widgets — LinkChip, LinkRow, LinkCard, CardUnder, PartCard, LinkPreview and their parts, with useCanHover, chosenOf, loadingShapeOf and unavailableMemory — from the Widgets 2 prototype, on 16 October; InlineText, a title or the line under it edited where it stands (SUM-4), on 16 October; ComposeBox with ComposeKeys and its classes, CommentHighlights with its five helpers, and keepSelection and releaseSelection, from the Leaf prototype (LEAF-4), on 16 October;NavTree, NavTreeSection, the composer triggers and UnreadDot joined on 2 October; BlockHandle and EditorBlockHandle (RIC-18) on 2 October, moveBlock and blockDropCursor, the drop in the gutter, on 5 October, MembersPill and MembersDialog, moved from Peek (SHI-31), on 6 October, ShowMore on 7 October, AppProvider on 8 October, and KindIcon, thingKindOf and PastedImages with its two helpers, moved from Peek, on 8 October; CodeBlockColours, the coloured code block of the editor, on 9 October; Checklist, Callout, isChecklistTick and calloutLook (RIC-19) on 13 October; EditorTableControls and its four actions (RIC-21) on 13 October; ReferenceCards, useReferenceCards and its three helpers, the card a chip in a document asks for, on 14 October; LinkChips and its two helpers, a URL in a document read as its chip, on 14 October; ReferenceMenu, ReferenceMenuView and three helpers, the menu of a chip while writing, on 14 October; PastedMarkdown, markdown pasted as the blocks it spells (LEAF-10), on 15 October; turnIntoRows, turnListInto and turnQuoteInto, the block menu’s Turn into for a list and a quote (LEAF-11), on 15 October)', () => {
52
52
  // The reconciliation GATES.md §24 explains. If this changes, that changes.
53
53
  // The `EDITOR_EXTENSIONS` count as components by their names; they are
54
54
  // editor extensions, documented on SelectionToolbar's, BlockNodes' and
55
55
  // ComposerTriggers' pages.
56
56
  const kinds = registry.entries.reduce<Record<string, number>>((all, one) => ({ ...all, [one.kind]: (all[one.kind] ?? 0) + 1 }), {})
57
- expect(kinds).toEqual({ component: 170, helper: 78, hook: 8 })
57
+ expect(kinds).toEqual({ component: 170, helper: 79, hook: 8 })
58
58
  expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(131)
59
59
  })
60
60
 
61
61
  it('gives every entry a purpose, from its own page or from the comment above it', () => {
62
62
  expect(registry.entries.filter((one) => one.purpose.trim() === '')).toEqual([])
63
63
  expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(118)
64
- expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(138)
64
+ expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(139)
65
65
  })
66
66
 
67
67
  it('takes a name with a page of its own from the page, and a name without one from the code', () => {