@devframes/json-render 0.7.8 → 0.7.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/hub.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as JsonRenderViewRef, n as JsonRenderView } from "./types-DafC9dUn.mjs";
1
+ import { i as JsonRenderViewRef, n as JsonRenderView } from "./types-Di-9QrXX.mjs";
2
2
  import { DevframeDockEntryBase } from "@devframes/hub/types";
3
3
  //#region src/hub.d.ts
4
4
  /**
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Catalog, InferComponentProps, Spec, StateModel, StateStore, UIElement } from "./core.mjs";
2
- import { i as JsonRenderViewRef, n as JsonRenderView, r as JSON_RENDER_UPSTREAM_VERSION, t as DevframeJsonRenderSpec } from "./types-DafC9dUn.mjs";
2
+ import { i as JsonRenderViewRef, n as JsonRenderView, r as JSON_RENDER_UPSTREAM_VERSION, t as DevframeJsonRenderSpec } from "./types-Di-9QrXX.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/prop-schemas.d.ts
5
5
  declare const StackPropsSchema: z.ZodObject<{
@@ -334,4 +334,36 @@ declare const baseCatalog: import("@json-render/core").Catalog<{
334
334
  actions: {};
335
335
  }>;
336
336
  //#endregion
337
- export { BadgePropsSchema, type BaseComponentName, ButtonPropsSchema, CardPropsSchema, type Catalog, CodeBlockPropsSchema, DataTablePropsSchema, type DevframeJsonRenderSpec, DividerPropsSchema, IconPropsSchema, type InferComponentProps, JSON_RENDER_UPSTREAM_VERSION, type JsonRenderView, type JsonRenderViewRef, KeyValueTablePropsSchema, ProgressPropsSchema, type Spec, StackPropsSchema, type StateModel, type StateStore, SwitchPropsSchema, TextInputPropsSchema, TextPropsSchema, TreePropsSchema, type UIElement, baseCatalog, baseComponentNames, basePropSchemas, baseSchema };
337
+ //#region src/view-index.d.ts
338
+ /**
339
+ * Well-known shared-state key carrying the **view index**: a map of every
340
+ * live JSON-render view registered on a context, keyed by its `stateKey`.
341
+ *
342
+ * A frontend that does not know view ids ahead of time (e.g. the prebuilt
343
+ * standalone SPA in `@devframes/json-render-ui`) subscribes to this one key to
344
+ * discover which views exist, then subscribes to each view's own state. A hub
345
+ * dock, by contrast, is handed a specific {@link JsonRenderViewRef} and needs
346
+ * no index.
347
+ */
348
+ declare const JSON_RENDER_INDEX_KEY = "devframe:json-render:index";
349
+ /**
350
+ * One entry in the {@link JSON_RENDER_INDEX_KEY view index}. Fully
351
+ * serializable: it locates a view's live state and carries the display title a
352
+ * multi-view frontend uses to label it.
353
+ */
354
+ interface JsonRenderIndexEntry {
355
+ /** Author-supplied stable id, unique within the view's scope. */
356
+ id: string;
357
+ /** The view's scope segment (e.g. `global` or a context namespace). */
358
+ scope: string;
359
+ /** Shared-state key the client subscribes to for the live spec + state. */
360
+ stateKey: string;
361
+ /** Human-facing label for the view (defaults to `id`). */
362
+ title: string;
363
+ /** Upstream `@json-render/*` version the view was authored against. */
364
+ upstreamVersion: string;
365
+ }
366
+ /** The shape of the view-index shared state: entries keyed by `stateKey`. */
367
+ type JsonRenderIndex = Record<string, JsonRenderIndexEntry>;
368
+ //#endregion
369
+ export { BadgePropsSchema, type BaseComponentName, ButtonPropsSchema, CardPropsSchema, type Catalog, CodeBlockPropsSchema, DataTablePropsSchema, type DevframeJsonRenderSpec, DividerPropsSchema, IconPropsSchema, type InferComponentProps, JSON_RENDER_INDEX_KEY, JSON_RENDER_UPSTREAM_VERSION, type JsonRenderIndex, type JsonRenderIndexEntry, type JsonRenderView, type JsonRenderViewRef, KeyValueTablePropsSchema, ProgressPropsSchema, type Spec, StackPropsSchema, type StateModel, type StateStore, SwitchPropsSchema, TextInputPropsSchema, TextPropsSchema, TreePropsSchema, type UIElement, baseCatalog, baseComponentNames, basePropSchemas, baseSchema };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as basePropSchemas, a as CodeBlockPropsSchema, c as IconPropsSchema, d as StackPropsSchema, f as SwitchPropsSchema, g as baseComponentNames, h as TreePropsSchema, i as CardPropsSchema, l as KeyValueTablePropsSchema, m as TextPropsSchema, n as BadgePropsSchema, o as DataTablePropsSchema, p as TextInputPropsSchema, r as ButtonPropsSchema, s as DividerPropsSchema, t as JSON_RENDER_UPSTREAM_VERSION, u as ProgressPropsSchema } from "./view-ref-70LHsEHb.mjs";
1
+ import { _ as baseComponentNames, a as CardPropsSchema, c as DividerPropsSchema, d as ProgressPropsSchema, f as StackPropsSchema, g as TreePropsSchema, h as TextPropsSchema, i as ButtonPropsSchema, l as IconPropsSchema, m as TextInputPropsSchema, n as JSON_RENDER_INDEX_KEY, o as CodeBlockPropsSchema, p as SwitchPropsSchema, r as BadgePropsSchema, s as DataTablePropsSchema, t as JSON_RENDER_UPSTREAM_VERSION, u as KeyValueTablePropsSchema, v as basePropSchemas } from "./view-ref-B_nBPfeR.mjs";
2
2
  import { defineCatalog, defineSchema } from "@json-render/core";
