Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add experimental
onNodeDetected
event (#457)
Relates to #223 and partially solves it. There're two categories of discoverable nodes: HTML nodes and SVG nodes. The HTML nodes are just the same as the input, which is easier to reason about: we just emit the input nodes with resolved layout and styling information. This can be thought as the "preprocessing step" of the data. Then, the SVG nodes are a little bit tricky because they're not a 1:1 mapping from the input nodes. For example a `<div style={{ boxShadow: '...' }}>` might be generated as a collection of SVG nodes including `<defs>`, `<filter>` and `<rect>`. However, in the future we can still emit structured data for these in a `onNodeGenerated` event, containing the mapping information via a `from` field: ```html <div key="k" id="i" className="c" style={{ boxShadow: '...' }}> ``` Emits: ```js onNodeDetected: #0 = { type: 'div', key: 'k', width, height, left, top, props } ``` And: ```js onNodeGenerated: { from: #0, defs: DefNode[], elements: SVGElementNode[] } ``` It apparently needs more discussion to get the best structured data design. The generated node can be converted to SVG easily but not necessarily (i.e. can be rendered in an imperative way such as canvas too). Then we can get #233 fully supported.
- Loading branch information
c1469ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
satori-playground – ./
satori-playground-git-main.vercel.sh
satori-playground.vercel.app
og-playground.vercel.sh
og-playground.vercel.app
satori-playground.vercel.sh