ngx-json-render 0.8.0 → 0.8.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.
- package/README.md +63 -2
- package/fesm2022/ngx-json-render-devtools.mjs +262 -0
- package/fesm2022/ngx-json-render-devtools.mjs.map +1 -0
- package/fesm2022/ngx-json-render.mjs +49 -3
- package/fesm2022/ngx-json-render.mjs.map +1 -1
- package/package.json +10 -2
- package/schematics/ng-add/index.cjs +1 -1
- package/types/ngx-json-render-devtools.d.ts +67 -0
- package/types/ngx-json-render.d.ts +32 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-json-render",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Angular renderer for json-render — stream AI-generated JSON specs into real Angular components with signals.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"@json-render/core": ">=0.20.0 <0.22.0",
|
|
28
28
|
"zod": "^4.0.0",
|
|
29
29
|
"@modelcontextprotocol/ext-apps": "^1.7.5",
|
|
30
|
-
"@modelcontextprotocol/sdk": "^1.29.0"
|
|
30
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
31
|
+
"@json-render/devtools": ">=0.20.0 <0.22.0"
|
|
31
32
|
},
|
|
32
33
|
"peerDependenciesMeta": {
|
|
33
34
|
"@modelcontextprotocol/ext-apps": {
|
|
@@ -35,6 +36,9 @@
|
|
|
35
36
|
},
|
|
36
37
|
"@modelcontextprotocol/sdk": {
|
|
37
38
|
"optional": true
|
|
39
|
+
},
|
|
40
|
+
"@json-render/devtools": {
|
|
41
|
+
"optional": true
|
|
38
42
|
}
|
|
39
43
|
},
|
|
40
44
|
"dependencies": {
|
|
@@ -55,6 +59,10 @@
|
|
|
55
59
|
"types": "./types/ngx-json-render.d.ts",
|
|
56
60
|
"default": "./fesm2022/ngx-json-render.mjs"
|
|
57
61
|
},
|
|
62
|
+
"./devtools": {
|
|
63
|
+
"types": "./types/ngx-json-render-devtools.d.ts",
|
|
64
|
+
"default": "./fesm2022/ngx-json-render-devtools.mjs"
|
|
65
|
+
},
|
|
58
66
|
"./mcp": {
|
|
59
67
|
"types": "./types/ngx-json-render-mcp.d.ts",
|
|
60
68
|
"default": "./fesm2022/ngx-json-render-mcp.mjs"
|
|
@@ -32,7 +32,7 @@ function ngAdd() {
|
|
|
32
32
|
'ngx-json-render is ready. Next: describe your components in a catalog,',
|
|
33
33
|
`register them, and render a spec with <json-render> — see ${README}`,
|
|
34
34
|
'No components of your own yet? `ng add ngx-json-render-material` adds',
|
|
35
|
-
'
|
|
35
|
+
'29 ready-made Angular Material ones.',
|
|
36
36
|
].join('\n'));
|
|
37
37
|
return (0, schematics_1.chain)(rules);
|
|
38
38
|
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as _json_render_core from '@json-render/core';
|
|
2
|
+
import { Spec, Catalog } from '@json-render/core';
|
|
3
|
+
import * as _angular_core from '@angular/core';
|
|
4
|
+
import { PanelPosition, DevtoolsEvent } from '@json-render/devtools';
|
|
5
|
+
export { DevtoolsEvent, PanelPosition } from '@json-render/devtools';
|
|
6
|
+
import { JsonRenderer, ChatUIReturn } from 'ngx-json-render';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A floating json-render devtools panel for an Angular app — the counterpart
|
|
10
|
+
* of `<JsonRenderDevtools />` in `@json-render/devtools-react`, `-vue`,
|
|
11
|
+
* `-svelte` and `-solid`, with the same tabs (Spec, State, Actions, Stream,
|
|
12
|
+
* Catalog) and the same element picker.
|
|
13
|
+
*
|
|
14
|
+
* Angular has no provider above `<json-render>` to read the renderer from, so
|
|
15
|
+
* the renderer is passed in by template reference. Streams need no wiring:
|
|
16
|
+
* every `injectUIStream` and `injectChatUI` generation in the app reaches the
|
|
17
|
+
* Stream tab.
|
|
18
|
+
*
|
|
19
|
+
* Renders nothing outside dev mode, and loads the panel itself
|
|
20
|
+
* (`@json-render/devtools`) with a dynamic `import()`, so a production build
|
|
21
|
+
* never fetches it.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```html
|
|
25
|
+
* <json-render #renderer [spec]="ui.spec()" [registry]="registry" />
|
|
26
|
+
* <json-render-devtools [renderer]="renderer" [catalog]="catalog" />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare class JsonRenderDevtools {
|
|
30
|
+
/** The renderer to inspect: its spec, state store and catalog. */
|
|
31
|
+
readonly renderer: _angular_core.InputSignal<JsonRenderer | null>;
|
|
32
|
+
/** Spec to show instead of the renderer's. */
|
|
33
|
+
readonly spec: _angular_core.InputSignal<Spec | null | undefined>;
|
|
34
|
+
/** Catalog for the Catalog tab, if the renderer was not given one. */
|
|
35
|
+
readonly catalog: _angular_core.InputSignal<Catalog<_json_render_core.SchemaDefinition<_json_render_core.SchemaType<string, unknown>, _json_render_core.SchemaType<string, unknown>>, unknown> | null | undefined>;
|
|
36
|
+
/**
|
|
37
|
+
* A chat from `injectChatUI`: every assistant reply with a spec becomes a
|
|
38
|
+
* generation in the Spec tab's switcher.
|
|
39
|
+
*/
|
|
40
|
+
readonly chat: _angular_core.InputSignal<ChatUIReturn | null>;
|
|
41
|
+
readonly initialOpen: _angular_core.InputSignal<boolean>;
|
|
42
|
+
readonly position: _angular_core.InputSignal<PanelPosition>;
|
|
43
|
+
/** Toggle shortcut; `false` disables it. */
|
|
44
|
+
readonly hotkey: _angular_core.InputSignal<string | false>;
|
|
45
|
+
/** Events kept in the ring buffer. Read once, at creation. */
|
|
46
|
+
readonly bufferSize: _angular_core.InputSignal<number>;
|
|
47
|
+
/** Pad the page while the panel is open instead of overlaying it. */
|
|
48
|
+
readonly reserveSpace: _angular_core.InputSignal<boolean>;
|
|
49
|
+
/** Let the viewer flip the panel between bottom and right dock. */
|
|
50
|
+
readonly allowDockToggle: _angular_core.InputSignal<boolean>;
|
|
51
|
+
/** Every event the panel records, for an app's own logging. */
|
|
52
|
+
readonly event: _angular_core.OutputEmitterRef<DevtoolsEvent>;
|
|
53
|
+
private readonly destroyRef;
|
|
54
|
+
private events;
|
|
55
|
+
private panel;
|
|
56
|
+
private destroyed;
|
|
57
|
+
constructor();
|
|
58
|
+
private currentSpec;
|
|
59
|
+
private currentCatalog;
|
|
60
|
+
private generations;
|
|
61
|
+
private stateStore;
|
|
62
|
+
private mount;
|
|
63
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<JsonRenderDevtools, never>;
|
|
64
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<JsonRenderDevtools, "json-render-devtools", never, { "renderer": { "alias": "renderer"; "required": false; "isSignal": true; }; "spec": { "alias": "spec"; "required": false; "isSignal": true; }; "catalog": { "alias": "catalog"; "required": false; "isSignal": true; }; "chat": { "alias": "chat"; "required": false; "isSignal": true; }; "initialOpen": { "alias": "initialOpen"; "required": false; "isSignal": true; }; "position": { "alias": "position"; "required": false; "isSignal": true; }; "hotkey": { "alias": "hotkey"; "required": false; "isSignal": true; }; "bufferSize": { "alias": "bufferSize"; "required": false; "isSignal": true; }; "reserveSpace": { "alias": "reserveSpace"; "required": false; "isSignal": true; }; "allowDockToggle": { "alias": "allowDockToggle"; "required": false; "isSignal": true; }; }, { "event": "event"; }, never, never, true, never>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { JsonRenderDevtools };
|
|
@@ -1090,6 +1090,36 @@ declare function createStoreSetState(store: Pick<StateStore, 'getSnapshot' | 'up
|
|
|
1090
1090
|
*/
|
|
1091
1091
|
declare function applyPatch(spec: Spec, patch: JsonPatch): Spec;
|
|
1092
1092
|
|
|
1093
|
+
/** Token usage as the AI SDK reports it in its usage line. */
|
|
1094
|
+
interface StreamObserverUsage {
|
|
1095
|
+
promptTokens: number;
|
|
1096
|
+
completionTokens: number;
|
|
1097
|
+
totalTokens: number;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Hooks into every `injectUIStream` and `injectChatUI` generation in the app,
|
|
1101
|
+
* the counterpart of `registerActionObserver` in `@json-render/core`. This is
|
|
1102
|
+
* what `ngx-json-render/devtools` fills its Stream tab from, so it is private
|
|
1103
|
+
* API: the `ɵ` prefix says it may change in any release.
|
|
1104
|
+
*/
|
|
1105
|
+
interface StreamObserver {
|
|
1106
|
+
/** A generation started. */
|
|
1107
|
+
onStart?(): void;
|
|
1108
|
+
/** A patch was applied to the spec, in arrival order. */
|
|
1109
|
+
onPatch?(patch: JsonPatch): void;
|
|
1110
|
+
/** A line of prose arrived (`injectChatUI` only). */
|
|
1111
|
+
onText?(text: string): void;
|
|
1112
|
+
/** The usage line arrived (`injectUIStream` only). */
|
|
1113
|
+
onUsage?(usage: StreamObserverUsage): void;
|
|
1114
|
+
/** The generation ended; `ok` is false on an error, true on a stop. */
|
|
1115
|
+
onEnd?(ok: boolean): void;
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Register an observer for every stream in the app. Returns the function that
|
|
1119
|
+
* removes it. Private API for `ngx-json-render/devtools`.
|
|
1120
|
+
*/
|
|
1121
|
+
declare function ɵregisterStreamObserver(observer: StreamObserver): () => void;
|
|
1122
|
+
|
|
1093
1123
|
/**
|
|
1094
1124
|
* Convert a flat element list to a Spec.
|
|
1095
1125
|
* Input elements use key/parentKey to establish identity and relationships.
|
|
@@ -1352,5 +1382,5 @@ declare function injectChatUI(options: ChatUIOptions): ChatUIReturn;
|
|
|
1352
1382
|
*/
|
|
1353
1383
|
declare function injectDevtoolsActive(): Signal<boolean>;
|
|
1354
1384
|
|
|
1355
|
-
export { CONFIRM_CONTEXT, ELEMENT_KEY, JR_CONFIRM_DIALOG, JR_CONFIRM_LABELS, JrChildren, JrConfirmDialog, JrElement, JrRepeatScope, JsonRenderActionsService, JsonRenderRootContext, JsonRenderStateService, JsonRenderValidationService, JsonRenderer, RENDER_CONTEXT, REPEAT_SCOPE, applyPatch, buildSpecFromParts, checkSpec, createStoreSetState, defineRegistry, flatToTree, formatSpecCheckIssues, getTextFromParts, injectAction, injectActions, injectBoundProp, injectChatUI, injectConfirmContext, injectDevtoolsActive, injectElementKey, injectFieldValidation, injectRenderContext, injectRepeatScope, injectStateBinding, injectStateStore, injectStateValue, injectUIStream, injectValidation, isActionCancelled, jsonRenderMessage };
|
|
1356
|
-
export type { ActionFn, Actions, CatalogHasActions, ChatMessage, ChatUIOptions, ChatUIReturn, ComponentRegistry, Components, ConfirmContext, ConfirmLabels, DataPart, DefineRegistryResult, EventHandle, FieldValidationState, PendingConfirmation, RegistryEntry, RenderContext, RenderLimits, RepeatScope, SetState, SpecCatalog, SpecCheck, SpecCheckIssue, SpecCheckIssueCode, SpecCheckOptions, SpecValidationMode, StateChange, TokenUsage, UIStreamOptions, UIStreamReturn, UIStreamSendOptions };
|
|
1385
|
+
export { CONFIRM_CONTEXT, ELEMENT_KEY, JR_CONFIRM_DIALOG, JR_CONFIRM_LABELS, JrChildren, JrConfirmDialog, JrElement, JrRepeatScope, JsonRenderActionsService, JsonRenderRootContext, JsonRenderStateService, JsonRenderValidationService, JsonRenderer, RENDER_CONTEXT, REPEAT_SCOPE, applyPatch, buildSpecFromParts, checkSpec, createStoreSetState, defineRegistry, flatToTree, formatSpecCheckIssues, getTextFromParts, injectAction, injectActions, injectBoundProp, injectChatUI, injectConfirmContext, injectDevtoolsActive, injectElementKey, injectFieldValidation, injectRenderContext, injectRepeatScope, injectStateBinding, injectStateStore, injectStateValue, injectUIStream, injectValidation, isActionCancelled, jsonRenderMessage, ɵregisterStreamObserver };
|
|
1386
|
+
export type { ActionFn, Actions, CatalogHasActions, ChatMessage, ChatUIOptions, ChatUIReturn, ComponentRegistry, Components, ConfirmContext, ConfirmLabels, DataPart, DefineRegistryResult, EventHandle, FieldValidationState, PendingConfirmation, RegistryEntry, RenderContext, RenderLimits, RepeatScope, SetState, SpecCatalog, SpecCheck, SpecCheckIssue, SpecCheckIssueCode, SpecCheckOptions, SpecValidationMode, StateChange, StreamObserver, StreamObserverUsage, TokenUsage, UIStreamOptions, UIStreamReturn, UIStreamSendOptions };
|