@devframes/json-render 0.9.0-beta.1 → 0.9.0-beta.10

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/dist/index.d.mts CHANGED
@@ -172,6 +172,7 @@ declare const SelectPropsSchema: z.ZodObject<{
172
172
  label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodIntersection<z.ZodObject<{}, z.core.$loose>, z.ZodRecord<z.ZodString, z.ZodUnknown>>]>>;
173
173
  disabled: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodIntersection<z.ZodObject<{}, z.core.$loose>, z.ZodRecord<z.ZodString, z.ZodUnknown>>]>>;
174
174
  searchable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodIntersection<z.ZodObject<{}, z.core.$loose>, z.ZodRecord<z.ZodString, z.ZodUnknown>>]>>;
175
+ native: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodIntersection<z.ZodObject<{}, z.core.$loose>, z.ZodRecord<z.ZodString, z.ZodUnknown>>]>>;
175
176
  }, z.core.$strip>;
176
177
  /**
177
178
  * Map of base-catalog component name → Zod prop schema. The keys are the
@@ -349,6 +350,7 @@ declare const basePropSchemas: {
349
350
  label: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodIntersection<z.ZodObject<{}, z.core.$loose>, z.ZodRecord<z.ZodString, z.ZodUnknown>>]>>;
350
351
  disabled: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodIntersection<z.ZodObject<{}, z.core.$loose>, z.ZodRecord<z.ZodString, z.ZodUnknown>>]>>;
351
352
  searchable: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodIntersection<z.ZodObject<{}, z.core.$loose>, z.ZodRecord<z.ZodString, z.ZodUnknown>>]>>;
353
+ native: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodIntersection<z.ZodObject<{}, z.core.$loose>, z.ZodRecord<z.ZodString, z.ZodUnknown>>]>>;
352
354
  }, z.core.$strip>;
353
355
  };
354
356
  /** Canonical base-catalog component name. */
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as TextPropsSchema, a as CodeBlockPropsSchema, b as basePropSchemas, c as IconPropsSchema, d as ProgressPropsSchema, f as SelectPropsSchema, g as TextInputPropsSchema, h as TabsPropsSchema, i as CardPropsSchema, l as KeyValueTablePropsSchema, m as SwitchPropsSchema, n as BadgePropsSchema, o as DataTablePropsSchema, p as StackPropsSchema, r as ButtonPropsSchema, s as DividerPropsSchema, t as JSON_RENDER_INDEX_KEY, u as LinkPropsSchema, v as TreePropsSchema, y as baseComponentNames } from "./view-index-CUg7TaB4.mjs";
1
+ import { _ as TextPropsSchema, a as CodeBlockPropsSchema, b as basePropSchemas, c as IconPropsSchema, d as ProgressPropsSchema, f as SelectPropsSchema, g as TextInputPropsSchema, h as TabsPropsSchema, i as CardPropsSchema, l as KeyValueTablePropsSchema, m as SwitchPropsSchema, n as BadgePropsSchema, o as DataTablePropsSchema, p as StackPropsSchema, r as ButtonPropsSchema, s as DividerPropsSchema, t as JSON_RENDER_INDEX_KEY, u as LinkPropsSchema, v as TreePropsSchema, y as baseComponentNames } from "./view-index-CJ8aJJLZ.mjs";
2
2
  import { defineCatalog, defineSchema } from "@json-render/core";
3
3
  //#region src/catalog.ts
4
4
  /**
@@ -42,7 +42,7 @@ const componentDescriptions = {
42
42
  Tree: "Recursive object/array viewer with expandable nodes.",
43
43
  Tabs: "Tabbed container; each child renders under the positionally-matching tab.",
44
44
  Link: "Hyperlink to a safe-scheme URL with an optional icon.",
45
- Select: "Single-select dropdown bound to a state value, with optional search."
45
+ Select: "Single-select dropdown bound to a state value, with optional search or a native `<select>` fallback."
46
46
  };
47
47
  /**
48
48
  * The Devframes base catalog (catalog v1): the seventeen canonical components
@@ -1,5 +1,4 @@
1
1
  import { n as JsonRenderView, t as DevframeJsonRenderSpec } from "../types-CC2-FD2H.mjs";
2
- import { Diagnostic } from "nostics";
3
2
  import { DevframeNodeContext, DevframeScopedNodeContext } from "devframe";
4
3
  //#region src/node/create-view.d.ts
5
4
  /** Options for {@link createJsonRenderView}. */
@@ -43,12 +42,236 @@ type AnyContext = DevframeNodeContext | DevframeScopedNodeContext<string>;
43
42
  */