3
3
  //#region src/catalog.ts
4
4
  /**
@@ -55,4 +55,4 @@ const baseCatalog = defineCatalog(baseSchema, {
55
55
  actions: {}
56
56
  });
57
57
  //#endregion
58
- export { BadgePropsSchema, ButtonPropsSchema, CardPropsSchema, CodeBlockPropsSchema, DataTablePropsSchema, DividerPropsSchema, IconPropsSchema, JSON_RENDER_UPSTREAM_VERSION, KeyValueTablePropsSchema, ProgressPropsSchema, StackPropsSchema, SwitchPropsSchema, TextInputPropsSchema, TextPropsSchema, TreePropsSchema, baseCatalog, baseComponentNames, basePropSchemas, baseSchema };
58
+ export { BadgePropsSchema, ButtonPropsSchema, CardPropsSchema, CodeBlockPropsSchema, DataTablePropsSchema, DividerPropsSchema, IconPropsSchema, JSON_RENDER_INDEX_KEY, JSON_RENDER_UPSTREAM_VERSION, KeyValueTablePropsSchema, ProgressPropsSchema, StackPropsSchema, SwitchPropsSchema, TextInputPropsSchema, TextPropsSchema, TreePropsSchema, baseCatalog, baseComponentNames, basePropSchemas, baseSchema };
@@ -1,4 +1,4 @@
1
- import { n as JsonRenderView, t as DevframeJsonRenderSpec } from "../types-DafC9dUn.mjs";
1
+ import { n as JsonRenderView, t as DevframeJsonRenderSpec } from "../types-Di-9QrXX.mjs";
2
2
  import { Diagnostic } from "nostics";
3
3
  import { DevframeNodeContext, DevframeScopedNodeContext } from "devframe/types";
4
4
  //#region src/node/create-view.d.ts
@@ -18,6 +18,12 @@ interface CreateJsonRenderViewOptions {
18
18
  * `'global'`.
19
19
  */
20
20
  scope?: string;
21
+ /**
22
+ * Human-facing label published in the view index and used by a multi-view
23
+ * frontend (e.g. the standalone SPA's view switcher) to name this view.
24
+ * Defaults to {@link CreateJsonRenderViewOptions.id}.
25
+ */
26
+ title?: string;
21
27
  }
22
28
  type AnyContext = DevframeNodeContext | DevframeScopedNodeContext<string>;
23
29
  /**
@@ -1,4 +1,4 @@
1
- import { _ as basePropSchemas, t as JSON_RENDER_UPSTREAM_VERSION } from "../view-ref-70LHsEHb.mjs";
1
+ import { n as JSON_RENDER_INDEX_KEY, t as JSON_RENDER_UPSTREAM_VERSION, v as basePropSchemas } from "../view-ref-B_nBPfeR.mjs";
2
2
  import { createSharedState } from "devframe/utils/shared-state";
3
3
  import { colors } from "devframe/utils/colors";
4
4
  import { defineDiagnostics } from "nostics";
@@ -44,6 +44,16 @@ function registryFor(ctx) {
44
44
  }
45
45
  return set;
46
46
  }
47
+ const indexStates = /* @__PURE__ */ new WeakMap();
48
+ function indexStateFor(ctx) {
49
+ let state = indexStates.get(ctx);
50
+ if (!state) {
51
+ state = createSharedState({ initialValue: {} });
52
+ indexStates.set(ctx, state);
53
+ ctx.rpc.sharedState.get(JSON_RENDER_INDEX_KEY, { sharedState: state });
54
+ }
55
+ return state;
56
+ }
47
57
  /** Parse an RFC 6901 JSON Pointer into path segments. */
