|
| 1 | +import type { DevframeDiagnostics } from 'devframe/utils/nostics' |
1 | 2 | import { defineDiagnostics } from 'devframe/utils/nostics' |
2 | 3 |
|
| 4 | +const codes = { |
| 5 | + DF0038: { |
| 6 | + why: (p: { id: string, key: string, issues: string }) => |
| 7 | + `JSON-render view "${p.id}" received invalid props on element "${p.key}": ${p.issues}`, |
| 8 | + fix: 'Match the element props to the base catalog\'s prop schema for that component. See the component reference for the expected shape.', |
| 9 | + }, |
| 10 | + DF0039: { |
| 11 | + why: (p: { id: string, scope: string }) => |
| 12 | + `A JSON-render view with id "${p.id}" already exists in scope "${p.scope}".`, |
| 13 | + fix: 'Give each view a stable id unique within its scope, or dispose the previous view before recreating it.', |
| 14 | + }, |
| 15 | + DF0040: { |
| 16 | + why: (p: { id: string }) => |
| 17 | + `JSON-render view "${p.id}" was used after it was disposed.`, |
| 18 | + fix: 'Create a fresh view with `createJsonRenderView` instead of reusing a disposed handle.', |
| 19 | + }, |
| 20 | + DF0041: { |
| 21 | + why: (p: { id: string, reason: string }) => |
| 22 | + `JSON-render view "${p.id}" spec is not JSON-serializable: ${p.reason}`, |
| 23 | + fix: 'Specs and state travel as strict JSON, so remove functions, symbols, class instances, Map/Set, or circular references.', |
| 24 | + }, |
| 25 | + DF0073: { |
| 26 | + why: (p: { id: string, issues: string }) => |
| 27 | + `JSON-render view "${p.id}" does not match its configured schema: ${p.issues}`, |
| 28 | + fix: 'Match the authored spec to the Standard Schema passed to `createJsonRenderView`.', |
| 29 | + }, |
| 30 | + DF0074: { |
| 31 | + why: (p: { id: string }) => |
| 32 | + `JSON-render view "${p.id}" uses an asynchronous Standard Schema.`, |
| 33 | + fix: 'Use a synchronous Standard Schema so initial creation and updates remain synchronous.', |
| 34 | + }, |
| 35 | +} |
| 36 | + |
3 | 37 | /** |
4 | 38 | * `@devframes/json-render` protocol/runtime diagnostics share the `DF` |
5 | 39 | * prefix and use the next globally available core codes. Browser-only render |
6 | 40 | * failures keep `console.*` in the UI package. |
| 41 | + * |
| 42 | + * Annotated with {@link DevframeDiagnostics} so the public type resolves |
| 43 | + * through the `devframe/utils/nostics` peer rather than inlining `nostics`. |
7 | 44 | */ |
8 | | -export const diagnostics = defineDiagnostics({ |
| 45 | +export const diagnostics: DevframeDiagnostics<typeof codes> = defineDiagnostics({ |
9 | 46 | docsBase: 'https://devfra.me/errors', |
10 | | - codes: { |
11 | | - DF0038: { |
12 | | - why: (p: { id: string, key: string, issues: string }) => |
13 | | - `JSON-render view "${p.id}" received invalid props on element "${p.key}": ${p.issues}`, |
14 | | - fix: 'Match the element props to the base catalog\'s prop schema for that component. See the component reference for the expected shape.', |
15 | | - }, |
16 | | - DF0039: { |
17 | | - why: (p: { id: string, scope: string }) => |
18 | | - `A JSON-render view with id "${p.id}" already exists in scope "${p.scope}".`, |
19 | | - fix: 'Give each view a stable id unique within its scope, or dispose the previous view before recreating it.', |
20 | | - }, |
21 | | - DF0040: { |
22 | | - why: (p: { id: string }) => |
23 | | - `JSON-render view "${p.id}" was used after it was disposed.`, |
24 | | - fix: 'Create a fresh view with `createJsonRenderView` instead of reusing a disposed handle.', |
25 | | - }, |
26 | | - DF0041: { |
27 | | - why: (p: { id: string, reason: string }) => |
28 | | - `JSON-render view "${p.id}" spec is not JSON-serializable: ${p.reason}`, |
29 | | - fix: 'Specs and state travel as strict JSON, so remove functions, symbols, class instances, Map/Set, or circular references.', |
30 | | - }, |
31 | | - DF0073: { |
32 | | - why: (p: { id: string, issues: string }) => |
33 | | - `JSON-render view "${p.id}" does not match its configured schema: ${p.issues}`, |
34 | | - fix: 'Match the authored spec to the Standard Schema passed to `createJsonRenderView`.', |
35 | | - }, |
36 | | - DF0074: { |
37 | | - why: (p: { id: string }) => |
38 | | - `JSON-render view "${p.id}" uses an asynchronous Standard Schema.`, |
39 | | - fix: 'Use a synchronous Standard Schema so initial creation and updates remain synchronous.', |
40 | | - }, |
41 | | - }, |
| 47 | + codes, |
42 | 48 | }) |
0 commit comments