@aglyn/aglyn-node-renderer 1.0.0-beta.143 → 1.0.0-beta.145

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.
Files changed (2) hide show
  1. package/README.md +101 -4
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -1,7 +1,104 @@
1
- # aglyn-node-renderer
1
+ # @aglyn/aglyn-node-renderer
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Renders a stored Aglyn node tree as React. It is the one renderer the Besigner
4
+ canvas, the console preview and a published site all mount. Install it if you
5
+ want to display Aglyn node trees in your own React app.
4
6
 
5
- ## Running unit tests
7
+ > Beta. Published from the Aglyn monorepo under the `beta` dist-tag; APIs can change between beta releases.
6
8
 
7
- Run `nx test aglyn-node-renderer` to execute the unit tests via [Jest](https://jestjs.io).
9
+ ## Install
10
+
11
+ npm install @aglyn/aglyn-node-renderer@beta
12
+
13
+ Peer dependencies:
14
+
15
+ - `react`
16
+
17
+ The package depends on `@aglyn/shared-ui-theme` and `@aglyn/shared-ui-jsx`,
18
+ which peer on MUI (`@mui/material`, `@mui/system` and related packages). The
19
+ renderer reads the active theme, so render it inside a theme provider.
20
+
21
+ ## What's in it
22
+
23
+ The tree components, from the outside in:
24
+
25
+ - `TreeRoot` (also exported as `AglynNodeRenderer`) takes the root `node` and
26
+ provides the component set to everything below it.
27
+ - `Trunk`, `Stem` and `Branch` walk the tree. `Stem` wraps each node in an
28
+ error boundary, so one failing node does not take the page down.
29
+ - `Leaf` renders one node. It looks up the node's `componentId` in the
30
+ `components` registry of `@aglyn/aglyn`, resolves the node's `sx` against
31
+ the active theme and color scheme, and applies element animation attributes.
32
+
33
+ Replacing a level:
34
+
35
+ - `TreeRoot` accepts `TrunkComponent`, `StemComponent`, `BranchComponent` and
36
+ `LeafComponent` props. The Besigner editor uses this to swap in a leaf that
37
+ adds selection and drag behavior. The `RendererComponents` context carries
38
+ the chosen set.
39
+ - `LeafSxTransformContext` lets a host transform the merged `sx` of every
40
+ leaf just before it reaches the element. A published site does not mount
41
+ it.
42
+
43
+ Helpers:
44
+
45
+ - `createAglynComponent(schema, component, options?)` wraps a React component
46
+ for registration: it returns the `{ schema, component }` pair, with the
47
+ component styled and wrapped in an error boundary.
48
+ - `useAglynSiteTheme` and `createAglynSiteTheme` build the theme a site renders
49
+ with from a stored host theme.
50
+ - `resolveSchemeSx`, `resolvePaletteVars`, `resolvePaletteVarsSx` and related
51
+ `sx` helpers, re-exported from `@aglyn/aglyn`.
52
+
53
+ Every file under `src/lib` is also reachable by subpath, for example
54
+ `@aglyn/aglyn-node-renderer/components/tree-root`.
55
+
56
+ ## Usage
57
+
58
+ Register a component with the core, then render a node that names it:
59
+
60
+ ```tsx
61
+ import { components } from '@aglyn/aglyn'
62
+ import { TreeRoot } from '@aglyn/aglyn-node-renderer'
63
+ import { createTheme, ThemeProvider } from '@aglyn/shared-ui-theme'
64
+
65
+ const Box = (props) => <div {...props} />
66
+
67
+ components.registerComponent(Box, {
68
+ $id: 'box',
69
+ pluginId: 'example',
70
+ displayName: 'Box',
71
+ })
72
+
73
+ const node = {
74
+ $id: 'root',
75
+ componentId: 'box',
76
+ pluginId: 'example',
77
+ props: { id: 'hello' },
78
+ children: [],
79
+ }
80
+
81
+ export function Page() {
82
+ return (
83
+ <ThemeProvider theme={createTheme({ palette: { mode: 'light' } })}>
84
+ <TreeRoot node={node} />
85
+ </ThemeProvider>
86
+ )
87
+ }
88
+ ```
89
+
90
+ In Aglyn itself the components come from plugins such as `@aglyn/plugins-mui`,
91
+ and the root node comes from the core's canvas (`canvas.rootNode`) after a
92
+ stored `NodesMap` is loaded into it.
93
+
94
+ ## How it fits
95
+
96
+ This is the `renderer` scope of the package map: it imports the core
97
+ (`@aglyn/aglyn`) and the generic `@aglyn/shared-*` packages, and nothing else.
98
+ It knows no plugin; components reach it only through the core's component
99
+ registry. `@aglyn/besigner-ui`, the tenant runtime and the plugins build on
100
+ it.
101
+
102
+ ## License
103
+
104
+ Apache-2.0. Source: https://github.com/aglyn/aglyn/tree/main/libs/aglyn-node-renderer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/aglyn-node-renderer",
3
- "version": "1.0.0-beta.143",
3
+ "version": "1.0.0-beta.145",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -24,12 +24,12 @@
24
24
  "./package.json": "./package.json"
25
25
  },
26
26
  "dependencies": {
27
- "@aglyn/aglyn": "1.0.0-beta.143",
28
- "@aglyn/shared-data-types": "1.0.0-beta.143",
29
- "@aglyn/shared-ui-jsx": "1.0.0-beta.143",
30
- "@aglyn/shared-ui-theme": "1.0.0-beta.143",
31
- "@aglyn/shared-util-tools": "1.0.0-beta.143",
32
- "@aglyn/shared-util-vendor": "1.0.0-beta.143",
27
+ "@aglyn/aglyn": "1.0.0-beta.145",
28
+ "@aglyn/shared-data-types": "1.0.0-beta.145",
29
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.145",
30
+ "@aglyn/shared-ui-theme": "1.0.0-beta.145",
31
+ "@aglyn/shared-util-tools": "1.0.0-beta.145",
32
+ "@aglyn/shared-util-vendor": "1.0.0-beta.145",
33
33
  "mobx-react-lite": "^4.1.1",
34
34
  "react-is": "^19.2.8"
35
35
  },