48
58
  function parsePointer(pointer) {
49
59
  if (pointer === "" || pointer === "/") return [];
@@ -100,6 +110,7 @@ function createJsonRenderView(ctx, options) {
100
110
  const baseCtx = scoped ? ctx.base : ctx;
101
111
  const scope = options.scope ?? (scoped ? ctx.namespace : "global");
102
112
  const { id } = options;
113
+ const title = options.title ?? id;
103
114
  const stateKey = `devframe:json-render:${scope}:${id}`;
104
115
  const registry = registryFor(baseCtx);
105
116
  if (registry.has(stateKey)) throw diagnostics.DF0039({
@@ -115,12 +126,23 @@ function createJsonRenderView(ctx, options) {
115
126
  });
116
127
  registry.add(stateKey);
117
128
  baseCtx.rpc.sharedState.get(stateKey, { sharedState: state });
129
+ const index = indexStateFor(baseCtx);
130
+ index.mutate((idx) => {
131
+ idx[stateKey] = {
132
+ id,
133
+ scope,
134
+ stateKey,
135
+ title,
136
+ upstreamVersion: JSON_RENDER_UPSTREAM_VERSION
137
+ };
138
+ });
118
139
  let disposed = false;
119
140
  function assertLive() {
120
141
  if (disposed) throw diagnostics.DF0040({ id });
121
142
  }
122
143
  return {
123
144
  id,
145
+ title,
124
146
  ref: {
125
147
  stateKey,
126
148
  upstreamVersion: JSON_RENDER_UPSTREAM_VERSION
@@ -146,6 +168,9 @@ function createJsonRenderView(ctx, options) {
146
168
  if (disposed) return;
147
169
  disposed = true;
148
170
  registry.delete(stateKey);
171
+ index.mutate((idx) => {
172
+ delete idx[stateKey];
173
+ });
149
174
  baseCtx.rpc.sharedState.delete(stateKey);
150
175
  }
151
176
  };
@@ -59,6 +59,8 @@ interface JsonRenderStatePatch {
59
59
  interface JsonRenderView {
60
60
  /** Author-supplied stable id, unique within the view's scope. */
61
61
  readonly id: string;
62
+ /** Human-facing label published in the view index (defaults to `id`). */
63
+ readonly title: string;
62
64
  /** The serializable reference clients subscribe through. */
63
65
  readonly ref: JsonRenderViewRef;
64
66
  /** Replace the entire spec (a structural change replaces the whole spec). */
@@ -170,6 +170,19 @@ const basePropSchemas = {
170
170
  /** The ordered list of base-catalog component names (catalog v1). */
171
171
  const baseComponentNames = Object.keys(basePropSchemas);
172
172
  //#endregion
173
+ //#region src/view-index.ts
174
+ /**
175
+ * Well-known shared-state key carrying the **view index**: a map of every
176
+ * live JSON-render view registered on a context, keyed by its `stateKey`.
177
+ *
178
+ * A frontend that does not know view ids ahead of time (e.g. the prebuilt
179
+ * standalone SPA in `@devframes/json-render-ui`) subscribes to this one key to
180
+ * discover which views exist, then subscribes to each view's own state. A hub
181
+ * dock, by contrast, is handed a specific {@link JsonRenderViewRef} and needs
182
+ * no index.
183
+ */
184
+ const JSON_RENDER_INDEX_KEY = "devframe:json-render:index";
185
+ //#endregion
173
186
  //#region src/view-ref.ts
174
187
  /**
175
188
  * The `@json-render/core` / `@json-render/vue` version this build of
@@ -185,4 +198,4 @@ const baseComponentNames = Object.keys(basePropSchemas);
185
198
  */
186
199
  const JSON_RENDER_UPSTREAM_VERSION = "0.19.0";
187
200
  //#endregion
188
- export { basePropSchemas as _, CodeBlockPropsSchema as a, IconPropsSchema as c, StackPropsSchema as d, SwitchPropsSchema as f, baseComponentNames as g, TreePropsSchema as h, CardPropsSchema as i, KeyValueTablePropsSchema as l, TextPropsSchema as m, BadgePropsSchema as n, DataTablePropsSchema as o, TextInputPropsSchema as p, ButtonPropsSchema as r, DividerPropsSchema as s, JSON_RENDER_UPSTREAM_VERSION as t, ProgressPropsSchema as u };
201
+ export { baseComponentNames as _, CardPropsSchema as a, DividerPropsSchema as c, ProgressPropsSchema as d, StackPropsSchema as f, TreePropsSchema as g, TextPropsSchema as h, ButtonPropsSchema as i, IconPropsSchema as l, TextInputPropsSchema as m, JSON_RENDER_INDEX_KEY as n, CodeBlockPropsSchema as o, SwitchPropsSchema as p, BadgePropsSchema as r, DataTablePropsSchema as s, JSON_RENDER_UPSTREAM_VERSION as t, KeyValueTablePropsSchema as u, basePropSchemas as v };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@devframes/json-render",
3
3
  "type": "module",
4
- "version": "0.7.8",
4
+ "version": "0.7.10",
5
5
  "description": "Opt-in, framework-neutral JSON-render protocol layer for devframe — spec/catalog types, base catalog, and the node runtime factory.",
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.7.8",
34
- "devframe": "0.7.8"
33
+ "@devframes/hub": "0.7.10",
34
+ "devframe": "0.7.10"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@devframes/hub": {
@@ -46,8 +46,8 @@
46
46
  "devDependencies": {
47
47
  "@types/node": "^26.1.1",
48
48
  "tsdown": "^0.22.12",
49
- "@devframes/hub": "0.7.8",
50
- "devframe": "0.7.8"
49
+ "@devframes/hub": "0.7.10",
50
+ "devframe": "0.7.10"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "tsdown",