Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# shell scripts must keep LF line endings, whatever the checkout: a CRLF install.sh breaks `sh`
*.sh text eol=lf
157 changes: 157 additions & 0 deletions .github/workflows/cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# The `bui` command (tools/bui): tested on the three systems for every change to it, and built for
# six targets and attached to the GitHub Release when a release tag is pushed. The installers
# (website/public/install.sh and install.ps1) and `bui update` download these archives.
#
# bui-<target>.tar.gz (Linux, macOS; holds `bui`)
# bui-<target>.zip (Windows; holds `bui.exe`)
# <archive>.sha256
#
# A release is made by tools/release.py (it tags vX.Y.Z); this runs beside release.yml and adds the
# files to the release that one creates (whichever workflow gets there first creates it).

name: bui command

on:
push:
tags: ["v*"]
pull_request:
paths: ["tools/bui/**", "website/public/install.*", ".github/workflows/cli.yml"]
workflow_dispatch:
inputs:
tag:
description: "Release tag to attach the archives to (e.g. v0.5.1)"
required: true
publish:
description: "Really upload (otherwise only build)"
type: boolean
default: false

permissions:
contents: read

env:
CARGO_TERM_COLOR: always

jobs:
test:
name: test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-15]
defaults:
run:
working-directory: tools/bui
steps:
- uses: actions/checkout@v4
with:
# a manual run builds the tag it was given, not the branch it was started from
ref: ${{ github.event.inputs.tag || github.ref }}
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: tools/bui
- run: cargo clippy --locked --all-targets -- -D warnings
- run: cargo test --locked

installers:
name: installers (syntax)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: install.sh is POSIX sh and passes shellcheck
run: |
sudo apt-get install -y shellcheck dash
dash -n website/public/install.sh
shellcheck -s sh -S warning website/public/install.sh
- name: install.ps1 is plain ASCII (Windows PowerShell 5.1 decodes a download as it likes) and parses
shell: pwsh
run: |
$bytes = [IO.File]::ReadAllBytes('website/public/install.ps1')
if ($bytes | Where-Object { $_ -gt 127 }) { throw 'install.ps1 has non-ASCII characters' }
$errors = $null
[void][System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path 'website/public/install.ps1'), [ref]$null, [ref]$errors)
if ($errors) { $errors | ForEach-Object { Write-Error $_.Message }; exit 1 }

