small tweaks

This commit is contained in:
EthanShoeDev
2025-10-07 10:19:45 -04:00
parent 8e7ec01e28
commit e4139c6f7b
7 changed files with 99 additions and 32 deletions

View File

@@ -50,7 +50,7 @@
"expo-font": "~14.0.8", "expo-font": "~14.0.8",
"expo-glass-effect": "^0.1.4", "expo-glass-effect": "^0.1.4",
"expo-haptics": "~15.0.7", "expo-haptics": "~15.0.7",
"expo-image": "~3.0.8", "expo-image": "~3.0.9",
"expo-linking": "~8.0.8", "expo-linking": "~8.0.8",
"expo-router": "6.0.10", "expo-router": "6.0.10",
"expo-secure-store": "~15.0.7", "expo-secure-store": "~15.0.7",

View File

@@ -16,11 +16,42 @@ Peer dependencies (you manage): `react`, `react-native`.
### Usage ### Usage
This package exposes a native Rust module for SSH transport. For a complete, This package exposes a native Rust module for SSH transport. For a complete,
working integration, see the example app in this monorepo at `apps/mobile`. working integration, see the example app:
- https://github.com/EthanShoeDev/fressh/tree/main/apps/mobile
### API overview
High-level API surface (see code for full types):
```ts
import { RnRussh } from '@fressh/react-native-uniffi-russh';
await RnRussh.uniffiInitAsync();
const conn = await RnRussh.connect({
host: 'example.com',
port: 22,
username: 'me',
security: { type: 'password', password: '...' },
onServerKey: async () => true,
});
const shell = await conn.startShell({ term: 'Xterm' });
shell.addListener(
(ev) => {
// handle TerminalChunk or DropNotice
},
{ cursor: { mode: 'live' } },
);
```
### Links ### Links
- Changelog: [`CHANGELOG.md`](./CHANGELOG.md) - Changelog:
- Contributing: see the monorepo guide at [`CHANGELOG.md`](https://github.com/EthanShoeDev/fressh/blob/main/packages/react-native-uniffi-russh/CHANGELOG.md)
[`../../CONTRIBUTING.md`](../../CONTRIBUTING.md) - Contributing:
[`CONTRIBUTING.md`](https://github.com/EthanShoeDev/fressh/blob/main/CONTRIBUTING.md)
- API source:
[`src/api.ts`](https://github.com/EthanShoeDev/fressh/blob/main/packages/react-native-uniffi-russh/src/api.ts)
- License: MIT - License: MIT

View File

@@ -1,6 +1,6 @@
{ {
"name": "@fressh/react-native-uniffi-russh", "name": "@fressh/react-native-uniffi-russh",
"homepage": "https://github.com/EthanShoeDev/fressh", "homepage": "https://github.com/EthanShoeDev/fressh#readme",
"license": "MIT", "license": "MIT",
"description": "Uniffi bindings for russh", "description": "Uniffi bindings for russh",
"version": "0.0.1", "version": "0.0.1",
@@ -52,15 +52,23 @@
"release": "GITHUB_TOKEN=$(gh auth token) release-it", "release": "GITHUB_TOKEN=$(gh auth token) release-it",
"release:dry": "release-it --dry-run" "release:dry": "release-it --dry-run"
}, },
"keywords": [
"react-native",
"ios",
"android"
],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/EthanShoeDev/fressh.git" "url": "git+https://github.com/EthanShoeDev/fressh.git"
}, },
"bugs": {
"url": "https://github.com/EthanShoeDev/fressh/issues"
},
"keywords": [
"react-native",
"ssh",
"russh",
"uniffi",
"rust",
"expo",
"android",
"ios"
],
"author": "EthanShoeDev <13422990+EthanShoeDev@users.noreply.github.com> (https://github.com/EthanShoeDev)", "author": "EthanShoeDev <13422990+EthanShoeDev@users.noreply.github.com> (https://github.com/EthanShoeDev)",
"publishConfig": { "publishConfig": {
"registry": "https://registry.npmjs.org/" "registry": "https://registry.npmjs.org/"

View File

@@ -24,7 +24,7 @@
"dependsOn": ["build:bob"], "dependsOn": ["build:bob"],
}, },
"typecheck": { "typecheck": {
"dependsOn": ["build:native"], "dependsOn": ["build:native", "build:bob"],
}, },
// Special tasks // Special tasks

View File

@@ -11,28 +11,33 @@ defaults and a bridge for input and output.
pnpm add @fressh/react-native-xtermjs-webview react-native-webview pnpm add @fressh/react-native-xtermjs-webview react-native-webview
``` ```
Peer dependencies: `react`, `react-dom` (for web), `react-native-webview`. Peer dependencies: `react`, `react-native-webview`.
### Usage ### Usage
See `apps/mobile` in this monorepo for a complete example. Basic usage: For a complete production example, see the mobile app:
https://github.com/EthanShoeDev/fressh/tree/main/apps/mobile
Basic usage:
```tsx ```tsx
import React, { useRef } from 'react'; import React, { useRef } from 'react';
import { import type { XtermWebViewHandle } from '@fressh/react-native-xtermjs-webview';
XtermJsWebView, import { XtermJsWebView } from '@fressh/react-native-xtermjs-webview';
type XtermWebViewHandle,
} from '@fressh/react-native-xtermjs-webview';
export function Terminal() { export function Terminal() {
const termRef = useRef<XtermWebViewHandle | null>(null); const termRef = useRef<XtermWebViewHandle | null>(null);
return ( return (
<XtermJsWebView <XtermJsWebView
ref={termRef} ref={termRef}
onInitialized={() => onInitialized={() => {
termRef.current?.write(new TextEncoder().encode('hello')) const hello = new TextEncoder().encode('hello');
} termRef.current?.write(hello);
onData={(input) => console.log('user input:', input)} }}
onData={(input) => {
console.log('user input:', input);
}}
/> />
); );
} }
@@ -60,8 +65,14 @@ transparency and debugging.
### Links ### Links
- Changelog: [`CHANGELOG.md`](./CHANGELOG.md) - Changelog:
- Contributing: see the monorepo guide at [`CHANGELOG.md`](https://github.com/EthanShoeDev/fressh/blob/main/packages/react-native-xtermjs-webview/CHANGELOG.md)
[`../../CONTRIBUTING.md`](../../CONTRIBUTING.md) - Contributing:
- Example: `apps/mobile` [`CONTRIBUTING.md`](https://github.com/EthanShoeDev/fressh/blob/main/CONTRIBUTING.md)
- Example app:
[`apps/mobile`](https://github.com/EthanShoeDev/fressh/tree/main/apps/mobile)
and source usage:
[`apps/mobile/src/app/(tabs)/shell/detail.tsx`](<https://github.com/EthanShoeDev/fressh/blob/main/apps/mobile/src/app/(tabs)/shell/detail.tsx>)
- API source:
[`src/index.tsx`](https://github.com/EthanShoeDev/fressh/blob/main/packages/react-native-xtermjs-webview/src/index.tsx)
- License: MIT - License: MIT

View File

@@ -15,6 +15,24 @@
"exports": { "exports": {
".": "./dist/index.js" ".": "./dist/index.js"
}, },
"repository": {
"type": "git",
"url": "git+https://github.com/EthanShoeDev/fressh.git"
},
"bugs": {
"url": "https://github.com/EthanShoeDev/fressh/issues"
},
"homepage": "https://github.com/EthanShoeDev/fressh#readme",
"keywords": [
"react-native",
"xterm",
"webview",
"terminal",
"ssh",
"expo",
"android",
"ios"
],
"scripts": { "scripts": {
"fmt": "cross-env SORT_IMPORTS=true prettier --write .", "fmt": "cross-env SORT_IMPORTS=true prettier --write .",
"fmt:check": "cross-env SORT_IMPORTS=true prettier --check .", "fmt:check": "cross-env SORT_IMPORTS=true prettier --check .",
@@ -33,7 +51,6 @@
}, },
"peerDependencies": { "peerDependencies": {
"react": "19.1.0", "react": "19.1.0",
"react-dom": "19.1.0",
"react-native-webview": "13.15.0" "react-native-webview": "13.15.0"
}, },
"devDependencies": { "devDependencies": {

10
pnpm-lock.yaml generated
View File

@@ -113,8 +113,8 @@ importers:
specifier: ~15.0.7 specifier: ~15.0.7
version: 15.0.7(expo@54.0.12) version: 15.0.7(expo@54.0.12)
expo-image: expo-image:
specifier: ~3.0.8 specifier: ~3.0.9
version: 3.0.8(expo@54.0.12)(react-native-web@0.21.1(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0) version: 3.0.9(expo@54.0.12)(react-native-web@0.21.1(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0)
expo-linking: expo-linking:
specifier: ~8.0.8 specifier: ~8.0.8
version: 8.0.8(expo@54.0.12)(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0) version: 8.0.8(expo@54.0.12)(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0)
@@ -5336,8 +5336,8 @@ packages:
peerDependencies: peerDependencies:
expo: '*' expo: '*'
expo-image@3.0.8: expo-image@3.0.9:
resolution: {integrity: sha512-L83fTHVjvE5hACxUXPk3dpABteI/IypeqxKMeOAAcT2eB/jbqT53ddsYKEvKAP86eoByQ7+TCtw9AOUizEtaTQ==} resolution: {integrity: sha512-GkPIjeqrODMBdpbRWOzbwiq8ztxjgq1rdZrnqwt/pzQavgXPlr4rW/7aigue9Jm5t5vebhMNAuc1A/XIXXqpcA==}
peerDependencies: peerDependencies:
expo: '*' expo: '*'
react: '*' react: '*'
@@ -15754,7 +15754,7 @@ snapshots:
dependencies: dependencies:
expo: 54.0.12(@babel/core@7.28.3)(@expo/metro-runtime@6.1.1)(expo-router@6.0.10)(react-native-webview@13.15.0(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0))(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0) expo: 54.0.12(@babel/core@7.28.3)(@expo/metro-runtime@6.1.1)(expo-router@6.0.10)(react-native-webview@13.15.0(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0))(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0)
expo-image@3.0.8(expo@54.0.12)(react-native-web@0.21.1(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0): expo-image@3.0.9(expo@54.0.12)(react-native-web@0.21.1(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0):
dependencies: dependencies:
expo: 54.0.12(@babel/core@7.28.3)(@expo/metro-runtime@6.1.1)(expo-router@6.0.10)(react-native-webview@13.15.0(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0))(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0) expo: 54.0.12(@babel/core@7.28.3)(@expo/metro-runtime@6.1.1)(expo-router@6.0.10)(react-native-webview@13.15.0(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0))(react-native@0.81.4(@babel/core@7.28.3)(@react-native-community/cli@20.0.2(typescript@5.9.2))(@types/react@19.1.12)(react@19.1.0))(react@19.1.0)
react: 19.1.0 react: 19.1.0