@veluai/velu 0.1.11 → 0.1.13

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.
@@ -1,54 +1,54 @@
1
- import React from 'react';
2
- import { ErrorCard } from 'velu-ui';
3
- import { extractMdxError } from '../lib/extract-mdx-error.js';
4
- import { CATEGORY_LABEL } from '../lib/issues.js';
5
- import { KNOWN_COMPONENTS } from '../lib/known-components.js';
6
-
7
- /**
8
- * Catches render-time errors from the current page (unknown component, a
9
- * component that threw on a bad prop, etc.) and renders a branded ErrorCard in
10
- * its place — leaving the surrounding chrome (header, sidebar, TOC) mounted.
11
- *
12
- * This is the CLIENT-side safety net: when the reader navigates (react-router,
13
- * no full reload) to a page that throws, the chrome stays put and only the
14
- * body shows the card. On a direct load / reload of a broken page the error
15
- * happens during SSR instead — React's renderToString doesn't recover through
16
- * error boundaries, so the dev server catches it there and serves the
17
- * full-page branded error (and logs it to the terminal).
18
- *
19
- * In `App.jsx` it's keyed by `pathname`, so navigating to another page (or
20
- * fixing the file and reloading) remounts it and clears the error.
21
- */
22
- export default class ErrorBoundary extends React.Component {
23
- constructor(props) {
24
- super(props);
25
- this.state = { error: null };
26
- }
27
-
28
- static getDerivedStateFromError(error) {
29
- return { error };
30
- }
31
-
32
- render() {
33
- const { error } = this.state;
34
- if (!error) return this.props.children;
35
-
36
- const issue = extractMdxError(error, {
37
- knownComponents: KNOWN_COMPONENTS,
38
- file: this.props.file || null,
39
- });
40
- return (
41
- <ErrorCard
42
- label={CATEGORY_LABEL[issue.category] || issue.category}
43
- title={issue.title}
44
- file={issue.file}
45
- line={issue.line}
46
- column={issue.column}
47
- frame={issue.frame}
48
- detail={issue.detail}
49
- hint={issue.hint}
50
- suggestion={issue.suggestion}
51
- />
52
- );
53
- }
54
- }
1
+ import React from 'react';
2
+ import { ErrorCard } from 'velu-ui';
3
+ import { extractMdxError } from '../lib/extract-mdx-error.js';
4
+ import { CATEGORY_LABEL } from '../lib/issues.js';
5
+ import { KNOWN_COMPONENTS } from '../lib/known-components.js';
6
+
7
+ /**
8
+ * Catches render-time errors from the current page (unknown component, a
9
+ * component that threw on a bad prop, etc.) and renders a branded ErrorCard in
10
+ * its place — leaving the surrounding chrome (header, sidebar, TOC) mounted.
11
+ *
12
+ * This is the CLIENT-side safety net: when the reader navigates (react-router,
13
+ * no full reload) to a page that throws, the chrome stays put and only the
14
+ * body shows the card. On a direct load / reload of a broken page the error
15
+ * happens during SSR instead — React's renderToString doesn't recover through
16
+ * error boundaries, so the dev server catches it there and serves the
17
+ * full-page branded error (and logs it to the terminal).
18
+ *
19
+ * In `App.jsx` it's keyed by `pathname`, so navigating to another page (or
20
+ * fixing the file and reloading) remounts it and clears the error.
21
+ */
22
+ export default class ErrorBoundary extends React.Component {
23
+ constructor(props) {
24
+ super(props);
25
+ this.state = { error: null };
26
+ }
27
+
28
+ static getDerivedStateFromError(error) {
29
+ return { error };
30
+ }
31
+
32
+ render() {
33
+ const { error } = this.state;
34
+ if (!error) return this.props.children;
35
+
36
+ const issue = extractMdxError(error, {
37
+ knownComponents: KNOWN_COMPONENTS,
38
+ file: this.props.file || null,
39
+ });
40
+ return (
41
+ <ErrorCard
42
+ label={CATEGORY_LABEL[issue.category] || issue.category}
43
+ title={issue.title}
44
+ file={issue.file}
45
+ line={issue.line}
46
+ column={issue.column}
47
+ frame={issue.frame}
48
+ detail={issue.detail}
49
+ hint={issue.hint}
50
+ suggestion={issue.suggestion}
51
+ />
52
+ );
53
+ }
54
+ }