@genesislcap/foundation-react-utils 15.46.6-alpha-6d1bd2f25.0 → 15.46.6-alpha-606571609.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.
package/README.md CHANGED
@@ -53,15 +53,15 @@ the theme was generated against.
53
53
  HOC) wraps a single tile, so a crash replaces only that tile. Both render a fallback with a
54
54
  reference ID, copyable diagnostics and a Retry button that remounts the children.
55
55
 
56
- Every caught error is passed to the optional `onError` callback as an `ErrorBoundaryReport`
57
- (`error`, `componentStack`, `referenceId`, `scope`, `title`, `tileRegistration`). Use it to send
58
- errors to a monitoring service; this package takes no dependency on one.
56
+ With `setupErrorMonitoring` from `@genesislcap/foundation-utils`, caught errors are reported with
57
+ their reference ID, scope, title, tile registration and component stack, and nothing else is
58
+ needed:
59
59
 
60
60
  ```tsx
61
61
  import { AppErrorBoundary, onCaughtError } from '@genesislcap/foundation-react-utils';
62
62
 
63
63
  createRoot(el, { onCaughtError }).render(
64
- <AppErrorBoundary onError={({ error, ...extra }) => Sentry.captureException(error, { extra })}>
64
+ <AppErrorBoundary>
65
65
  <App />
66
66
  </AppErrorBoundary>,
67
67
  );
@@ -70,23 +70,28 @@ createRoot(el, { onCaughtError }).render(
70
70
  ```tsx
71
71
  import { TileErrorBoundary, withTileErrorBoundary } from '@genesislcap/foundation-react-utils';
72
72
 
73
- <TileErrorBoundary title="Trade Blotter" tileRegistration="tradeBlotter" onError={report}>
73
+ <TileErrorBoundary title="Trade Blotter" tileRegistration="tradeBlotter">
74
74
  <TradeBlotter />
75
75
  </TileErrorBoundary>;
76
76
 
