ngx-json-render 0.7.2 → 0.7.3
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 +34 -2
- package/package.json +5 -1
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.cjs +55 -0
package/README.md
CHANGED
|
@@ -14,6 +14,13 @@ This is an Angular **adapter over the official core**, not a second implementati
|
|
|
14
14
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
17
|
+
```bash
|
|
18
|
+
ng add ngx-json-render
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`ng add` installs the package and adds its peers, `@json-render/core` and
|
|
22
|
+
`zod`, at the ranges it admits. By hand, that is
|
|
23
|
+
|
|
17
24
|
```bash
|
|
18
25
|
npm install ngx-json-render @json-render/core zod
|
|
19
26
|
```
|
|
@@ -52,11 +59,14 @@ ships 28 Angular Material components already registered, so a generated spec
|
|
|
52
59
|
renders with nothing else wired up:
|
|
53
60
|
|
|
54
61
|
```bash
|
|
55
|
-
|
|
62
|
+
ng add ngx-json-render-material
|
|
56
63
|
```
|
|
57
64
|
|
|
58
65
|
Those are real Material components, so the app needs a Material theme and the
|
|
59
|
-
icon font
|
|
66
|
+
icon font; `ng add` sets both up through Material's own `ng add` when the
|
|
67
|
+
workspace has no Material yet (see the
|
|
68
|
+
[catalog's README](https://github.com/shteynu/ngx-json-render/tree/main/projects/ngx-json-render-material#install)
|
|
69
|
+
for installing by hand).
|
|
60
70
|
|
|
61
71
|
```ts
|
|
62
72
|
import { Component, signal } from '@angular/core';
|
|
@@ -90,6 +100,28 @@ export class App {
|
|
|
90
100
|
vocabulary. Everything below is the other path — your own components, which is
|
|
91
101
|
what the catalog API is for.
|
|
92
102
|
|
|
103
|
+
## ngx-json-render or Hashbrown?
|
|
104
|
+
|
|
105
|
+
[Hashbrown](https://hashbrown.dev) is the other generative-UI library for
|
|
106
|
+
Angular. Both let a model compose your components; they differ in what the
|
|
107
|
+
model emits and in how much of the agent around it they provide. Compared
|
|
108
|
+
against `@hashbrownai/angular` 0.6.1, as published on 2026-09-30:
|
|
109
|
+
|
|
110
|
+
| | ngx-json-render | Hashbrown |
|
|
111
|
+
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
112
|
+
| What the model emits | A json-render spec, streamed as RFC 6902 patches — the format the React, Vue, Svelte and Solid renderers read, so a catalog and a spec move between frameworks unchanged | Hashbrown's own JSON, generated against a schema built from the components you expose; read by Hashbrown's Angular and React clients |
|
|
113
|
+
| Server | Anything that streams text: the [AI SDK](https://ai-sdk.dev) in a few lines, or your own endpoint; `catalog.prompt()` writes the system prompt | An [AG-UI](https://docs.ag-ui.com) endpoint, built with Hashbrown's adapters (OpenAI, Anthropic, Google, Azure, Bedrock, Ollama) or your own mapping |
|
|
114
|
+
| Angular | 20, 21 and 22, each tested in CI | 22 only since 0.6 (0.5 supported 20 and 21) |
|
|
115
|
+
| Components | Your own, or 28 ready-made Angular Material ones ([`ngx-json-render-material`](https://www.npmjs.com/package/ngx-json-render-material)) | Your own (`exposeComponent`, UI kits) |
|
|
116
|
+
| Beyond rendering | Rendering-focused: state and two-way bindings in the spec, actions, visibility, repeat, watch, confirmation dialogs | An agent toolkit: client-side tools, a QuickJS sandbox for model-written code, shared agent state, interrupts, streaming Markdown |
|
|
117
|
+
| License | Apache-2.0 | MIT |
|
|
118
|
+
|
|
119
|
+
Reach for Hashbrown when you want the agent loop — tools, a sandbox, AG-UI —
|
|
120
|
+
from one library and are on Angular 22. Reach for this one when you want an
|
|
121
|
+
open spec format that is not tied to Angular or to one vendor's client, a
|
|
122
|
+
server you already have, Angular 20 or 21, or a UI that renders from a
|
|
123
|
+
ready-made Material catalog before you have written a component.
|
|
124
|
+
|
|
93
125
|
## Quick start
|
|
94
126
|
|
|
95
127
|
**1. Define a catalog** — the vocabulary the model (or your server) is allowed to use:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-json-render",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
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",
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
"tslib": "^2.3.0"
|
|
32
32
|
},
|
|
33
33
|
"sideEffects": false,
|
|
34
|
+
"schematics": "./schematics/collection.json",
|
|
35
|
+
"ng-add": {
|
|
36
|
+
"save": "dependencies"
|
|
37
|
+
},
|
|
34
38
|
"module": "fesm2022/ngx-json-render.mjs",
|
|
35
39
|
"typings": "types/ngx-json-render.d.ts",
|
|
36
40
|
"exports": {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
+
"schematics": {
|
|
4
|
+
"ng-add": {
|
|
5
|
+
"description": "Adds ngx-json-render's peer dependencies (@json-render/core and zod) to the workspace.",
|
|
6
|
+
"factory": "./ng-add/index.cjs#ngAdd"
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ngAdd = ngAdd;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const utility_1 = require("@schematics/angular/utility");
|
|
6
|
+
const self = require('../../package.json');
|
|
7
|
+
/** Peers a workspace has to declare itself; `@angular/*` is already there. */
|
|
8
|
+
const PEERS = ['@json-render/core', 'zod'];
|
|
9
|
+
const README = 'https://github.com/shteynu/ngx-json-render/tree/main/projects/ngx-json-render#readme';
|
|
10
|
+
/**
|
|
11
|
+
* `ng add ngx-json-render`: declares the peers the renderer needs, at the
|
|
12
|
+
* ranges its own manifest admits, and leaves any the workspace already has
|
|
13
|
+
* untouched. The CLI installs the package itself; npm would install the peers
|
|
14
|
+
* too, but without a `package.json` entry nothing pins them.
|
|
15
|
+
*/
|
|
16
|
+
function ngAdd() {
|
|
17
|
+
return (tree, context) => {
|
|
18
|
+
const workspace = readManifest(tree);
|
|
19
|
+
warnOnOldAngular(workspace, (message) => context.logger.warn(message));
|
|
20
|
+
const rules = [];
|
|
21
|
+
for (const name of PEERS) {
|
|
22
|
+
if (declares(workspace, name))
|
|
23
|
+
continue;
|
|
24
|
+
const range = self.peerDependencies?.[name];
|
|
25
|
+
if (!range)
|
|
26
|
+
throw new schematics_1.SchematicsException(`ngx-json-render declares no peer range for ${name}.`);
|
|
27
|
+
rules.push((0, utility_1.addDependency)(name, range));
|
|
28
|
+
context.logger.info(`Adding ${name}@${range}`);
|
|
29
|
+
}
|
|
30
|
+
context.logger.info([
|
|
31
|
+
'',
|
|
32
|
+
'ngx-json-render is ready. Next: describe your components in a catalog,',
|
|
33
|
+
`register them, and render a spec with <json-render> — see ${README}`,
|
|
34
|
+
'No components of your own yet? `ng add ngx-json-render-material` adds',
|
|
35
|
+
'28 ready-made Angular Material ones.',
|
|
36
|
+
].join('\n'));
|
|
37
|
+
return (0, schematics_1.chain)(rules);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function readManifest(tree) {
|
|
41
|
+
if (!tree.exists('/package.json')) {
|
|
42
|
+
throw new schematics_1.SchematicsException('No package.json at the workspace root.');
|
|
43
|
+
}
|
|
44
|
+
return tree.readJson('/package.json');
|
|
45
|
+
}
|
|
46
|
+
function declares(manifest, name) {
|
|
47
|
+
return !!(manifest.dependencies?.[name] ?? manifest.devDependencies?.[name]);
|
|
48
|
+
}
|
|
49
|
+
function warnOnOldAngular(manifest, warn) {
|
|
50
|
+
const range = manifest.dependencies?.['@angular/core'];
|
|
51
|
+
const major = range ? Number(/\d+/.exec(range)?.[0]) : NaN;
|
|
52
|
+
if (major < 20) {
|
|
53
|
+
warn(`ngx-json-render needs Angular 20 or newer; this workspace has @angular/core ${range}.`);
|
|
54
|
+
}
|
|
55
|
+
}
|