Skip to content

Commit c4e8fe7

Browse files
committed
fix(npm): ship native/*/examples/ + document perry-ffi sibling-checkout (v0.3.1)
Two issues reported against the v0.3.0 npm tarball: 1. native/{macos,ios,windows,linux}/Cargo.toml declare [[example]] blocks pointing at examples/demo_editor.rs etc., but examples/ wasn't in the tarball — `cargo build` failed with "can't find demo_editor example at examples/demo_editor.rs". Fix: add `native/*/examples/**` to `files:`. Tarball grew from 121 → 140 files / 265 KB → 347 KB. 2. native/{macos,ios}/Cargo.toml have `perry-ffi = { path = "../../../../perry/perry/crates/perry-ffi" }` — a sibling-checkout-only path that doesn't survive `npm install`. perry-ffi isn't on crates.io, so the real fix requires Perry to publish it (filed PerryTS/perry#1112). Until that lands, document the [patch.crates-io] workaround in: - native/NATIVE_CRATES.md (new) — full consumer setup guide - README "Consuming the native crates from npm" section - comment block above the perry-ffi line in each affected Cargo.toml Web target is unaffected by either — Perry compiles the TS editor itself to WASM and the renderer is plain TypeScript at native/web/dom-ffi.ts, no Rust build path at all. Found by: @honeide/editor consumers using the macOS native crate from a Perry app after `npm install`.
1 parent b567bdf commit c4e8fe7

5 files changed

Lines changed: 97 additions & 1 deletion

File tree

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,23 @@ cargo run --example demo_editor_ios
167167

168168
Launches a fully interactive editor in the iOS Simulator with touch input, soft keyboard, and syntax highlighting.
169169

170+
## Consuming the native crates from npm
171+
172+
The npm tarball ships every native rendering crate's Rust source so consumers
173+
can build them as part of their Perry-AOT pipeline. Two prerequisites apply
174+
until upstream Perry work lands — see [`native/NATIVE_CRATES.md`](native/NATIVE_CRATES.md)
175+
for the full story:
176+
177+
1. `perry-ffi` is currently an unpublished workspace crate inside Perry's
178+
monorepo. Either keep a Perry checkout next to your project, or add a
179+
`[patch.crates-io]` in your workspace root pointing at it. Tracking issue:
180+
[PerryTS/perry#1112](https://github.com/PerryTS/perry/issues/1112).
181+
2. Each crate's `Cargo.toml` declares `[[example]]` blocks; the `examples/`
182+
directory is shipped as of `0.3.1`.
183+
184+
The **web target** doesn't need any of this — it compiles TypeScript → WASM
185+
via Perry and the renderer is TypeScript, so there's no Rust crate to build.
186+
170187
## Design Decisions
171188

172189
- **No external editor dependencies** — no CodeMirror, Monaco, or ProseMirror. Fully self-contained.

native/NATIVE_CRATES.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Building the native crates after `npm install @honeide/editor`
2+
3+
The npm tarball ships the Rust source for every native rendering crate
4+
(`native/macos/`, `native/ios/`, `native/windows/`, `native/linux/`,
5+
`native/android/`) so consumers can build them as part of their Perry-AOT
6+
pipeline. To make those builds resolve, two prerequisites must be in place
7+
locally — both are Perry-side constraints we hope to remove once Perry ships
8+
the missing pieces.
9+
10+
## 1. `perry-ffi` must be resolvable to Cargo
11+
12+
The crates' `Cargo.toml` files declare:
13+
14+
```toml
15+
perry-ffi = { path = "../../../../perry/perry/crates/perry-ffi" }
16+
```
17+
18+
That relative path resolves in a **sibling-checkout layout**:
19+
20+
```
21+
~/code/
22+
├── hone/hone-editor/ ← your fork / clone
23+
└── perry/perry/ ← Perry monorepo checkout
24+
```
25+
26+
After `npm install @honeide/editor`, the editor lands at
27+
`node_modules/@honeide/editor/`, so the `../../../../perry/...` path no longer
28+
points anywhere useful. You'll see:
29+
30+
```
31+
error: no matching package found for `perry-ffi`
32+
```
33+
34+
**Workaround until [PerryTS/perry#1112](https://github.com/PerryTS/perry/issues/1112) lands** (publishing `perry-ffi` to crates.io):
35+
36+
Add a `[patch.crates-io]` to **your workspace's root** `Cargo.toml` pointing
37+
at a local Perry checkout:
38+
39+
```toml
40+
[patch.crates-io]
41+
perry-ffi = { path = "/absolute/path/to/perry-checkout/crates/perry-ffi" }
42+
```
43+
44+
Or, if you're a Perry user, add a workspace `Cargo.toml` at your project root
45+
that includes the editor's native crate as a member and uses the same `[patch]`.
46+
47+
Once Perry publishes `perry-ffi` to crates.io, we'll switch this dep to a
48+
version-based requirement (`perry-ffi = "0.5"`) and this workaround goes away.
49+
50+
## 2. Building the demos requires the `examples/` directory
51+
52+
Each native crate ships its `examples/` folder in the npm tarball as of
53+
`@honeide/editor@0.3.1+`. You can run them with:
54+
55+
```bash
56+
cd node_modules/@honeide/editor/native/macos
57+
cargo run --example demo_editor
58+
```
59+
60+
(Older `@honeide/editor@0.3.0` was missing `examples/` in the tarball even
61+
though `Cargo.toml` declared `[[example]]` blocks — that gap is fixed in
62+
0.3.1.)
63+
64+
## Web doesn't need any of this
65+
66+
The web target compiles the editor TS itself to WASM via Perry. The
67+
"renderer" on web is plain TypeScript (`native/web/dom-ffi.ts`) — no Rust
68+
crate, no `perry-ffi`, no Cargo. See [`../examples/web/`](../examples/web/)
69+
for the build pipeline.

native/ios/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ objc = "0.2"
1818
serde = { version = "1", features = ["derive"] }
1919
serde_json = "1"
2020
libc = "0.2"
21+
# perry-ffi is currently unpublished; this relative path assumes a sibling
22+
# Perry checkout. After `npm install @honeide/editor` you'll need a workspace
23+
# `[patch.crates-io] perry-ffi = { path = "..." }` pointing at your Perry
24+
# checkout — see native/NATIVE_CRATES.md and PerryTS/perry#1112.
2125
perry-ffi = { path = "../../../../perry/perry/crates/perry-ffi" }

native/macos/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ objc = "0.2"
1616
serde = { version = "1", features = ["derive"] }
1717
serde_json = "1"
1818
libc = "0.2"
19+
# perry-ffi is currently unpublished; this relative path assumes a sibling
20+
# Perry checkout. After `npm install @honeide/editor` you'll need a workspace
21+
# `[patch.crates-io] perry-ffi = { path = "..." }` pointing at your Perry
22+
# checkout — see native/NATIVE_CRATES.md and PerryTS/perry#1112.
1923
perry-ffi = { path = "../../../../perry/perry/crates/perry-ffi" }
2024

2125
# Tree-sitter for TextMate-quality highlighting. Phase 0 PoC validated TS+Python;

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@honeide/editor",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "High-performance, cross-platform code editor surface",
55
"main": "core/index.ts",
66
"types": "core/index.ts",
@@ -13,11 +13,13 @@
1313
"perry/",
1414
"view-model/",
1515
"perry.config.ts",
16+
"native/NATIVE_CRATES.md",
1617
"native/*/src/**",
1718
"native/*/Cargo.toml",
1819
"native/*/Cargo.lock",
1920
"native/*/README.md",
2021
"native/*/build.rs",
22+
"native/*/examples/**",
2123
"native/web/dom-ffi.ts",
2224
"native/web/tree-sitter-bridge.ts"
2325
],

0 commit comments

Comments
 (0)