@devframes/json-render 0.9.20 → 0.10.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.
@@ -1,6 +1,7 @@
1
1
  import { n as DevframeJsonRenderSpec, r as JsonRenderView } from "../types-ByXkazOp.mjs";
2
- import { StandardSchemaV1 } from "@standard-schema/spec";
2
+ import { DevframeDiagnostics } from "devframe/utils/nostics";
3
3
  import { DevframeNodeContext, DevframeScopedNodeContext } from "devframe";
4
+ import { StandardSchemaV1 } from "devframe/utils/simple-schema";
4
5
  //#region src/node/create-view.d.ts
5
6
  /** Options for {@link createJsonRenderView}. */
6
7
  interface CreateJsonRenderViewOptions<SpecType extends DevframeJsonRenderSpec = DevframeJsonRenderSpec> {
@@ -45,284 +46,58 @@ type AnyContext = DevframeNodeContext | DevframeScopedNodeContext<string>;
45
46
  */
46
47
  export declare function createJsonRenderView<SpecType extends DevframeJsonRenderSpec = DevframeJsonRenderSpec>(ctx: AnyContext, options: CreateJsonRenderViewOptions<SpecType>): JsonRenderView<SpecType>;
47
48
  //#endregion
48
- //#region ../../node_modules/.pnpm/nostics@1.2.0/node_modules/nostics/dist/diagnostic-wduO7saY.d.mts
49
- //#region src/utils.d.ts
50
- /**
51
- * A value of type T, or a function that resolves T from a single params object.
52
- *
53
- * @internal
54
- */
55
- type ValueOrFn<T, P = any> = T | ((params: P) => T);
56
- /**
57
- * Extracts the param type from a single-arg function, or `never` for
58
- * non-function inputs. Pairs with {@link ValueOrFn}.
59
- *
60
- * @internal
61
- */
62
- type ExtractFnParam<T> = T extends ((params: infer P) => any) ? P : never;
63
- /**
64
- * Converts a union of types to their intersection.
65
- *
66
- * @internal
67
- */
68
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
69
- /**
70
- * `true` when `T` is the `any` type.
71
- *
72
- * @internal
73
- */
74
- type IsAny<Type> = 0 extends 1 & Type ? true : false;
75
- /**
76
- * `true` when `T` is the `unknown` type (and not `any`).
77
- *
78
- * @internal
79
- */
80
- type IsUnknown<Type> = IsAny<Type> extends true ? false : unknown extends Type ? true : false;
81
- /**
82
- * Expands a type to its property listing so editor hovers show the resolved
83
- * shape instead of a chain of aliases / intersections.
84
- *
85
- * @internal
86
- */
87
- type Prettify<Type> = { [Key in keyof Type]: Type[Key]; };
88
- //#endregion
89
- //#region src/diagnostic.d.ts
90
- /**
91
- * Define-time shape of a diagnostic. Each field can be a static value or a
92
- * function that resolves it from a shared `params` object passed at call
93
- * time. Runtime-only fields (`cause`, `sources`) from {@link DiagnosticInit}
94
- * are intentionally omitted: they're only meaningful at the call site.
95
- */
96
- interface DiagnosticDefinition<P = any> {
97
- /**
98
- * The error message: why this failed. String, or a function of `params`.
99
- *
100
- * @example
101
- * ```ts
102
- * why: (p: { name: string }) => `module "${p.name}" failed to load`
103
- * ```
104
- */
105
- why: ValueOrFn<string, P>;
106
- /**
107
- * Actionable instructions on how to resolve the problem. String, or a
108
- * function of `params`.
109
- *
110
- * @example
111
- * ```ts
112
- * fix: (p: { name: string }) => `run "npm install ${p.name}"`
113
- * ```
114
- */
115
- fix?: ValueOrFn<string, P>;
116
- /**
117
- * Per-code docs URL. A string overrides
118
- * {@link DefineDiagnosticsOptions.docsBase} for this code; `false` opts this
119
- * code out entirely, even when `docsBase` is set. When omitted, the URL is
120
- * derived from `docsBase`.
121
- */
122
- docs?: string | false;
123
- }
124
- /**
125
- * Runtime-only fields that can be passed alongside the interpolation params
126
- * at call time. Merged into the same object so callers pass everything in
127
- * one place.
128
- */
129
- interface DiagnosticCallParams {
130
- /**
131
- * Original error or exception that triggered this diagnostic. Pass it
132
- * through when re-throwing so the original stack trace is preserved.
133
- */
134
- cause?: unknown;
135
- /**
136
- * Locations in user code that contributed to this diagnostic, in
137
- * `file:line:column` format. Useful for compilers and other tools where the
138
- * JS stack trace doesn't reflect the user's source.
139
- */
140
- sources?: string[];
141
- }
142
- /**
143
- * Structured initializer for a {@link Diagnostic}. `why` is the only required
144
- * field: it becomes the {@link Diagnostic.message}. The remaining fields are
145
- * optional metadata that reporters and consumers can render or forward.
146
- */
147
- interface DiagnosticInit extends DiagnosticCallParams {
148
- /**
149
- * The diagnostic code, e.g. `MATH_E001`. Appear as {@link Diagnostic.name}.
150
- */
151
- code: string;
152
- /**
153
- * The actual error message: why this failed.
154
- * Mirrored to `Error.message`.
155
- */
156
- why: string;
157
- /**
158
- * Optional actionable instructions on how to resolve the problem.
159
- */
160
- fix?: string;
161
- /**
162
- * URL to extended documentation for this diagnostic.
163
- */
164
- docs?: string;
165
- }
166
- /**
167
- * Permissive reporter constraint used internally so reporters with 1 arg,
168
- * required options, or optional options all satisfy the array constraint.
169
- *
170
- * @internal
171
- */
172
- type AnyDiagnosticReporter = (diagnostic: Diagnostic, options: any) => void;
173
- /**
174
- * Resolves the `params` type a code expects from the intersection of params
175
- * across all function-typed fields, falling back to `{}` when every field is
176
- * static. Merged with {@link DiagnosticCallParams} at the call site.
177
- *
178
- * @internal
179
- */
180
- type InferCodeParams<Def> = [ExtractFnParam<Def[keyof Def]>] extends [never] ? {} : UnionToIntersection<ExtractFnParam<Def[keyof Def]>>;
181
- /**
182
- * The first positional argument of a {@link DiagnosticHandle} call:
183
- * interpolation params merged with the runtime-only call-site fields
184
- * (`cause`, `sources`).
185
- *
186
- * @internal
187
- */
188
- type CallSiteParams<Params> = Params & DiagnosticCallParams;
189
- /**
190
- * Resolves the full argument tuple for a {@link DiagnosticHandle} call.
191
- * Branches on whether params and reporter options each have required fields.
192
- * Required positions become required tuple elements, all-optional ones
193
- * become `?`, and when no reporter declares any options the parameter is
194
- * omitted entirely.
195
- *
196
- * @internal
197
- */
198
- type ActionArgs<Params, ReporterOpts> = keyof ReporterOpts extends never ? {} extends Params ? [params?: CallSiteParams<Params>] : [params: CallSiteParams<Params>] : {} extends ReporterOpts ? {} extends Params ? [params?: CallSiteParams<Params>, reporterOptions?: ReporterOpts] : [params: CallSiteParams<Params>, reporterOptions?: ReporterOpts] : {} extends Params ? [params: CallSiteParams<Params> | undefined, reporterOptions: ReporterOpts] : [params: CallSiteParams<Params>, reporterOptions: ReporterOpts];
199
- /**
200
- * Per-code handle exposed by {@link defineDiagnostics}. Each code is a
201
- * callable: invoke it to build the diagnostic and run every reporter, or
202
- * prefix the call with `throw` to raise it.
203
- *
204
- * @example
205
- * ```ts
206
- * diagnostics.MATH_E001({ name: 'x' }) // report
207
- * throw diagnostics.MATH_E001({ name: 'x' }) // throw
208
- * ```
209
- */
210
- interface DiagnosticHandle<Params, ReporterOpts> {
211
- /**
212
- * Builds the diagnostic, runs every reporter, and returns the diagnostic
213
- * instance. The returned diagnostic can be inspected, attached as `cause`,
214
- * or thrown with `throw`.
215
- */
216
- (...args: ActionArgs<Params, ReporterOpts>): Diagnostic;
217
- }
218
- /**
219
- * Return type of {@link defineDiagnostics}.
220
- */
221
- type Diagnostics<Codes extends Record<string, DiagnosticDefinition>, Reporters extends readonly AnyDiagnosticReporter[]> = { [Code in keyof Codes]: DiagnosticHandle<InferCodeParams<Codes[Code]>, Prettify<ExtractReportersOptions<Reporters>>>; };
222
- declare class Diagnostic extends Error {
223
- name: string;
224
- /**
225
- * The diagnostic code, e.g. `MATH_E001`.
226
- * Also appears as the `name` property.
227
- */
228
- code: string;
229
- /**
230
- * URL to extended documentation for this diagnostic code.
231
- * Auto-generated from {@link DefineDiagnosticsOptions.docsBase}.
232
- */
233
- docs?: string;
234
- /**
235
- * Optional actionable instructions on how to resolve the problem.
236
- */
237
- fix?: string;
238
- /**
239
- * Locations in user code that contributed to this diagnostic, in
240
- * `file:line:column` format. Relevant when the stack trace doesn't reflect
241
- * the user's source (e.g. compilers, bundlers), otherwise redundant with the
242
- * stack and should be omitted.
243
- */
244
- sources?: string[];
245
- /**
246
- * Alias for {@link Error.message}: the reason this diagnostic was raised.
247
- */
248
- get why(): string;
249
- /**
250
- * @param init structured initializer; `why` is required
251
- * @param captureFrom V8 stack-cutoff frame. Defaults to {@link Diagnostic}
252
- * so the top of the trace is the `new Diagnostic(...)` call site.
253
- * `defineDiagnostics` passes its action method to strip its own frames too.
254
- * Ignored on engines without `Error.captureStackTrace`.
255
- */
256
- constructor(init: DiagnosticInit, captureFrom?: Function);
257
- /**
258
- * Converts the diagnostic into a serializable structured object.
259
- */
260
- toJSON(): object;
261
- }
262
- /**
263
- * Extracts the options object a reporter accepts as its 2nd argument. Returns
264
- * `{}` when the reporter has no 2nd arg (so it contributes nothing to the
265
- * merged shape).
266
- */
267
- type ExtractSingleReporterOptions<Reporter> = Reporter extends ((diagnostic: Diagnostic, options: infer ReporterOpts) => any) ? IsUnknown<ReporterOpts> extends true ? {} : Exclude<ReporterOpts, undefined> : {};
268
- /**
269
- * Intersects every reporter's options shape into a single object. If any
270
- * reporter has a required field, the merged shape has a required field, and
271
- * {@link ActionArgs} flips `reporterOptions` from optional to required via
272
- * `{} extends Merged`.
273
- */
274
- type ExtractReportersOptions<Reporters extends readonly any[]> = Reporters extends readonly [infer First, ...infer Rest] ? ExtractSingleReporterOptions<First> & ExtractReportersOptions<Rest> : {};
275
- //#endregion
276
49
  //#region src/node/diagnostics.d.ts
277
- /**
278
- * `@devframes/json-render` protocol/runtime diagnostics share the `DF`
279
- * prefix and use the next globally available core codes. Browser-only render
280
- * failures keep `console.*` in the UI package.
281
- */
282
- declare const diagnostics: Diagnostics<{
283
- readonly DF0038: {
284
- readonly why: (p: {
50
+ declare const codes: {
51
+ DF0038: {
52
+ why: (p: {
285
53
  id: string;
286
54
  key: string;
287
55
  issues: string;
288
56
  }) => string;
289
- readonly fix: "Match the element props to the base catalog's prop schema for that component. See the component reference for the expected shape.";
57
+ fix: string;
290
58
  };
291
- readonly DF0039: {
292
- readonly why: (p: {
59
+ DF0039: {
60
+ why: (p: {
293
61
  id: string;
294
62
  scope: string;
295
63
  }) => string;
296
- readonly fix: "Give each view a stable id unique within its scope, or dispose the previous view before recreating it.";
64
+ fix: string;
297
65
  };
298
- readonly DF0040: {
299
- readonly why: (p: {
66
+ DF0040: {
67
+ why: (p: {
300
68
  id: string;
301
69
  }) => string;
302
- readonly fix: "Create a fresh view with `createJsonRenderView` instead of reusing a disposed handle.";
70
+ fix: string;
303
71
  };
304
- readonly DF0041: {
305
- readonly why: (p: {
72
+ DF0041: {
73
+ why: (p: {
306
74
  id: string;
307
75
  reason: string;
308
76
  }) => string;
309
- readonly fix: "Specs and state travel as strict JSON, so remove functions, symbols, class instances, Map/Set, or circular references.";
77
+ fix: string;
310
78
  };
311
- readonly DF0073: {
312
- readonly why: (p: {
79
+ DF0073: {
80
+ why: (p: {
313
81
  id: string;
314
82
  issues: string;
315
83
  }) => string;
316
- readonly fix: "Match the authored spec to the Standard Schema passed to `createJsonRenderView`.";
84
+ fix: string;
317
85
  };
318
- readonly DF0074: {
319
- readonly why: (p: {
86
+ DF0074: {
87
+ why: (p: {
320
88
  id: string;
321
89
  }) => string;
322
- readonly fix: "Use a synchronous Standard Schema so initial creation and updates remain synchronous.";
90
+ fix: string;
323
91
  };
324
- }, readonly [(d: Diagnostic, { method }?: {
325
- method?: "log" | "warn" | "error";
326
- }) => void]>;
92
+ };
93
+ /**
94
+ * `@devframes/json-render` protocol/runtime diagnostics share the `DF`
95
+ * prefix and use the next globally available core codes. Browser-only render
96
+ * failures keep `console.*` in the UI package.
97
+ *
98
+ * Annotated with {@link DevframeDiagnostics} so the public type resolves
99
+ * through the `devframe/utils/nostics` peer rather than inlining `nostics`.
100
+ */
101
+ declare const diagnostics: DevframeDiagnostics<typeof codes>;
327
102
  //#endregion
328
103
  export { type CreateJsonRenderViewOptions, diagnostics as jsonRenderDiagnostics };
@@ -1,11 +1,13 @@
1
1
  import { b as basePropSchemas, t as JSON_RENDER_INDEX_KEY } from "../view-index-De3Gt127.mjs";
2
2
  import { createSharedState } from "devframe/utils/shared-state";
3
3
  import { defineDiagnostics } from "devframe/utils/nostics";
4
- //#region src/node/diagnostics.ts
5
4
  /**
6
5
  * `@devframes/json-render` protocol/runtime diagnostics share the `DF`
7
6
  * prefix and use the next globally available core codes. Browser-only render
8
7
  * failures keep `console.*` in the UI package.
8
+ *
9
+ * Annotated with {@link DevframeDiagnostics} so the public type resolves
10
+ * through the `devframe/utils/nostics` peer rather than inlining `nostics`.
9
11
  */
10
12
  const diagnostics = defineDiagnostics({
11
13
  docsBase: "https://devfra.me/errors",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devframes/json-render",
3
3
  "type": "module",
4
- "version": "0.9.20",
4
+ "version": "0.10.1",
5
5
  "description": "Protocol layer for describing devframe views as JSON that any renderer can display.",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -30,8 +30,8 @@
30
30
  "dist"
31
31
  ],
32
32
  "peerDependencies": {
33
- "@devframes/hub": "0.9.20",
34
- "devframe": "0.9.20"
33
+ "@devframes/hub": "0.10.1",
34
+ "devframe": "0.10.1"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@devframes/hub": {
@@ -40,13 +40,12 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@json-render/core": "^0.20.0",
43
- "@standard-schema/spec": "^1.1.0",
44
43
  "zod": "^4.6.5"
45
44
  },
46
45
  "devDependencies": {
47
- "@devframes/hub": "0.9.20",
46
+ "@devframes/hub": "0.10.1",
48
47
  "@types/node": "^26.5.1",
49
- "devframe": "0.9.20",
48
+ "devframe": "0.10.1",
50
49
  "tsdown": "^0.23.0"
51
50
  },
52
51
  "scripts": {