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
{{ message }}
Repository navigation
Commit e36159c
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: AGENTS.md
+20-8Lines changed: 20 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# libnativeapi workspace
2
2
3
-
This is the workspace repo (`libnativeapi/nativeapi`, formerly `nativeapi-flutter` and `nativeapi-workspace`) for the [libnativeapi](https://github.com/libnativeapi) project family. Every binding (`bindings/dart/`, `bindings/rust/`, `bindings/csharp/`, `bindings/js/`, `bindings/python/`), the code generator (`tools/codegen/`), the `./codegen` script, the specs and the shared tooling live directly in this repo (the Rust and C# histories were merged in from `nativeapi-rust` and `nativeapi-csharp`); only `core/` and `bindings/dart/tray_manager/` are git submodules of independent repositories. Work inside a submodule is committed and pushed from that subdirectory; everything else is committed here.
3
+
This is the workspace repo (`libnativeapi/nativeapi`, formerly `nativeapi-flutter` and `nativeapi-workspace`) for the [libnativeapi](https://github.com/libnativeapi) project family. Every binding (`bindings/dart/`, `bindings/rust/`, `bindings/csharp/`, `bindings/js/`, `bindings/python/`, `bindings/go/`), the code generator (`tools/codegen/`), the `./codegen` script, the specs and the shared tooling live directly in this repo (the Rust and C# histories were merged in from `nativeapi-rust` and `nativeapi-csharp`); only `core/` and `bindings/dart/tray_manager/` are git submodules of independent repositories. Work inside a submodule is committed and pushed from that subdirectory; everything else is committed here.
4
4
5
5
## Layout
6
6
@@ -11,8 +11,9 @@ bindings/
11
11
├── rust/ # the Rust binding: crates/{nativeapi,cnativeapi}
12
12
├── csharp/ # the C# binding: src/, tests/, NativeAPI.slnx
13
13
├── js/ # the JS/TS binding: a Node-API addon (src/) + TypeScript (lib/)
Cargo.toml # cargo workspace root: Rust crates and examples
18
19
tools/codegen/ # in-repo Rust workspace: the code generator
@@ -25,8 +26,8 @@ codegen # Python entry point orchestrating the generators
25
26
## Architecture
26
27
27
28
-`core` — the C++ core library (repo: `nativeapi-core`). The source of truth for the native API surface (windows, tray icons, menus, displays, keyboard, dialogs, storage, etc.) with per-platform implementations (macOS/Windows/Linux).
28
-
-`tools/codegen` — three crates: `shared` (libclang parser, IR, naming), `capi` (C ABI + umbrella header), `bindings` (Rust/Dart/C#/JS/Python generators, consuming the IR JSON emitted by `capi`). Only `capi` depends on libclang. See tools/codegen/README.md.
29
-
-`bindings/*` — language bindings wrapping the core library. All live in this repo and build against the `core/` submodule directly (Rust `build.rs`, the Dart `cnativeapi` package's build hook, the C# native CMake, the JS addon's and the Python binding's`CMakeLists.txt`). Only a published package carries its own copy of core, in `cxx_impl/`, which the release workflows vendor and never commit. The Rust binding layers `nativeapi` (safe API) over `cnativeapi` (FFI). The Python binding has no compiled extension: generated `ctypes` code (`nativeapi/_capi.py` plus one module per header) calls a shared library built from core and a small event loop shim, which `Application.run_async()` pumps from asyncio.
29
+
-`tools/codegen` — three crates: `shared` (libclang parser, IR, naming), `capi` (C ABI + umbrella header), `bindings` (Rust/Dart/C#/JS/Python/Go generators, consuming the IR JSON emitted by `capi`). Only `capi` depends on libclang. See tools/codegen/README.md.
30
+
-`bindings/*` — language bindings wrapping the core library. All live in this repo and build against the `core/` submodule directly (Rust `build.rs`, the Dart `cnativeapi` package's build hook, the C# native CMake, the JS, Python and Go bindings'`CMakeLists.txt`). Only a published package carries its own copy of core, in `cxx_impl/`, which the release workflows vendor and never commit. The Rust binding layers `nativeapi` (safe API) over `cnativeapi` (FFI). The Python binding has no compiled extension: generated `ctypes` code (`nativeapi/_capi.py` plus one module per header) calls a shared library built from core and a small event loop shim, which `Application.run_async()` pumps from asyncio.
30
31
31
32
## Design specs
32
33
@@ -50,13 +51,24 @@ breaks). When one is resolved, edit the spec text itself.
50
51
Always drive the generators through `./codegen` at the workspace root:
-`./codegen check` — read-only verification, non-zero exit when stale (CI mode)
55
56
-`./codegen readme` — copy the shared README sections (`tools/readme/*.md`, e.g. Contributing) into core and every binding; `check` flags drift, `sync` runs it. Edit the snippet, never the copies.
56
57
-`./codegen sync [-m "msg"] [--push]` — full downstream propagation, see below
57
58
58
59
Generated files start with `// AUTO-GENERATED. DO NOT EDIT.` (`#` in Python) — change the C++ headers in `core/src/` and regenerate instead of editing outputs. Files without that banner are hand-written and never overwritten. The header list (`API_HEADERS`) lives in `tools/codegen/shared/src/lib.rs`.
59
60
61
+
Go builds require Go 1.22+, cgo and CMake 3.24+; build the shared library with
parameters, and fallible operations return `error` while predicates keep `bool`.
67
+
Native singletons are exported values with methods (`DisplayManager.All()`,
68
+
`Application.Run()`), backed by private stateless types.
69
+
Object getters retain nil-for-absence semantics; native failures without detailed
70
+
causes wrap `ErrOperationFailed`. Examples intentionally use dot imports as requested.
71
+
60
72
## Changing the core API
61
73
62
74
A core change ripples to every binding. After editing headers in `core`, run:
@@ -95,8 +107,8 @@ scenarios for *this project's* examples live in [tools/gui/](tools/gui/README.md
95
107
-`core` tracks `branch = main`. Use `make sync` to fast-forward it; `make status` to see dirty state everywhere; `make bump` to stage its pointer.
96
108
- The leanflutter packages built on nativeapi (`tray_manager`, `window_manager`, `launch_at_startup`, …) live in their own repos under github.com/leanflutter and depend on the published `nativeapi`. Only `tray_manager` rides along, as the submodule `bindings/dart/tray_manager` (tracking `main`); it is not a member of the root pub workspace, melos ignores it, and CI does not check it out. To try one against local changes, point a `dependency_overrides` entry in that package at `bindings/dart/nativeapi_flutter` (and `nativeapi`, `cnativeapi`) and never commit the override.
97
109
- Commit workspace submodule pointer updates only when the combination is compatible (a known-good snapshot).
98
-
- Examples live in `examples/<binding>_<name>_example` (`dart_` for plain Dart programs, `flutter_`, `rust_`, `csharp_`, `js_`, `python_`), not inside the bindings; a new Dart, Flutter or Rust example must also be listed in the root `pubspec.yaml` / `Cargo.toml`, a C# one in `bindings/csharp/NativeAPI.slnx`, a JS one in the root `package.json`. A Python example is a standalone uv project whose `pyproject.toml` points `nativeapi` at `../../bindings/python` (`uv run main.py` builds the wheel). Only the pub.dev package examples (`bindings/dart/*/example`) stay inside their package.
99
-
- CI is one workflow per binding (`dart-ci.yml`, `rust-ci.yml`, `csharp-ci.yml`, `js-ci.yml`, `python-ci.yml`), each running only for changes under its `bindings/<lang>/` and its examples (`examples/dart_*` and `examples/flutter_*` for Dart, `examples/rust_*`, `examples/csharp_*`, `examples/js_*`, `examples/python_*`). Release tags are per binding: `v*` publishes the Dart packages (`dart-release.yml`), `rust-v*` publishes the crates (`rust-release.yml`), `python-v*` publishes the Python package to PyPI (`python-release.yml`: an sdist carrying core in `cxx_impl/`, and wheels built from it with cibuildwheel; the tag must equal `python-v` + the version in `bindings/python/pyproject.toml`); never push a bare `v*` tag for anything but the Dart packages. Nothing has been published to PyPI yet: the first release needs `nativeapi` set up on PyPI with this workflow and the `pypi` environment as a trusted publisher.
110
+
- Examples live in `examples/<binding>_<name>_example` (`dart_` for plain Dart programs, `flutter_`, `rust_`, `csharp_`, `js_`, `python_`, `go_`), not inside the bindings; a new Dart, Flutter or Rust example must also be listed in the root `pubspec.yaml` / `Cargo.toml`, a C# one in `bindings/csharp/NativeAPI.slnx`, a JS one in the root `package.json`. A Python example is a standalone uv project whose `pyproject.toml` points `nativeapi` at `../../bindings/python` (`uv run main.py` builds the wheel). A Go example is a standalone module whose `go.mod` replaces `github.com/libnativeapi/nativeapi/bindings/go` with `../../bindings/go`. Only the pub.dev package examples (`bindings/dart/*/example`) stay inside their package.
111
+
- CI is one workflow per binding (`dart-ci.yml`, `rust-ci.yml`, `csharp-ci.yml`, `js-ci.yml`, `python-ci.yml`, `go-ci.yml`), each running only for changes under its `bindings/<lang>/` and its examples (`examples/dart_*` and `examples/flutter_*` for Dart, `examples/rust_*`, `examples/csharp_*`, `examples/js_*`, `examples/python_*`, `examples/go_*`). Release tags are per binding: `v*` publishes the Dart packages (`dart-release.yml`), `rust-v*` publishes the crates (`rust-release.yml`), `python-v*` publishes the Python package to PyPI (`python-release.yml`: an sdist carrying core in `cxx_impl/`, and wheels built from it with cibuildwheel; the tag must equal `python-v` + the version in `bindings/python/pyproject.toml`); never push a bare `v*` tag for anything but the Dart packages. Nothing has been published to PyPI yet: the first release needs `nativeapi` set up on PyPI with this workflow and the `pypi` environment as a trusted publisher.
100
112
- The Dart packages `cnativeapi`, `nativeapi` and `nativeapi_flutter` share one version: a release bumps all three pubspecs and CHANGELOGs, because pub.dev's automated publishing matches the tag `v<version>` against each package's own version. `cnativeapi` and `nativeapi` are plain Dart (no Flutter dependency; a build hook compiles core); `nativeapi_flutter` is the Flutter-facing package, holding the widgets, the `dart:ui` conversions and `windowing.dart`, and re-exporting `nativeapi` minus the names that clash with Flutter's.
101
113
- Never commit in a submodule while on a detached HEAD — check out `main` first (`./codegen sync` enforces this).
Copy file name to clipboardExpand all lines: README.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
# nativeapi
2
2
3
-
Unified access to native system APIs — windows, tray icons, menus, displays, keyboard, dialogs, storage and more — from Dart/Flutter, Rust, C#, JavaScript/TypeScriptand Python, all built on one C++ core.
3
+
Unified access to native system APIs — windows, tray icons, menus, displays, keyboard, dialogs, storage and more — from Dart/Flutter, Rust, C#, JavaScript/TypeScript, Python and Go, all built on one C++ core.
4
4
5
5
| Android | iOS | Linux | macOS | Windows |
6
6
|:-------:|:---:|:-----:|:-----:|:-------:|
7
7
| ✅ | ✅ | ✅ | ✅ | ✅ |
8
8
9
9
🚧 **Work in Progress**: the API is under active development.
10
10
11
-
This repository is the home of every binding: the Dart, Rust, C#, JSand Python bindings, the code generator, the design specs and the shared tooling live here directly, and the C++ core ([nativeapi-core](https://github.com/libnativeapi/nativeapi-core)) is checked out as a git submodule. A core change and its regenerated bindings (core → codegen → bindings) are made and tracked together.
11
+
This repository is the home of every binding: the Dart, Rust, C#, JS, Python and Go bindings, the code generator, the design specs and the shared tooling live here directly, and the C++ core ([nativeapi-core](https://github.com/libnativeapi/nativeapi-core)) is checked out as a git submodule. A core change and its regenerated bindings (core → codegen → bindings) are made and tracked together.
12
12
13
13
## Bindings
14
14
@@ -19,6 +19,7 @@ This repository is the home of every binding: the Dart, Rust, C#, JS and Python
19
19
|[C#](bindings/csharp)|`NativeAPI`| not yet on NuGet; build from source |
20
20
|[JavaScript / TypeScript](bindings/js)|`nativeapi` (Node-API addon for Node.js, Deno and Bun) | not yet on npm |
21
21
|[Python](bindings/python)|`nativeapi` (`ctypes`, Python 3.10+) | prototype, not yet on PyPI |
22
+
|[Go](bindings/go)|`github.com/libnativeapi/nativeapi/bindings/go` (cgo, Go 1.22+) | build from source |
22
23
23
24
Each binding's README covers installation and usage.
24
25
@@ -36,7 +37,8 @@ This repository was `nativeapi-flutter`, then `nativeapi-workspace`, and is now
|[examples](examples)| example apps of every binding, prefixed by binding: `flutter_*`, `rust_*`, `csharp_*`, `js_*`, `python_*`, … |
40
+
|[bindings/go](bindings/go)| Go binding (cgo) |
41
+
|[examples](examples)| example apps of every binding, prefixed by binding: `flutter_*`, `rust_*`, `csharp_*`, `js_*`, `python_*`, `go_*`, … |
40
42
|[tools/codegen](tools/codegen)| the C ABI and binding generators |
41
43
|[specs](specs)| design rules for the core's public API |
42
44
@@ -86,7 +88,7 @@ Work on the bindings, the tooling and the specs is committed here directly. Work
86
88
87
89
## Releases
88
90
89
-
Each binding is released from a tag of its own: `v<version>` publishes the Dart packages to pub.dev (`dart-release.yml`), `rust-v<version>` publishes the crates to crates.io (`rust-release.yml`). The C#, JSand Python bindings are not published yet.
91
+
Each binding is released from a tag of its own: `v<version>` publishes the Dart packages to pub.dev (`dart-release.yml`), `rust-v<version>` publishes the crates to crates.io (`rust-release.yml`). The C#, JS, Python and Go bindings are not published yet.
0 commit comments