44
43
  declare function createJsonRenderView(ctx: AnyContext, options: CreateJsonRenderViewOptions): JsonRenderView;
45
44
  //#endregion
46
- //#region src/node/diagnostics.d.ts
47
- interface ReporterOptions {
48
- method?: 'log' | 'warn' | 'error';
45
+ //#region ../../node_modules/.pnpm/nostics@1.2.0/node_modules/nostics/dist/diagnostic-wduO7saY.d.mts
46
+ //#region src/utils.d.ts
47
+ /**
48
+ * A value of type T, or a function that resolves T from a single params object.
49
+ *
50
+ * @internal
51
+ */
52
+ type ValueOrFn<T, P = any> = T | ((params: P) => T);
53
+ /**
54
+ * Extracts the param type from a single-arg function, or `never` for
55
+ * non-function inputs. Pairs with {@link ValueOrFn}.
56
+ *
57
+ * @internal
58
+ */
59
+ type ExtractFnParam<T> = T extends ((params: infer P) => any) ? P : never;
60
+ /**
61
+ * Converts a union of types to their intersection.
62
+ *
63
+ * @internal
64
+ */
65
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
66
+ /**
67
+ * `true` when `T` is the `any` type.
68
+ *
69
+ * @internal
70
+ */
71
+ type IsAny<Type> = 0 extends 1 & Type ? true : false;
72
+ /**
73
+ * `true` when `T` is the `unknown` type (and not `any`).
74
+ *
75
+ * @internal
76
+ */
77
+ type IsUnknown<Type> = IsAny<Type> extends true ? false : unknown extends Type ? true : false;
78
+ /**
79
+ * Expands a type to its property listing so editor hovers show the resolved
80
+ * shape instead of a chain of aliases / intersections.
81
+ *
82
+ * @internal
83
+ */
84
+ type Prettify<Type> = { [Key in keyof Type]: Type[Key]; };
85
+ //#endregion
86
+ //#region src/diagnostic.d.ts
87
+ /**
88
+ * Define-time shape of a diagnostic. Each field can be a static value or a
89
+ * function that resolves it from a shared `params` object passed at call
90
+ * time. Runtime-only fields (`cause`, `sources`) from {@link DiagnosticInit}
91
+ * are intentionally omitted: they're only meaningful at the call site.
92
+ */
93
+ interface DiagnosticDefinition<P = any> {
94
+ /**
95
+ * The error message: why this failed. String, or a function of `params`.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * why: (p: { name: string }) => `module "${p.name}" failed to load`
100
+ * ```
101
+ */
102
+ why: ValueOrFn<string, P>;
103
+ /**
104
+ * Actionable instructions on how to resolve the problem. String, or a
105
+ * function of `params`.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * fix: (p: { name: string }) => `run "npm install ${p.name}"`
110
+ * ```
111
+ */
112
+ fix?: ValueOrFn<string, P>;
113
+ /**
114
+ * Per-code docs URL. A string overrides
115
+ * {@link DefineDiagnosticsOptions.docsBase} for this code; `false` opts this
116
+ * code out entirely, even when `docsBase` is set. When omitted, the URL is
117
+ * derived from `docsBase`.
118
+ */
119
+ docs?: string | false;
120
+ }
121
+ /**
122
+ * Runtime-only fields that can be passed alongside the interpolation params
123
+ * at call time. Merged into the same object so callers pass everything in
124
+ * one place.
125
+ */
126
+ interface DiagnosticCallParams {
127
+ /**
128
+ * Original error or exception that triggered this diagnostic. Pass it
129
+ * through when re-throwing so the original stack trace is preserved.
130
+ */
131
+ cause?: unknown;
132
+ /**
133
+ * Locations in user code that contributed to this diagnostic, in
134
+ * `file:line:column` format. Useful for compilers and other tools where the
135
+ * JS stack trace doesn't reflect the user's source.
136
+ */
137
+ sources?: string[];
138
+ }
139
+ /**
140
+ * Structured initializer for a {@link Diagnostic}. `why` is the only required
141
+ * field: it becomes the {@link Diagnostic.message}. The remaining fields are
142
+ * optional metadata that reporters and consumers can render or forward.
143
+ */
144
+ interface DiagnosticInit extends DiagnosticCallParams {
145
+ /**
146
+ * The diagnostic code, e.g. `MATH_E001`. Appear as {@link Diagnostic.name}.
147
+ */
148
+ code: string;
149
+ /**
150
+ * The actual error message: why this failed.
151
+ * Mirrored to `Error.message`.
152
+ */
153
+ why: string;
154
+ /**
155
+ * Optional actionable instructions on how to resolve the problem.
156
+ */
157
+ fix?: string;
158
+ /**
159
+ * URL to extended documentation for this diagnostic.
160
+ */
161
+ docs?: string;
49
162
  }
50
- declare function jsonRenderReporter(d: Diagnostic, { method }?: ReporterOptions): void;
51
- declare const diagnostics: import("nostics").Diagnostics<{
163
+ /**
164
+ * Permissive reporter constraint used internally so reporters with 1 arg,
165
+ * required options, or optional options all satisfy the array constraint.
166
+ *
167
+ * @internal
168
+ */
169
+ type AnyDiagnosticReporter = (diagnostic: Diagnostic, options: any) => void;
170
+ /**
171
+ * Resolves the `params` type a code expects from the intersection of params
172
+ * across all function-typed fields, falling back to `{}` when every field is
173
+ * static. Merged with {@link DiagnosticCallParams} at the call site.
174
+ *
175
+ * @internal
176
+ */
177
+ type InferCodeParams<Def> = [ExtractFnParam<Def[keyof Def]>] extends [never] ? {} : UnionToIntersection<ExtractFnParam<Def[keyof Def]>>;
178
+ /**
179
+ * The first positional argument of a {@link DiagnosticHandle} call:
180
+ * interpolation params merged with the runtime-only call-site fields
181
+ * (`cause`, `sources`).
182
+ *
183
+ * @internal
184
+ */
185
+ type CallSiteParams<Params> = Params & DiagnosticCallParams;
186
+ /**
187
+ * Resolves the full argument tuple for a {@link DiagnosticHandle} call.
188
+ * Branches on whether params and reporter options each have required fields.
189
+ * Required positions become required tuple elements, all-optional ones
190
+ * become `?`, and when no reporter declares any options the parameter is
191
+ * omitted entirely.
192
+ *
193
+ * @internal
194
+ */
195
+ 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];
196
+ /**
197
+ * Per-code handle exposed by {@link defineDiagnostics}. Each code is a
198
+ * callable: invoke it to build the diagnostic and run every reporter, or
199
+ * prefix the call with `throw` to raise it.
200
+ *
201
+ * @example
202
+ * ```ts
203
+ * diagnostics.MATH_E001({ name: 'x' }) // report
204
+ * throw diagnostics.MATH_E001({ name: 'x' }) // throw
205
+ * ```
206
+ */
207
+ interface DiagnosticHandle<Params, ReporterOpts> {
208
+ /**
209
+ * Builds the diagnostic, runs every reporter, and returns the diagnostic
210
+ * instance. The returned diagnostic can be inspected, attached as `cause`,
211
+ * or thrown with `throw`.
212
+ */
213
+ (...args: ActionArgs<Params, ReporterOpts>): Diagnostic;
214
+ }
215
+ /**
216
+ * Return type of {@link defineDiagnostics}.
217
+ */
218
+ type Diagnostics<Codes extends Record<string, DiagnosticDefinition>, Reporters extends readonly AnyDiagnosticReporter[]> = { [Code in keyof Codes]: DiagnosticHandle<InferCodeParams<Codes[Code]>, Prettify<ExtractReportersOptions<Reporters>>>; };
219
+ declare class Diagnostic extends Error {
220
+ name: string;
221
+ /**
222
+ * The diagnostic code, e.g. `MATH_E001`.
223
+ * Also appears as the `name` property.
224
+ */
225
+ code: string;
226
+ /**
227
+ * URL to extended documentation for this diagnostic code.
228
+ * Auto-generated from {@link DefineDiagnosticsOptions.docsBase}.
229
+ */
230
+ docs?: string;
231
+ /**
232
+ * Optional actionable instructions on how to resolve the problem.
233
+ */
234
+ fix?: string;
235
+ /**
236
+ * Locations in user code that contributed to this diagnostic, in
237
+ * `file:line:column` format. Relevant when the stack trace doesn't reflect
238
+ * the user's source (e.g. compilers, bundlers), otherwise redundant with the
239
+ * stack and should be omitted.
240
+ */
241
+ sources?: string[];
242
+ /**
243
+ * Alias for {@link Error.message}: the reason this diagnostic was raised.
244
+ */
245
+ get why(): string;
246
+ /**
247
+ * @param init structured initializer; `why` is required
248
+ * @param captureFrom V8 stack-cutoff frame. Defaults to {@link Diagnostic}
249
+ * so the top of the trace is the `new Diagnostic(...)` call site.
250
+ * `defineDiagnostics` passes its action method to strip its own frames too.
251
+ * Ignored on engines without `Error.captureStackTrace`.
252
+ */
253
+ constructor(init: DiagnosticInit, captureFrom?: Function);
254
+ /**
255
+ * Converts the diagnostic into a serializable structured object.
256
+ */
257
+ toJSON(): object;
258
+ }
259
+ /**
260
+ * Extracts the options object a reporter accepts as its 2nd argument. Returns
261
+ * `{}` when the reporter has no 2nd arg (so it contributes nothing to the
262
+ * merged shape).
263
+ */
264
+ type ExtractSingleReporterOptions<Reporter> = Reporter extends ((diagnostic: Diagnostic, options: infer ReporterOpts) => any) ? IsUnknown<ReporterOpts> extends true ? {} : Exclude<ReporterOpts, undefined> : {};
265
+ /**
266
+ * Intersects every reporter's options shape into a single object. If any
267
+ * reporter has a required field, the merged shape has a required field, and
268
+ * {@link ActionArgs} flips `reporterOptions` from optional to required via
269
+ * `{} extends Merged`.
270
+ */
271
+ type ExtractReportersOptions<Reporters extends readonly any[]> = Reporters extends readonly [infer First, ...infer Rest] ? ExtractSingleReporterOptions<First> & ExtractReportersOptions<Rest> : {};
272
+ //#endregion
273
+ //#region src/node/diagnostics.d.ts
274
+ declare const diagnostics: Diagnostics<{
52
275
  readonly DF0038: {
53
276
  readonly why: (p: {
54
277
  id: string;
@@ -77,6 +300,8 @@ declare const diagnostics: import("nostics").Diagnostics<{
77
300
  }) => string;
78
301
  readonly fix: "Specs and state travel as strict JSON — remove functions, symbols, class instances, Map/Set, or circular references.";
79
302
  };
80
- }, readonly [typeof jsonRenderReporter]>;
303
+ }, readonly [(d: Diagnostic, { method }?: {
304
+ method?: "log" | "warn" | "error";
305
+ }) => void]>;
81
306
  //#endregion
82
307
  export { type CreateJsonRenderViewOptions, createJsonRenderView, diagnostics as jsonRenderDiagnostics };
@@ -1,16 +1,9 @@
1
- import { b as basePropSchemas, t as JSON_RENDER_INDEX_KEY } from "../view-index-CUg7TaB4.mjs";
1
+ import { b as basePropSchemas, t as JSON_RENDER_INDEX_KEY } from "../view-index-CJ8aJJLZ.mjs";
2
2
  import { createSharedState } from "devframe/utils/shared-state";
3
- import { colors } from "devframe/utils/colors";
4
- import { defineDiagnostics } from "nostics";
5
- import { ansiFormatter } from "nostics/formatters/ansi";
3
+ import { defineDiagnostics } from "devframe/utils/nostics";
6
4
  //#region src/node/diagnostics.ts
7
- const formatAnsi = ansiFormatter(colors);
8
- function jsonRenderReporter(d, { method = "warn" } = {}) {
9
- console[method](formatAnsi(d));
10
- }
11
5
  const diagnostics = defineDiagnostics({
12
6
  docsBase: "https://devfra.me/errors",
13
- reporters: [jsonRenderReporter],
14
7
  codes: {
15
8
  DF0038: {
16
9
  why: (p) => `JSON-render view "${p.id}" received invalid props on element "${p.key}": ${p.issues}`,
@@ -182,7 +182,8 @@ const SelectPropsSchema = z.object({
182
182
  placeholder: str.optional(),
183
183
  label: str.optional(),
184
184
  disabled: bool.optional(),
185
- searchable: bool.optional()
185
+ searchable: bool.optional(),
186
+ native: bool.optional()
186
187
  });
187
188
  /**
188
189
  * Map of base-catalog component name → Zod prop schema. The keys are the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devframes/json-render",
3
3
  "type": "module",
4
- "version": "0.9.0-beta.1",
4
+ "version": "0.9.0-beta.10",
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.0-beta.1",
34
- "devframe": "0.9.0-beta.1"
33
+ "@devframes/hub": "0.9.0-beta.10",
34
+ "devframe": "0.9.0-beta.10"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@devframes/hub": {
@@ -40,14 +40,13 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@json-render/core": "^0.19.0",
43
- "nostics": "^1.2.0",
44
43
  "zod": "^4.4.3"
45
44
  },
46
45
  "devDependencies": {
47
46
  "@types/node": "^26.2.0",
48
47
  "tsdown": "^0.22.14",
49
- "@devframes/hub": "0.9.0-beta.1",
50
- "devframe": "0.9.0-beta.1"
48
+ "devframe": "0.9.0-beta.10",
49
+ "@devframes/hub": "0.9.0-beta.10"
51
50
  },
52
51
  "scripts": {
53
52
  "build": "tsdown",