@nersh/render 0.2.5 → 0.4.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Scott Campbell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -94,12 +94,33 @@ Without this, styles from the render package will not appear.
94
94
 
95
95
  ---
96
96
 
97
+ ## Node styles
98
+
99
+ A node in `site.json` may carry `styles`: CSS per breakpoint, keyed `desktop`, `tablet` (below 64rem) and `phone` (below 48rem), each a map of CSS longhands to values (`{ "desktop": { "min-height": "100vh" }, "phone": { "min-height": "80vh" } }`). `SiteRenderer` writes one scoped `<style data-node-styles>` with container queries against the surface, the same stylesheet the hosted site writes, and stamps `data-section` and `data-instance` on a nested wrapper only when that node declares styles. A site with no `styles` renders what 0.2.5 rendered; the surface stylesheet only loses two type rules (`data-text-color`, `data-text-align`) that no exported node ever set.
100
+
101
+ ---
102
+
97
103
  ## `SiteRenderer` props
98
104
 
99
105
  | Prop | Type | Description |
100
106
  |------|------|-------------|
101
107
  | `site` | `CompositionSite` | The parsed `site.json` |
102
108
  | `registry` | `Record<string, ComponentType>` | Maps section IDs to components |
109
+ | `codeEmbed` | `'run' \| 'off'` | Whether Code Embed blocks run their code; default `'off'` |
110
+
111
+ ### Code Embed
112
+
113
+ With `codeEmbed="run"`, Code Embed blocks run the site author's HTML, CSS and JavaScript in a sealed frame: a sandboxed iframe with no access to the page or its cookies, whose own policy blocks requests (WebRTC aside, as "What it still can" in the [Code Embed guide](https://nertia.ai/docs/guides/code-embed) says). The default is off, and an off block shows its reserved box and fallback picture. `renderSiteToHtml` never runs it: static markup holds the box and the fallback, never the frame or the code.
114
+
115
+ A sealed frame can send itself to another address. Send a `frame-src` rule that names the hosts your embeds use, and the browser lets it go only to those:
116
+
117
+ ```
118
+ Content-Security-Policy: frame-src https://www.youtube.com https://player.vimeo.com
119
+ ```
120
+
121
+ List the hosts your own embeds use; nertia's list is in `packages/create-nersh/templates/next/next.config.ts`, and projects created with `create-nersh` send it for you. Without this rule, a frame's code can send the frame to any site. That site's page then shows in the block's box, has the network, and can stay there. Whatever a frame loads, it still cannot read your page, its cookies or its storage, and cannot navigate the top window, open popups or submit forms.
122
+
123
+ A sealed frame inherits the page's policy, so a page-level `script-src` without `'unsafe-inline'`, or one that moves to nonces, stops Code Embed frames: their code never runs.
103
124
 
104
125
  ---
105
126
 
@@ -126,4 +147,6 @@ A skin's dark values ship under a `.dark` class selector, the shadcn convention:
126
147
 
127
148
  ## Changelog
128
149
 
150
+ - 0.4.0: `SiteRenderer` takes `codeEmbed?: 'run' | 'off'` (default `'off'`); with `'run'`, Code Embed blocks run the author's code in a sealed frame. `create-nersh` 0.4.0 passes `'run'` and sends the `frame-src` header
151
+ - 0.3.0: renders node `styles` (per-breakpoint CSS on any node) as one scoped stylesheet; unstyled sites render as before, the surface stylesheet less the unused `data-text-color` and `data-text-align` rules; a node's legacy `overrides` bag is not read (0.2.5 never read it either); importing an older `.nertia.json` into nertia.ai converts each bag to `styles`, so export it again from there to keep that look
129
152
  - 0.2.5: declares `tailwind-merge`, `clsx`, and `embla-carousel-react`; 0.2.4 required installing them by hand