77
- export const TradeBlotterTile = withTileErrorBoundary(TradeBlotter, 'Trade Blotter', 'tradeBlotter', report);
77
+ export const TradeBlotterTile = withTileErrorBoundary(TradeBlotter, 'Trade Blotter', 'tradeBlotter');
78
78
  ```
79
79
 
80
+ To handle caught errors yourself, pass `onError`. It receives an `ErrorBoundaryReport` (`error`,
81
+ `componentStack`, `referenceId`, `scope`, `title`, `tileRegistration`). `withTileErrorBoundary`
82
+ takes it as a fourth argument.
83
+
80
84
  Pass `onCaughtError` to `createRoot`. By default React 19 logs every error a boundary catches to
81
85
  `console.error` before the boundary runs, so a console-capturing monitoring tool reports the bare
82
86
  error first and can drop or duplicate the boundary's own report. `onCaughtError` skips that log
83
87
  for these boundaries, and still logs errors caught by any other boundary.
84
88
 
85
89
  Without `onError`, a boundary logs each caught error through a foundation logger named
86
- `ERROR_BOUNDARY_LOGGER_NAME`, which a global log reporter (`addGlobalLogReporter` from
87
- `@genesislcap/foundation-logger`) receives. With `onError` set, the boundary doesn't log the error,
88
- so an app that reports through both `onError` and a global reporter gets each error once. If
89
- `onError` throws, the boundary logs the original error and the handler's error, so neither is lost.
90
+ `ERROR_BOUNDARY_LOGGER_NAME`: the error, then an object with its reference ID, scope, title, tile
91
+ registration and component stack. A global log reporter (`addGlobalLogReporter` from
92
+ `@genesislcap/foundation-logger`) receives it, which is how `setupErrorMonitoring` reports it. With
93
+ `onError` set, the boundary doesn't log the error, so it isn't reported twice. If `onError` throws,
94
+ the boundary logs the original error and the handler's error, so neither is lost.
90
95
 
91
96
  The fallback reads its colours and fonts from `--eb-*` CSS custom properties (`--eb-bg`,
92
97
  `--eb-surface`, `--eb-text`, `--eb-text-muted`, `--eb-border`, `--eb-accent`, `--eb-error`,
@@ -381,29 +381,6 @@
381
381
  }
382
382
  ]
383
383
  },
384
- {
385
- "kind": "javascript-module",
386
- "path": "src/flexlayout/index.ts",
387
- "declarations": [],
388
- "exports": [
389
- {
390
- "kind": "js",
391
- "name": "*",
392
- "declaration": {
393
- "name": "*",
394
- "package": "flexlayout-react"
395
- }
396
- },
397
- {
398
- "kind": "js",
399
- "name": "installRapidFlexLayoutReactStyles",
400
- "declaration": {
401
- "name": "installRapidFlexLayoutReactStyles",
402
- "module": "src/flexlayout/index.ts"
403
- }
404
- }
405
- ]
406
- },
407
384
  {
408
385
  "kind": "javascript-module",
409
386
  "path": "src/router/index.ts",
@@ -648,6 +625,29 @@
648
625
  }
649
626
  }
650
627
  ]
628
+ },
629
+ {
630
+ "kind": "javascript-module",
631
+ "path": "src/flexlayout/index.ts",
632
+ "declarations": [],
633
+ "exports": [
634
+ {
635
+ "kind": "js",
636
+ "name": "*",
637
+ "declaration": {
638
+ "name": "*",
639
+ "package": "flexlayout-react"
640
+ }
641
+ },
642
+ {
643
+ "kind": "js",
644
+ "name": "installRapidFlexLayoutReactStyles",
645
+ "declaration": {
646
+ "name": "installRapidFlexLayoutReactStyles",
647
+ "module": "src/flexlayout/index.ts"
648
+ }
649
+ }
650
+ ]
651
651
  }
652
652
  ]
653
653
  }
@@ -1,8 +1,10 @@
1
1
  import type { ComponentType, FC, ReactNode } from 'react';
2
2
  import type { RootOptions } from 'react-dom/client';
3
3
  /**
4
- * Name of the logger the error boundaries log through. They log a caught error only when no
5
- * `onError` handler is set, or when the handler throws.
4
+ * Name of the logger the error boundaries log through. They log a caught error, followed by its
5
+ * reference ID, scope, title, tile registration and component stack, only when no `onError`
6
+ * handler is set or when the handler throws. `setupErrorMonitoring` from foundation-utils reports
7
+ * these logs, so apps using it don't need an `onError`.
6
8
  * @public
7
9
  */
8
10
  export declare const ERROR_BOUNDARY_LOGGER_NAME = "foundation-react-utils:error-boundary";
@@ -1 +1 @@
1
- {"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../../src/error-boundary/error-boundary.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAa,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,0CAA0C,CAAC;AAIlF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,MAAM,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,c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AM,EACb,kBAAkB,MAAM,EACxB,UAAU,yBAAyB,KAClC,EAAE,CAAC,CAAC,CAUN,CAAC;AAOF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,WAAW,CAAC,eAAe,CAAC,CAKnE,CAAC"}
@@ -5,8 +5,10 @@ import { createLogger } from '@genesislcap/foundation-logger';
5
5
  import { Component, useState } from 'react';
6
6
  import { errorBoundaryStyles } from './error-boundary-styles';
7
7
  /**
8
- * Name of the logger the error boundaries log through. They log a caught error only when no
9
- * `onError` handler is set, or when the handler throws.
8
+ * Name of the logger the error boundaries log through. They log a caught error, followed by its
9
+ * reference ID, scope, title, tile registration and component stack, only when no `onError`
10
+ * handler is set or when the handler throws. `setupErrorMonitoring` from foundation-utils reports
11
+ * these logs, so apps using it don't need an `onError`.
10
12
  * @public
11
13
  */
12
14
  export const ERROR_BOUNDARY_LOGGER_NAME = 'foundation-react-utils:error-boundary';
@@ -106,11 +108,13 @@ class BaseErrorBoundary extends Component {
106
108
  const { referenceId } = this.state;
107
109
  this.setState({ componentStack });
108
110
  recordReport(normalized, componentStack);
109
- const logCaughtError = () => logger.error(`[${scope}] error boundary captured an error`, {
111
+ // The error comes first so a global log reporter can report it as an exception, with the
112
+ // context object attached (see `setupErrorMonitoring` in foundation-utils).
113
+ const logCaughtError = () => logger.error(`[${scope}] error boundary captured an error`, normalized, {
110
114
  referenceId,
115
+ scope,
111
116
  title,
112
117
  tileRegistration,
113
- error: normalized,
114
118
  componentStack,
115
119
  });
116
120
  // With a handler set, the handler reports the error, so logging it as well would send it to
@@ -500,7 +500,7 @@
500
500
  {
501
501
  "kind": "Variable",
502
502
  "canonicalReference": "@genesislcap/foundation-react-utils!ERROR_BOUNDARY_LOGGER_NAME:var",
503
- "docComment": "/**\n * Name of the logger the error boundaries log through. They log a caught error only when no `onError` handler is set, or when the handler throws.\n *\n * @public\n */\n",
503
+ "docComment": "/**\n * Name of the logger the error boundaries log through. They log a caught error, followed by its reference ID, scope, title, tile registration and component stack, only when no `onError` handler is set or when the handler throws. `setupErrorMonitoring` from foundation-utils reports these logs, so apps using it don't need an `onError`.\n *\n * @public\n */\n",
504
504
  "excerptTokens": [
505
505
  {
506
506
  "kind": "Content",
@@ -238,8 +238,10 @@ export declare function createReactRenderer(Component: ComponentType<RendererCon
238
238
  }): RendererEntry;
239
239
 
240
240
  /**
241
- * Name of the logger the error boundaries log through. They log a caught error only when no
242
- * `onError` handler is set, or when the handler throws.
241
+ * Name of the logger the error boundaries log through. They log a caught error, followed by its
242
+ * reference ID, scope, title, tile registration and component stack, only when no `onError`
243
+ * handler is set or when the handler throws. `setupErrorMonitoring` from foundation-utils reports
244
+ * these logs, so apps using it don't need an `onError`.
243
245
  * @public
244
246
  */
245
247
  export declare const ERROR_BOUNDARY_LOGGER_NAME = "foundation-react-utils:error-boundary";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-react-utils",
3
3
  "description": "Genesis Foundation React Utils",
4
- "version": "15.46.6-alpha-6d1bd2f25.0",
4
+ "version": "15.46.6-alpha-606571609.0",
5
5
  "sideEffects": [
6
6
  "./dist/esm/flexlayout/index.js"
7
7
  ],
@@ -56,12 +56,12 @@
56
56
  }
57
57
  },
58
58
  "devDependencies": {
59
- "@genesislcap/foundation-testing": "15.46.6-alpha-6d1bd2f25.0",
60
- "@genesislcap/genx": "15.46.6-alpha-6d1bd2f25.0",
61
- "@genesislcap/ts-builder": "15.46.6-alpha-6d1bd2f25.0",
62
- "@genesislcap/uvu-playwright-builder": "15.46.6-alpha-6d1bd2f25.0",
63
- "@genesislcap/vite-builder": "15.46.6-alpha-6d1bd2f25.0",
64
- "@genesislcap/webpack-builder": "15.46.6-alpha-6d1bd2f25.0",
59
+ "@genesislcap/foundation-testing": "15.46.6-alpha-606571609.0",
60
+ "@genesislcap/genx": "15.46.6-alpha-606571609.0",
61
+ "@genesislcap/ts-builder": "15.46.6-alpha-606571609.0",
62
+ "@genesislcap/uvu-playwright-builder": "15.46.6-alpha-606571609.0",
63
+ "@genesislcap/vite-builder": "15.46.6-alpha-606571609.0",
64
+ "@genesislcap/webpack-builder": "15.46.6-alpha-606571609.0",
65
65
  "react-router-dom": "^7.1.3"
66
66
  },
67
67
  "peerDependencies": {
@@ -75,11 +75,11 @@
75
75
  }
76
76
  },
77
77
  "dependencies": {
78
- "@genesislcap/foundation-forms": "15.46.6-alpha-6d1bd2f25.0",
79
- "@genesislcap/foundation-layout": "15.46.6-alpha-6d1bd2f25.0",
80
- "@genesislcap/foundation-logger": "15.46.6-alpha-6d1bd2f25.0",
81
- "@genesislcap/rapid-design-system": "15.46.6-alpha-6d1bd2f25.0",
82
- "@genesislcap/web-core": "15.46.6-alpha-6d1bd2f25.0",
78
+ "@genesislcap/foundation-forms": "15.46.6-alpha-606571609.0",
79
+ "@genesislcap/foundation-layout": "15.46.6-alpha-606571609.0",
80
+ "@genesislcap/foundation-logger": "15.46.6-alpha-606571609.0",
81
+ "@genesislcap/rapid-design-system": "15.46.6-alpha-606571609.0",
82
+ "@genesislcap/web-core": "15.46.6-alpha-606571609.0",
83
83
  "@jsonforms/core": "^3.2.1",
84
84
  "@r2wc/core": "1.3.1",
85
85
  "@r2wc/react-to-web-component": "^2.0.2",