@blender-ui/react 0.1.0 → 0.2.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.
Files changed (4) hide show
  1. package/README.md +9 -3
  2. package/index.d.ts +15 -0
  3. package/index.js +12 -1
  4. package/package.json +74 -74
package/README.md CHANGED
@@ -103,7 +103,8 @@ cover yet.
103
103
  [`@blender-ui/native`](https://www.npmjs.com/package/@blender-ui/native),
104
104
  and `act(fn)` is for tests.
105
105
  - Window options: `title`, `width`, `height`, `resizable`, `gpu`,
106
- `headless`.
106
+ `slug`, `headless`, and `theme` (`'dark'`, the default, or `'light'`:
107
+ Blender's Light theme; `BUI_THEME` applies otherwise).
107
108
 
108
109
  ## Standalone apps
109
110
 
@@ -129,7 +130,8 @@ lists updating through signals, or use `--bun`.
129
130
 
130
131
  ## Benchmarks
131
132
 
132
- Ryzen 7 5800U laptop, Windows 11, GPU renderer, React's production build.
133
+ Ryzen 7 5800U laptop, Windows 11, GPU renderer, React's production build,
134
+ measured before the latest features landed.
133
135
  The full method is in the [guide](https://github.com/ppmpreetham/BUI/blob/main/docs/javascript.md#performance).
134
136
 
135
137
  **Startup:** a small React app that quits at its first frame; medians of 12
@@ -156,10 +158,14 @@ launches.
156
158
 
157
159
  ## Requirements
158
160
 
159
- - **Windows x64** for native windows; `headless: true` renders off-screen.
161
+ - **Windows x64** prebuilt. On **Linux**, build the `@blender-ui/native`
162
+ addon from source (`npm run build` in `bindings/node`) and windows are
163
+ native X11 windows. On **macOS** it's headless for now. `headless: true`
164
+ renders off-screen anywhere.
160
165
  - **Node.js 18** or newer, or Bun.
161
166
  - **React 19.3.**
162
167
 
163
168
  Guide: [docs/javascript.md](https://github.com/ppmpreetham/BUI/blob/main/docs/javascript.md) ·
169
+ Website: [bui.preetham.top](https://bui.preetham.top) ·
164
170
  Source: [github.com/ppmpreetham/BUI](https://github.com/ppmpreetham/BUI) ·
165
171
  License: GPL-2.0-or-later
package/index.d.ts CHANGED
@@ -93,3 +93,18 @@ declare module 'react' {
93
93
  buiSignal: ReadSignal<unknown>
94
94
  }
95
95
  }
96
+
97
+ /** Blender's widgets as components: always drawn and handled like Blender.
98
+ * Their lowercase HTML counterparts look like a browser's form controls
99
+ * (and like Blender inside an element with the `styled` attribute). */
100
+ type BlenderProps = Record<string, unknown> & { children?: ReactNode }
101
+ export function Button (props: BlenderProps): ReactNode
102
+ export function Checkbox (props: BlenderProps): ReactNode
103
+ export function Radio (props: BlenderProps): ReactNode
104
+ export function NumberField (props: BlenderProps): ReactNode
105
+ export function NumberSlider (props: BlenderProps): ReactNode
106
+ export function TextField (props: BlenderProps): ReactNode
107
+ export function TextArea (props: BlenderProps): ReactNode
108
+ export function ColorSwatch (props: BlenderProps): ReactNode
109
+ export function Dropdown (props: BlenderProps): ReactNode
110
+ export function ProgressBar (props: BlenderProps): ReactNode
package/index.js CHANGED
@@ -321,7 +321,7 @@ function createRoot (window) {
321
321
  * @returns {{ app: App, window: import('@blender-ui/native').Window, root: ReturnType<typeof createRoot> }}
322
322
  */
323
323
  function render (element, options = {}) {
324
- const app = options.app ?? new App({ gpu: options.gpu, slug: options.slug, headless: options.headless })
324
+ const app = options.app ?? new App({ gpu: options.gpu, slug: options.slug, headless: options.headless, theme: options.theme })
325
325
  const window = app.window(options)
326
326
  const root = createRoot(window)
327
327
  root.render(element)
@@ -339,7 +339,18 @@ function act (fn) {
339
339
  const reactHooks = {}
340
340
  for (const k of Object.keys(React)) if (/^use([A-Z]|$)/.test(k)) reactHooks[k] = React[k]
341
341
 
342
+ // Blender's widgets as components: `<NumberSlider min={0} max={10} />`,
343
+ // `<Button onClick={..}>Apply</Button>`. Always Blender widgets; their
344
+ // lowercase HTML counterparts look like a browser's (Blender's inside `styled`).
345
+ const blenderComponents = {}
346
+ for (const name of Object.keys(native.BLENDER_COMPONENTS)) {
347
+ const C = (props) => React.createElement(name, props)
348
+ Object.defineProperty(C, 'name', { value: name })
349
+ blenderComponents[name] = C
350
+ }
351
+
342
352
  module.exports = {
353
+ ...blenderComponents,
343
354
  ...reactHooks,
344
355
  ...hooks,
345
356
  render,
package/package.json CHANGED
@@ -1,74 +1,74 @@
1
- {
2
- "name": "@blender-ui/react",
3
- "version": "0.1.0",
4
- "description": "React renderer for BUI: Blender's UI in native windows from JSX, with React's hooks backed by signals. Node.js and Bun.",
5
- "main": "index.js",
6
- "types": "index.d.ts",
7
- "exports": {
8
- ".": {
9
- "types": "./index.d.ts",
10
- "default": "./index.js"
11
- },
12
- "./jsx-runtime": {
13
- "types": "./jsx-runtime.d.ts",
14
- "default": "./jsx-runtime.js"
15
- },
16
- "./jsx-dev-runtime": {
17
- "types": "./jsx-dev-runtime.d.ts",
18
- "default": "./jsx-dev-runtime.js"
19
- },
20
- "./package.json": "./package.json"
21
- },
22
- "files": [
23
- "index.js",
24
- "hooks.js",
25
- "index.d.ts",
26
- "jsx-runtime.js",
27
- "jsx-runtime.d.ts",
28
- "jsx-dev-runtime.js",
29
- "jsx-dev-runtime.d.ts",
30
- "README.md",
31
- "LICENSE"
32
- ],
33
- "scripts": {
34
- "test": "node --test",
35
- "prepublishOnly": "node --test",
36
- "prepack": "node -e \"require('fs').copyFileSync('../../LICENSE', 'LICENSE')\"",
37
- "postpack": "node -e \"require('fs').rmSync('LICENSE', { force: true })\""
38
- },
39
- "engines": {
40
- "node": ">=18"
41
- },
42
- "dependencies": {
43
- "@blender-ui/native": "^0.2.0",
44
- "react-reconciler": "0.34.0"
45
- },
46
- "peerDependencies": {
47
- "react": "^19.3.0"
48
- },
49
- "devDependencies": {
50
- "react": "19.3.1"
51
- },
52
- "license": "GPL-2.0-or-later",
53
- "repository": {
54
- "type": "git",
55
- "url": "git+https://github.com/ppmpreetham/BUI.git",
56
- "directory": "bindings/react"
57
- },
58
- "homepage": "https://github.com/ppmpreetham/BUI/blob/main/docs/javascript.md",
59
- "bugs": {
60
- "url": "https://github.com/ppmpreetham/BUI/issues"
61
- },
62
- "keywords": [
63
- "react",
64
- "renderer",
65
- "react-reconciler",
66
- "signals",
67
- "blender",
68
- "ui",
69
- "desktop",
70
- "native",
71
- "tailwind",
72
- "bun"
73
- ]
74
- }
1
+ {
2
+ "name": "@blender-ui/react",
3
+ "version": "0.2.0",
4
+ "description": "React renderer for BUI: Blender's UI in native windows from JSX, with React's hooks backed by signals. Node.js and Bun.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./index.d.ts",
10
+ "default": "./index.js"
11
+ },
12
+ "./jsx-runtime": {
13
+ "types": "./jsx-runtime.d.ts",
14
+ "default": "./jsx-runtime.js"
15
+ },
16
+ "./jsx-dev-runtime": {
17
+ "types": "./jsx-dev-runtime.d.ts",
18
+ "default": "./jsx-dev-runtime.js"
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "files": [
23
+ "index.js",
24
+ "hooks.js",
25
+ "index.d.ts",
26
+ "jsx-runtime.js",
27
+ "jsx-runtime.d.ts",
28
+ "jsx-dev-runtime.js",
29
+ "jsx-dev-runtime.d.ts",
30
+ "README.md",
31
+ "LICENSE"
32
+ ],
33
+ "scripts": {
34
+ "test": "node --test",
35
+ "prepublishOnly": "node --test",
36
+ "prepack": "node -e \"require('fs').copyFileSync('../../LICENSE', 'LICENSE')\"",
37
+ "postpack": "node -e \"require('fs').rmSync('LICENSE', { force: true })\""
38
+ },
39
+ "engines": {
40
+ "node": ">=18"
41
+ },
42
+ "dependencies": {
43
+ "@blender-ui/native": "^0.2.1",
44
+ "react-reconciler": "0.34.0"
45
+ },
46
+ "peerDependencies": {
47
+ "react": "^19.3.0"
48
+ },
49
+ "devDependencies": {
50
+ "react": "19.3.1"
51
+ },
52
+ "license": "GPL-2.0-or-later",
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/ppmpreetham/BUI.git",
56
+ "directory": "bindings/react"
57
+ },
58
+ "homepage": "https://bui.preetham.top",
59
+ "bugs": {
60
+ "url": "https://github.com/ppmpreetham/BUI/issues"
61
+ },
62
+ "keywords": [
63
+ "react",
64
+ "renderer",
65
+ "react-reconciler",
66
+ "signals",
67
+ "blender",
68
+ "ui",
69
+ "desktop",
70
+ "native",
71
+ "tailwind",
72
+ "bun"
73
+ ]
74
+ }