ngx-json-render 0.7.1 → 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 +49 -2
- package/fesm2022/ngx-json-render-testing.mjs.map +1 -1
- package/fesm2022/ngx-json-render.mjs.map +1 -1
- package/package.json +6 -2
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.cjs +55 -0
- package/types/ngx-json-render-testing.d.ts +1 -1
- package/types/ngx-json-render.d.ts +1 -3
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",
|
|
@@ -24,13 +24,17 @@
|
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@angular/common": ">=20.0.0",
|
|
26
26
|
"@angular/core": ">=20.0.0",
|
|
27
|
-
"@json-render/core": "
|
|
27
|
+
"@json-render/core": ">=0.20.0 <0.22.0",
|
|
28
28
|
"zod": "^4.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
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
|
+
}
|
|
@@ -216,7 +216,7 @@ interface RenderSpecOptions {
|
|
|
216
216
|
/** Custom validation functions. */
|
|
217
217
|
validationFunctions?: Record<string, ValidationFunction>;
|
|
218
218
|
/** Custom directives for `$`-prefixed values. */
|
|
219
|
-
directives?: DirectiveDefinition[];
|
|
219
|
+
directives?: DirectiveDefinition<any>[];
|
|
220
220
|
/** Render as if the spec were still streaming. */
|
|
221
221
|
loading?: boolean;
|
|
222
222
|
/** Extra TestBed providers, e.g. a `JR_CONFIRM_DIALOG` replacement. */
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as _json_render_core from '@json-render/core';
|
|
2
2
|
import { ResolvedAction, ActionHandler, ActionBinding, SpecIssue, Spec, Catalog, InferCatalogActions, InferActionParams, StateModel, InferCatalogComponents, UIElement, StateStore, ValidationFunction, ComputedFunction, DirectiveDefinition, ActionConfirm, DirectiveRegistry, ValidationResult, ValidationConfig, JsonPatch, FlatElement } from '@json-render/core';
|
|
3
3
|
export { ActionBinding, ActionHandler, JsonPatch, Spec, SpecIssue, StateModel, StateStore, UIElement, VisibilityCondition, autoFixSpec, createStateStore, formatSpecIssues, nestedToFlat, validateSpec } from '@json-render/core';
|
|
4
|
-
import * as zod from 'zod';
|
|
5
|
-
import * as zod_v4_core from 'zod/v4/core';
|
|
6
4
|
import * as _angular_core from '@angular/core';
|
|
7
5
|
import { Signal, Type, InjectionToken } from '@angular/core';
|
|
8
6
|
import * as ngx_json_render from 'ngx-json-render';
|
|
@@ -520,7 +518,7 @@ declare class JsonRenderer {
|
|
|
520
518
|
/** Named functions for `$computed` expressions in props. */
|
|
521
519
|
readonly functions: _angular_core.InputSignal<Record<string, ComputedFunction> | undefined>;
|
|
522
520
|
/** Custom directives for user-defined `$`-prefixed dynamic values. */
|
|
523
|
-
readonly directives: _angular_core.InputSignal<DirectiveDefinition<
|
|
521
|
+
readonly directives: _angular_core.InputSignal<DirectiveDefinition<any>[] | undefined>;
|
|
524
522
|
/** Emits state changes in uncontrolled mode. */
|
|
525
523
|
readonly stateChange: _angular_core.OutputEmitterRef<StateChange[]>;
|
|
526
524
|
/** The state store of this renderer (also injectable in the subtree). */
|