You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is how we handle chemical values, But you may notice that we support top level macros
49
49
50
-
`#preact`, `#react`, `#solid`, `#universal` All these component framework libraries are top level macros. The reason being
51
-
that these handle components and that's why.
50
+
`#universal` is the component macro. It handles SSR + hydration for server-rendered interactive UI.
52
51
53
-
for example
52
+
For example:
54
53
55
54
```chemical
56
-
#preact Greeting(props) {
55
+
#universal Greeting(props) {
57
56
return <div>Hello {props.name}</div>
58
57
}
59
58
```
@@ -75,6 +74,6 @@ The function names maybe a little different, but they accomplish similar logic,
75
74
universal lib generate a function that takes two more parameters, an SsrAttributeList, content for the children
76
75
universal lib also generates in both bundles, HTML that is server side rendered (from the component) and then a js function
77
76
that would hydrate the emitted html.
78
-
universal components are fast and they render everywhere, they work in react, preact and solid components. They work in `#html` too.
77
+
universal components are fast and they render everywhere. They work in `#html` blocks too.
79
78
80
79
For more information on universal components, load the `universal` skill. For developing new compiler plugins or understanding the plugin API, load the `cbi_plugin_api` skill. For understanding the compiler intrinsics and reflection APIs that macros can use at compile time, load the `intrinsics_compiler_reflection` skill.
Copy file name to clipboardExpand all lines: .agents/skills/universal/SKILL.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,12 @@ description: Diagnose, fix, and implement features in the Chemical universal com
8
8
Universal library is present in `lang/libs/universal_cbi`, its a macro processing library, it handles
9
9
specifically `#univeral` macros, for examples you can look for components present in `lang/libs/components`
10
10
11
-
Universal library emits components, Universal library is meant for server side rendering + hydration, The reason
12
-
its called universal is because we have libraries like `react_cbi`, `preact_cbi`, `solid_cbi`, they do not do hydration + ssr,
13
-
instead they just translate jsx to runtime calls, which is way easier. Universal components are supposed to
14
-
work inside react, preact or solid components, we have another `#html` macro, library `html_cbi`, universal components
15
-
work inside the html macro too. So yeah, Universal components work everywhere, they are fast because they do ssr + hydration.
11
+
Universal library emits components, Universal library is meant for server side rendering + hydration.
12
+
Universal components work inside `#html` blocks (processed by `html_cbi`) and are the primary way
13
+
to build interactive UI. They do SSR + hydration for fast initial paint and full interactivity.
14
+
15
+
> **Note:** React, Preact, and Solid framework bridges (`react_cbi`, `preact_cbi`, `solid_cbi`) have been
16
+
> removed. The universal component system is the only supported component model.
16
17
17
18
### How universal performs ssr + hydration.
18
19
@@ -22,14 +23,13 @@ third the text for the children, yes we pass children as `SsrText` (a struct in
22
23
23
24
The server function does two things, it appends a js function that would perform hydration into the js bundle, It also appends the server side rendered html
24
25
to the html bundle.
25
-
A trick used by `react_cbi`, `solid_cbi` and `preact_cbi`, they actually capture this html and put it into the js bundle.
26
+
The universal component system captures this html and puts it into the js bundle for hydration.
26
27
27
28
When I say js bundle or html bundle, A struct HtmlPage present in `lang/libs/page` is used for each page, it contains strings
28
29
in which we append, `pageHtml`, `pageHeadJs`, `pageJs`, these fields are used to write the final output.
29
30
30
-
`react_cbi`, `solid_cbi` and `preact_cbi` write their components to `pageHeadJs`, because we use umd bundles, so that everything is rendered
31
-
without flash of unrendered components, `universal_cbi` however appends to the `pageJs`, so its components are present in the js loaded at the end of body
32
-
this means we have to use a queue to hydrate universal components, once they have been rendered.
31
+
`universal_cbi` appends to the `pageJs`, so its components are present in the js loaded at the end of body.
32
+
This means we have to use a queue (`$__uni_hydration_queue`) to hydrate universal components once they have been rendered.
0 commit comments