@solidrt/core 0.0.10 → 0.0.11
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/AGENTS.md +108 -0
- package/README.md +2 -0
- package/package.json +5 -4
- package/src/gpu.ts +23 -0
- package/src/index.ts +1 -1
- package/src/types.d.ts +8 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# @solidrt/core - agent notes
|
|
2
|
+
|
|
3
|
+
Dense, self-contained facts for writing a SolidRT app.
|
|
4
|
+
Full docs live in docs/ (and the website). When this conflicts with prose docs,
|
|
5
|
+
trust this file and the types in src/types.d.ts and jsx-runtime.d.ts.
|
|
6
|
+
|
|
7
|
+
SolidRT is a custom SolidJS renderer: it paints through a Rust runtime, not the
|
|
8
|
+
DOM. There is no HTML, no CSS cascade, no `className`.
|
|
9
|
+
|
|
10
|
+
## Setup
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
bun add @solidrt/core # the renderer
|
|
14
|
+
bun add -d @solidrt/cli # the `srt` tool (see its AGENTS.md)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`@solidrt/components` is a separate, optional package of higher-level components
|
|
18
|
+
(see its own AGENTS.md); core primitives alone are enough to build a full app.
|
|
19
|
+
|
|
20
|
+
tsconfig.json - the two load-bearing lines are jsx + jsxImportSource:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{ "compilerOptions": {
|
|
24
|
+
"jsx": "preserve",
|
|
25
|
+
"jsxImportSource": "@solidrt/core",
|
|
26
|
+
"moduleResolution": "bundler",
|
|
27
|
+
"strict": true
|
|
28
|
+
} }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Peer deps @solidjs/signals and @solidjs/universal must match (currently
|
|
32
|
+
2.0.0-beta.14); bun resolves them from peerDependencies.
|
|
33
|
+
|
|
34
|
+
## Element model (the parts that are easy to get wrong)
|
|
35
|
+
|
|
36
|
+
- `render(() => <App />)`. The returned root MUST be a `<window>` or it throws.
|
|
37
|
+
Call render once, at the top level.
|
|
38
|
+
|
|
39
|
+
- Two kinds of element:
|
|
40
|
+
- Containers - `<window>`, `<view>`. Do layout + transform + pointer events.
|
|
41
|
+
THEY DO NOT PAINT. A `<view>` has no background/fill prop.
|
|
42
|
+
- Draw primitives - `<rect>`, `<oval>`, `<path>`, `<texture>`, `<text>`.
|
|
43
|
+
These paint. To give a view a background, render a draw primitive (e.g.
|
|
44
|
+
`<d-rect>`) as a child, behind the content.
|
|
45
|
+
|
|
46
|
+
- Paint color is the `color` prop (a CSS color string). There is NO `fill`,
|
|
47
|
+
`stroke`, or `background` prop (some older doc examples are wrong about this).
|
|
48
|
+
Outlines: `drawStyle="stroke"` (or "stroke-and-fill") plus `strokeWidth`.
|
|
49
|
+
Corner radius on draw primitives: `radius` (number or [tl, tr, br, bl]).
|
|
50
|
+
|
|
51
|
+
- Registered JSX intrinsics: `window`, `view`, `text`, `rect`, `oval`, `path`,
|
|
52
|
+
`texture`, `audio`, plus the `d-` variants `d-view`, `d-rect`, `d-oval`,
|
|
53
|
+
`d-path`, `d-texture`, `d-text`. NOTE: `<line>` has a LineProps type but is
|
|
54
|
+
NOT a registered intrinsic - it will not typecheck.
|
|
55
|
+
|
|
56
|
+
- Plain vs `d-` variant (the `d-` prefix means "detached" - detached from the
|
|
57
|
+
layout engine, Taffy): a plain element (e.g. `rect`) is `RectProps &
|
|
58
|
+
LayoutProps`, so it draws AND is laid out by Taffy. The detached variant
|
|
59
|
+
(`d-rect`) is `RectProps` only - it draws but is NOT in the layout pass; you
|
|
60
|
+
place it yourself with `x`/`y` (omit them and it fills the parent, which is
|
|
61
|
+
how backgrounds work). Reach for `d-` whenever you want explicit coordinate
|
|
62
|
+
positioning instead of layout. It is also a performance lever: for many
|
|
63
|
+
directly-positioned, often-animating elements (e.g. hundreds of balls), `d-`
|
|
64
|
+
skips the per-element layout that plain elements would incur.
|
|
65
|
+
|
|
66
|
+
- Events: there is NO `onClick`/`onPress`. A "button" is a `<view>`/`<rect>`
|
|
67
|
+
with `onPointerDown`. Handlers: onPointerDown/Up/Move/Enter/Leave, onWheel,
|
|
68
|
+
onKeyDown/Up, onTextInput, onFocus/onBlur. Text entry: focus a node with an
|
|
69
|
+
`onTextInput` handler (setFocus activates the on-screen keyboard).
|
|
70
|
+
|
|
71
|
+
- Reactivity is plain SolidJS (`createSignal`, `createEffect`, ... from
|
|
72
|
+
@solidjs/signals). Per-frame work: `onFrame((tick, frame) => {})` (returns a
|
|
73
|
+
cleanup; auto-cleaned inside a reactive scope). Also onResize, onLayout,
|
|
74
|
+
onWindowFocus, onWindowBlur.
|
|
75
|
+
|
|
76
|
+
- Device/GPU access via subpath imports: @solidrt/core/camera, /microphone,
|
|
77
|
+
/speech, /gpu. Image flow: `decodeImage(bytes)` -> `createTexture(data,w,h)`
|
|
78
|
+
-> `<texture src={id} />`.
|
|
79
|
+
|
|
80
|
+
## Minimal app, core primitives only (verified to render)
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import { render } from "@solidrt/core"
|
|
84
|
+
import { createSignal } from "@solidjs/signals"
|
|
85
|
+
|
|
86
|
+
function App() {
|
|
87
|
+
let [count, setCount] = createSignal(0)
|
|
88
|
+
return (
|
|
89
|
+
<window flexDirection="column" alignItems="center" justifyContent="center" gap={24}>
|
|
90
|
+
<d-rect color="#0b0f17" /> {/* window background */}
|
|
91
|
+
<text color="#1f6feb" fontSize={48} fontWeight={800}>{count()}</text>
|
|
92
|
+
<view onPointerDown={() => setCount((c) => c + 1)}
|
|
93
|
+
padding={16} alignItems="center" justifyContent="center">
|
|
94
|
+
<d-rect color="#1f6feb" radius={12} /> {/* button background, underlays the label */}
|
|
95
|
+
<text color="#ffffff" fontSize={20}>increment</text>
|
|
96
|
+
</view>
|
|
97
|
+
</window>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
render(() => <App />)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Note the two `<d-rect>` underlays: a `<view>`/`<window>` does not paint, so a
|
|
105
|
+
background is a draw-primitive child placed behind the content.
|
|
106
|
+
|
|
107
|
+
To run and verify (incl. headless), see @solidrt/cli (its AGENTS.md). For
|
|
108
|
+
higher-level components, see @solidrt/components (its AGENTS.md).
|
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ A low-level toolkit for creating cross-platform applications.
|
|
|
4
4
|
|
|
5
5
|
_SolidRT is in pre-alpha stage. Anything can and will be changed._
|
|
6
6
|
|
|
7
|
+
> LLM agents: see [AGENTS.md](./AGENTS.md) for a dense, self-contained quickstart.
|
|
8
|
+
|
|
7
9
|
## Getting started
|
|
8
10
|
|
|
9
11
|
Prerequisites: [bun](https://bun.sh) (only required for development; not needed to run built apps).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidrt/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Antoine van Wel",
|
|
6
6
|
"type": "module",
|
|
@@ -17,16 +17,17 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"src/",
|
|
19
19
|
"jsx-runtime.d.ts",
|
|
20
|
-
"
|
|
20
|
+
"AGENTS.md"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"colord": "^2.9.3"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@solidrt/flux-types": "0.0.
|
|
26
|
+
"@solidrt/flux-types": "0.0.11"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@solidjs/signals": "2.0.0-beta.14",
|
|
30
|
-
"@solidjs/universal": "2.0.0-beta.14"
|
|
30
|
+
"@solidjs/universal": "2.0.0-beta.14",
|
|
31
|
+
"solid-js": "2.0.0-beta.14"
|
|
31
32
|
}
|
|
32
33
|
}
|
package/src/gpu.ts
CHANGED
|
@@ -20,4 +20,27 @@ export function createMutableTexture(data: Uint8Array, width: number, height: nu
|
|
|
20
20
|
|
|
21
21
|
export function uploadTexture(textureId: number, offset: number = 0): void {
|
|
22
22
|
gpu.uploadTexture(textureId, offset)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Compile a GLSL ES 3.00 fragment shader and render it into a texture, returning
|
|
26
|
+
// the texture id (usable anywhere a normal texture id is, e.g. <texture src>).
|
|
27
|
+
// The fragment body may reference vUV (0..1, top-left origin), iResolution,
|
|
28
|
+
// iTime, and any `uniform float` it declares; pass their values via `params`.
|
|
29
|
+
// `textures` binds each declared `uniform sampler2D` to an existing texture id
|
|
30
|
+
// (e.g. a camera or decoded image) so the shader can read it; those inputs are
|
|
31
|
+
// re-sampled on every setShaderParams call, so live sources stay current.
|
|
32
|
+
export function createShader(
|
|
33
|
+
fragmentSrc: string,
|
|
34
|
+
width: number,
|
|
35
|
+
height: number,
|
|
36
|
+
params?: Record<string, number>,
|
|
37
|
+
textures?: Record<string, number>,
|
|
38
|
+
): number {
|
|
39
|
+
return gpu.createShader(fragmentSrc, width, height, params, textures)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Re-render an existing shader texture with new param values and request a
|
|
43
|
+
// frame. Use this to animate (e.g. update iTime each frame).
|
|
44
|
+
export function setShaderParams(textureId: number, params: Record<string, number>): void {
|
|
45
|
+
gpu.setShaderParams(textureId, params)
|
|
23
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./renderer"
|
|
2
|
-
export { setFocus, getFocusedNodeId, measureText, getBoundingBox } from "./core"
|
|
2
|
+
export { setFocus, getFocusedNodeId, measureText, getBoundingBox, parseColorToU32 } from "./core"
|
|
3
3
|
export type { BoundingBox } from "./core"
|
|
4
4
|
export { onFrame, onLayout, onResize, onWindowFocus, onWindowBlur } from "./window"
|
|
5
5
|
export { createTexture, decodeImage } from "./gpu"
|
package/src/types.d.ts
CHANGED
|
@@ -40,6 +40,14 @@ declare global {
|
|
|
40
40
|
createTexture(data: Uint8Array, width: number, height: number): number
|
|
41
41
|
createMutableTexture(data: Uint8Array, width: number, height: number): number
|
|
42
42
|
uploadTexture(textureId: number, offset?: number): void
|
|
43
|
+
createShader(
|
|
44
|
+
fragmentSrc: string,
|
|
45
|
+
width: number,
|
|
46
|
+
height: number,
|
|
47
|
+
params?: Record<string, number>,
|
|
48
|
+
textures?: Record<string, number>,
|
|
49
|
+
): number
|
|
50
|
+
setShaderParams(textureId: number, params: Record<string, number>): void
|
|
43
51
|
decodeImage(bytes: Uint8Array): { data: Uint8Array, width: number, height: number }
|
|
44
52
|
}
|
|
45
53
|
|