build:
name: build (${{ matrix.target }})
needs: [test, installers]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04 }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04-arm }
- { target: x86_64-apple-darwin, os: macos-15-intel }
- { target: aarch64-apple-darwin, os: macos-15 }
- { target: x86_64-pc-windows-msvc, os: windows-latest }
- { target: aarch64-pc-windows-msvc, os: windows-11-arm }
steps:
- uses: actions/checkout@v4
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
with:
# a manual run builds the tag it was given, not the branch it was started from
ref: ${{ github.event.inputs.tag || github.ref }}
persist-credentials: false
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
workspaces: tools/bui
key: ${{ matrix.target }}
- name: Build
working-directory: tools/bui
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Package (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
set -eu
mkdir -p dist
name="bui-${{ matrix.target }}.tar.gz"
tar -czf "dist/$name" -C "tools/bui/target/${{ matrix.target }}/release" bui
(cd dist && { sha256sum "$name" 2>/dev/null || shasum -a 256 "$name"; } > "$name.sha256")
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory dist | Out-Null
$name = "bui-${{ matrix.target }}.zip"
Compress-Archive -Path "tools/bui/target/${{ matrix.target }}/release/bui.exe" -DestinationPath "dist/$name"
$hash = (Get-FileHash "dist/$name" -Algorithm SHA256).Hash.ToLower()
"$hash $name" | Set-Content "dist/$name.sha256" -NoNewline
- uses: actions/upload-artifact@v4
with:
name: bui-${{ matrix.target }}
path: dist/*

upload:
name: attach to the GitHub Release
needs: build
if: github.event_name == 'push' || github.event.inputs.publish == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
env:
TAG: ${{ github.event.inputs.tag || github.ref_name }}
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create the release if release.yml has not yet, then attach the files
run: |
ls -l dist
gh release view "$TAG" >/dev/null 2>&1 || gh release create "$TAG" --title "BUI ${TAG#v}" --generate-notes --verify-tag || gh release view "$TAG" >/dev/null
gh release upload "$TAG" dist/* --clobber
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to **blenderui** (BUI). The format follows
## [Unreleased]

### Added
- **The `bui` command** (`tools/bui`, a Rust program): `bui new` / `bui init` ask what to write in (Rust, JavaScript or TypeScript with React, Svelte or plain DOM on Bun, npm or pnpm, Python with Blender components, Qt or tkinter syntax, Lua, C), check that the language's tools are installed and offer the commands that install the newest one, write a project with that language's lints and formatter (Clippy pedantic and rustfmt, Biome and strict TypeScript, Ruff, Luacheck and StyLua, clang-format and clang-tidy) and install the newest BUI with the language's own package manager. `bui dev` and `bui build` run the project; `bui doctor` finds what is wrong with the least work (the project's own checks first, `--all` for every toolchain, `--json`) and offers the fix for each problem before running anything; `bui update` updates `bui` from the release (progress bar, checksum) and the project's packages; `bui docs`, `bui completions`; `bui dev -- ARGS` and `bui build -- ARGS` hand arguments to the tool underneath; `bui` alone lists every command with its options. `bui new` says which packages it will install, with the exact commands, and asks before writing anything. Installed with `curl -LsSf https://bui.preetham.top/install.sh | sh` or `irm https://bui.preetham.top/install.ps1 | iex` (`website/public/install.sh`, `install.ps1`). `.github/workflows/cli.yml` tests it on the three systems and attaches `bui-<target>` archives (six targets, with checksums) to every release; `tools/bump_version.py` and `check_versions.py` move and check its version with the rest. Nothing is installed or changed without a prompt, `--fix` or `--install-tools`. `bui init` in a folder with a `package.json` adds only the missing scripts (and stops on a manifest it cannot read), `bui build` checks for Bun (the bundler of `@blender-ui/native`), `bui update --cli-only` updates only `bui` (what `bui doctor --fix` runs) and a failed required update step is an error; the Unix installer replaces an existing `bui` atomically and the Windows installer by backup and rollback (an installer killed between its two moves leaves `bui.exe.old` to rename back), `bui init` also stops on an unreadable `package.json` or one with `"type": "module"` in a React and TypeScript project (its `tsx` entry cannot import the CommonJS `@blender-ui/react` as an ES module), BUI's `FetchContent_Declare` in a C project is found with spaces before the parenthesis and ignoring comments (a `#` inside a quoted or bracket argument is not one, and a comment between `GIT_TAG` and its value is skipped), `bui update` stages the new binary in a private file beside the old one, and C projects declare C, C++ and Objective-C (macOS).
- **Rust: selecting text.** Text in elements is selectable like in a browser: press and drag across words, lines, elements and paragraphs, double-click a word, triple-click a block, `Shift`+click to extend, `Ctrl+A` (Cmd on macOS) for all, `Ctrl+C` to copy, `Esc` or a click elsewhere to clear. The highlight is the theme's `selection` color, drawn behind the text on the CPU and GPU renderers (while something is selected each text line holds one rectangle slot, so a change damages only the lines that changed; with nothing selected there is no extra work), the pointer is the I-beam over selectable text, and a drag that selected text does not click. `user-select` (`none`, `auto`, `text`, `all`, with `-webkit-user-select` / `-moz-user-select` and Tailwind `select-none` / `select-auto` / `select-text` / `select-all`) is implemented and no longer in the accepted-but-ignored list: `auto` follows the parent as in CSS UI 4. Text fields and other widgets keep their own selection; painted lists (`vlist`, `chat_list`) and canvases are not selectable and there is no autoscroll. `Window::selected_text`, `select_all`, `clear_selection`, `on_selection_change` and `read_clipboard` expose it; `examples/selectable.rs` and `tests/selection.rs` show and test it.
- **Editor extensions** (`addons/`): `bui-vscode` (a TextMate injection grammar for `rsx!` / `view!` bodies in Rust files, with Tailwind-aware `class` strings, snippets and class completion) and `bui-zed` (a BUI RSX language for `.rsx` files and snippets; Zed cannot extend its built-in Rust macro injections, so `rsx!` inside `.rs` files is not highlighted there). Both GPL-3.0-or-later.
- **GPU effects: run your own shader.** A canvas item (`BK_ITEM_EFFECT`, Rust `Painter::effect`) runs a pixel shader of the app's over its box on the GPU renderers, in paint order, clipped and premultiplied like the rest. The source is one portable dialect, GLSL with a small compat set (`vec4 effect(vec2 p)`, `box_size`, `U[i]` floats, `input_color(i, texel)` over up to 8 BUI textures); Direct3D 11 compiles it at run time through `d3dcompiler_47.dll` loaded dynamically (nothing to link, no SDK), OpenGL through the driver, and the compile/link log is returned by `BK_effect_error` / `ShaderEffect::error`. Where the GPU cannot run it (software raster, no compiler, a compile error) the item's image is drawn instead, so an effect has a CPU path too (the distortion wave, `bui-wave`, renders the same frames on the CPU, over every core, and on the GPU through this item; the two agree to within 1/255). `BK_effect_create` / `BK_effect_free` (= `BUI_effect_*`), `BUI_raster_effect`, Rust `ShaderEffect`, `Painter::effect`, `Painter::is_gpu` and `GpuTarget` (off-screen GPU frames). The macOS renderer has no effects yet (it draws the fallback).
Expand Down Expand Up @@ -92,6 +93,7 @@ All notable changes to **blenderui** (BUI). The format follows
audio track plays and each video with sound owns one stream and thread.

### Fixed
- **`bui build` of an npm-installed app.** The JavaScript bundler left `*.node` files out of the bundle but not the platform package `@blender-ui/native-<platform>` that holds one, so Bun stopped with "Loading .node files won't work in the browser"; it is left out now.
- **Rust: Tailwind `text-sm` / `text-xs` / `text-lg` line heights.** A unitless `calc()` line height (`calc(1.25 / 0.875)`, what the Tailwind theme sets) was read as pixels (1.4 px), so the text sat about 9 px above its box and a parent with `overflow: hidden` (`truncate`) cut it. It is now a factor of the font size, like a number.
- **Rust: `text-overflow: ellipsis` on a clipping block.** A `nowrap` text in a block with `overflow: hidden` (`truncate`) was laid out as line-box words, so it was clipped without the `…`. A block holding only text now lays it out as one measured run whatever its `overflow` (except scrolling ones), clips it to the content box and ends it with `…`; `text-overflow` takes effect only when `overflow-x` is not `visible`, as in CSS.
- **Windows window exposure and resizing:** a window dragged back from outside the screen, restored from minimize or uncovered
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,23 @@ theme.

## 7. Install

**The `bui` command (any language).** One line installs it, and `bui new` makes a project in
Rust, JavaScript or TypeScript (React, Svelte or plain DOM), Python, Lua or C, with that
language's lints, checking its tools first and installing the newest BUI with its own package
manager:

```sh
curl -LsSf https://bui.preetham.top/install.sh | sh # Linux and macOS
irm https://bui.preetham.top/install.ps1 | iex # Windows (PowerShell)

bui new my-app # asks what to write it in, then makes it
bui dev # run it
bui doctor # find what is wrong with the setup, and fix it
bui update # update bui and the project's BUI packages
```

Or install by hand, per language:

**Python.** You need CPython 3.11 or newer. Wheels are published for Windows,
Linux and macOS, so there's nothing to compile. One package gives you all four
Python APIs (tkinter syntax, Qt syntax, the Blender components and Dear ImGui):
Expand Down
2 changes: 1 addition & 1 deletion bindings/node/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function main ({ entry, out, bun, dev, console: keepConsole }) {
// an ES module importing the entry: Bun's IIFE output runs a CommonJS
// entry only when something imports it
entrypoints: [writeWrapper(entry, out)], target: 'browser', format: 'iife', minify: true, define, plugins,
external: ['node:*', '*.node'],
external: ['node:*', '*.node', '@blender-ui/native-*'],
})
if (!r.success) {
for (const log of r.logs) console.error(log)
Expand Down
2 changes: 2 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Getting started

**Fastest start: the `bui` command.** `curl -LsSf https://bui.preetham.top/install.sh | sh` (Windows: `irm https://bui.preetham.top/install.ps1 | iex`), then `bui new my-app`. It asks for a language (Rust, JavaScript or TypeScript, Python, Lua, C), makes a project with that language's lints and installs the newest BUI. `bui doctor` checks and fixes the setup, `bui update` updates. See [tools/bui](../tools/bui/README.md). The rest of this page builds BUI from source.

## 1. Build

Requirements:
Expand Down
Loading
Loading