@fressh/react-native-terminal 0.1.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 (73) hide show
  1. package/README.md +182 -0
  2. package/ReactNativeTerminal.podspec +82 -0
  3. package/android/CMakeLists.txt +76 -0
  4. package/android/build.gradle +121 -0
  5. package/android/fix-prefab.gradle +51 -0
  6. package/android/src/main/assets/fonts/DejaVuSansMono.ttf +0 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +180 -0
  8. package/android/src/main/java/com/margelo/nitro/fressh/HybridTerminal.kt +146 -0
  9. package/android/src/main/java/com/margelo/nitro/fressh/ReactNativeTerminalModule.kt +43 -0
  10. package/android/src/main/java/com/margelo/nitro/fressh/ReactNativeTerminalPackage.kt +32 -0
  11. package/android/src/main/jniLibs/arm64-v8a/libshim_uniffi.so +0 -0
  12. package/android/src/main/jniLibs/x86_64/libshim_uniffi.so +0 -0
  13. package/babel.config.js +12 -0
  14. package/cpp/README.md +14 -0
  15. package/cpp/generated/shim_uniffi.cpp +4246 -0
  16. package/cpp/generated/shim_uniffi.hpp +364 -0
  17. package/ios/FresshTerminalRenderABI.h +46 -0
  18. package/ios/HybridTerminal.swift +144 -0
  19. package/ios/ReactNativeTerminalUniffi.mm +77 -0
  20. package/ios/fetch-angle.sh +39 -0
  21. package/ios/fonts/DejaVuSansMono.ttf +0 -0
  22. package/libEGL.xcframework/Info.plist +44 -0
  23. package/libEGL.xcframework/ios-arm64/libEGL.framework/Info.plist +0 -0
  24. package/libEGL.xcframework/ios-arm64/libEGL.framework/libEGL +0 -0
  25. package/libEGL.xcframework/ios-arm64_x86_64-simulator/libEGL.framework/Info.plist +0 -0
  26. package/libEGL.xcframework/ios-arm64_x86_64-simulator/libEGL.framework/libEGL +0 -0
  27. package/libGLESv2.xcframework/Info.plist +44 -0
  28. package/libGLESv2.xcframework/ios-arm64/libGLESv2.framework/Info.plist +0 -0
  29. package/libGLESv2.xcframework/ios-arm64/libGLESv2.framework/libGLESv2 +0 -0
  30. package/libGLESv2.xcframework/ios-arm64_x86_64-simulator/libGLESv2.framework/Info.plist +0 -0
  31. package/libGLESv2.xcframework/ios-arm64_x86_64-simulator/libGLESv2.framework/libGLESv2 +0 -0
  32. package/nitro/Terminal.nitro.ts +40 -0
  33. package/nitrogen/generated/.gitattributes +1 -0
  34. package/nitrogen/generated/android/ReactNativeTerminal+autolinking.cmake +83 -0
  35. package/nitrogen/generated/android/ReactNativeTerminal+autolinking.gradle +27 -0
  36. package/nitrogen/generated/android/ReactNativeTerminalOnLoad.cpp +56 -0
  37. package/nitrogen/generated/android/ReactNativeTerminalOnLoad.hpp +34 -0
  38. package/nitrogen/generated/android/c++/JHybridTerminalSpec.cpp +76 -0
  39. package/nitrogen/generated/android/c++/JHybridTerminalSpec.hpp +68 -0
  40. package/nitrogen/generated/android/c++/views/JHybridTerminalStateUpdater.cpp +64 -0
  41. package/nitrogen/generated/android/c++/views/JHybridTerminalStateUpdater.hpp +49 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/fressh/HybridTerminalSpec.kt +69 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/fressh/ReactNativeTerminalOnLoad.kt +35 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/fressh/views/HybridTerminalManager.kt +80 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/fressh/views/HybridTerminalStateUpdater.kt +23 -0
  46. package/nitrogen/generated/ios/ReactNativeTerminal+autolinking.rb +62 -0
  47. package/nitrogen/generated/ios/ReactNativeTerminal-Swift-Cxx-Bridge.cpp +33 -0
  48. package/nitrogen/generated/ios/ReactNativeTerminal-Swift-Cxx-Bridge.hpp +57 -0
  49. package/nitrogen/generated/ios/ReactNativeTerminal-Swift-Cxx-Umbrella.hpp +43 -0
  50. package/nitrogen/generated/ios/ReactNativeTerminalAutolinking.mm +33 -0
  51. package/nitrogen/generated/ios/ReactNativeTerminalAutolinking.swift +26 -0
  52. package/nitrogen/generated/ios/c++/HybridTerminalSpecSwift.cpp +11 -0
  53. package/nitrogen/generated/ios/c++/HybridTerminalSpecSwift.hpp +96 -0
  54. package/nitrogen/generated/ios/c++/views/HybridTerminalComponent.mm +132 -0
  55. package/nitrogen/generated/ios/swift/HybridTerminalSpec.swift +57 -0
  56. package/nitrogen/generated/ios/swift/HybridTerminalSpec_cxx.swift +204 -0
  57. package/nitrogen/generated/shared/c++/HybridTerminalSpec.cpp +26 -0
  58. package/nitrogen/generated/shared/c++/HybridTerminalSpec.hpp +68 -0
  59. package/nitrogen/generated/shared/c++/views/HybridTerminalComponent.cpp +110 -0
  60. package/nitrogen/generated/shared/c++/views/HybridTerminalComponent.hpp +113 -0
  61. package/nitrogen/generated/shared/json/TerminalConfig.json +12 -0
  62. package/package.json +97 -0
  63. package/react-native.config.js +12 -0
  64. package/shim_uniffi.xcframework/Info.plist +44 -0
  65. package/shim_uniffi.xcframework/ios-arm64/libshim_uniffi.a +0 -0
  66. package/shim_uniffi.xcframework/ios-arm64_x86_64-simulator/libshim_uniffi.a +0 -0
  67. package/src/Terminal.tsx +135 -0
  68. package/src/generated/shim_uniffi-ffi.ts +320 -0
  69. package/src/generated/shim_uniffi.ts +2527 -0
  70. package/src/index.ts +52 -0
  71. package/src/ssh.ts +239 -0
  72. package/tsconfig.json +31 -0
  73. package/ubrn.config.yaml +24 -0
@@ -0,0 +1,2527 @@
1
+ // This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
2
+ // Trust me, you don't want to mess with it!
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ // @ts-nocheck
6
+ import nativeModule from "./shim_uniffi-ffi";
7
+ import {
8
+ type UniffiRustFutureContinuationCallback,
9
+ type UniffiForeignFutureDroppedCallback,
10
+ type UniffiForeignFutureDroppedCallbackStruct,
11
+ type UniffiVTableCallbackInterfaceShimUniffiFresshEventListener,
12
+ } from "./shim_uniffi-ffi";
13
+ import {
14
+ type FfiConverter,
15
+ type UniffiByteArray,
16
+ type UniffiGcObject,
17
+ type UniffiHandle,
18
+ type UniffiObjectFactory,
19
+ type UniffiReferenceHolder,
20
+ type UniffiRustCallStatus,
21
+ AbstractFfiConverterByteArray,
22
+ FfiConverterArrayBuffer,
23
+ FfiConverterBool,
24
+ FfiConverterFloat32,
25
+ FfiConverterInt32,
26
+ FfiConverterObject,
27
+ FfiConverterObjectWithCallbacks,
28
+ FfiConverterOptional,
29
+ FfiConverterUInt16,
30
+ FfiConverterUInt32,
31
+ FfiConverterUInt64,
32
+ FfiConverterUInt8,
33
+ RustBuffer,
34
+ UniffiAbstractObject,
35
+ UniffiEnum,
36
+ UniffiError,
37
+ UniffiInternalError,
38
+ UniffiResult,
39
+ UniffiRustCaller,
40
+ destructorGuardSymbol,
41
+ pointerLiteralSymbol,
42
+ uniffiCreateFfiConverterString,
43
+ uniffiCreateRecord,
44
+ uniffiRustCallAsync,
45
+ uniffiTraitInterfaceCall,
46
+ uniffiTypeNameSymbol,
47
+ variantOrdinalSymbol,
48
+ } from "@ubjs/core";
49
+ const uniffiCaller = new UniffiRustCaller(() => ({ code: 0 }));
50
+
51
+ const uniffiIsDebug =
52
+ // @ts-ignore -- The process global might not be defined
53
+ typeof process !== "object" ||
54
+ // @ts-ignore -- The process global might not be defined
55
+ process?.env?.NODE_ENV !== "production" ||
56
+ false;
57
+
58
+ // Public interface members begin here.
59
+
60
+ /**
61
+ * Tear down a preview shell created by [`create_preview`]. Emits no `ShellClosed`
62
+ * event (preview lifetime is owned by the settings screen, not the session list).
63
+ */
64
+ export async function closePreview(
65
+ previewId: string,
66
+ asyncOpts_?: { signal: AbortSignal }
67
+ ): Promise<void> {
68
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
69
+ try {
70
+ return await uniffiRustCallAsync(
71
+ /*rustCaller:*/ uniffiCaller,
72
+ /*rustFutureFunc:*/ () => {
73
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_close_preview(
74
+ FfiConverterString.lower(previewId, nativeModule().rustbuffer_alloc)
75
+ );
76
+ },
77
+ /*pollFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_poll_void,
78
+ /*cancelFunc:*/ nativeModule()
79
+ .ubrn_ffi_shim_uniffi_rust_future_cancel_void,
80
+ /*completeFunc:*/ nativeModule()
81
+ .ubrn_ffi_shim_uniffi_rust_future_complete_void,
82
+ /*freeFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_free_void,
83
+ /*liftFunc:*/ (_v) => {},
84
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
85
+ /*asyncOpts:*/ asyncOpts_
86
+ );
87
+ } catch (__error: any) {
88
+ if (uniffiIsDebug && __error instanceof Error) {
89
+ __error.stack = __stack;
90
+ }
91
+ throw __error;
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Close a shell channel and drop its `Term`.
97
+ */
98
+ export async function closeShell(
99
+ shellId: string,
100
+ asyncOpts_?: { signal: AbortSignal }
101
+ ): Promise<void> /*throws*/ {
102
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
103
+ try {
104
+ return await uniffiRustCallAsync(
105
+ /*rustCaller:*/ uniffiCaller,
106
+ /*rustFutureFunc:*/ () => {
107
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_close_shell(
108
+ FfiConverterString.lower(shellId, nativeModule().rustbuffer_alloc)
109
+ );
110
+ },
111
+ /*pollFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_poll_void,
112
+ /*cancelFunc:*/ nativeModule()
113
+ .ubrn_ffi_shim_uniffi_rust_future_cancel_void,
114
+ /*completeFunc:*/ nativeModule()
115
+ .ubrn_ffi_shim_uniffi_rust_future_complete_void,
116
+ /*freeFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_free_void,
117
+ /*liftFunc:*/ (_v) => {},
118
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
119
+ /*asyncOpts:*/ asyncOpts_,
120
+ /*errorHandler:*/ FfiConverterTypeSshError.lift.bind(
121
+ FfiConverterTypeSshError
122
+ )
123
+ );
124
+ } catch (__error: any) {
125
+ if (uniffiIsDebug && __error instanceof Error) {
126
+ __error.stack = __stack;
127
+ }
128
+ throw __error;
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Connect + authenticate. Returns the connection id. A `HostKeyPending` event is
134
+ * emitted mid-handshake; answer it with [`respond_to_host_key`].
135
+ */
136
+ export async function connect(
137
+ details: ConnectionDetails,
138
+ asyncOpts_?: { signal: AbortSignal }
139
+ ): Promise<string> /*throws*/ {
140
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
141
+ try {
142
+ return await uniffiRustCallAsync(
143
+ /*rustCaller:*/ uniffiCaller,
144
+ /*rustFutureFunc:*/ () => {
145
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_connect(
146
+ FfiConverterTypeConnectionDetails.lower(
147
+ details,
148
+ nativeModule().rustbuffer_alloc
149
+ )
150
+ );
151
+ },
152
+ /*pollFunc:*/ nativeModule()
153
+ .ubrn_ffi_shim_uniffi_rust_future_poll_rust_buffer,
154
+ /*cancelFunc:*/ nativeModule()
155
+ .ubrn_ffi_shim_uniffi_rust_future_cancel_rust_buffer,
156
+ /*completeFunc:*/ nativeModule()
157
+ .ubrn_ffi_shim_uniffi_rust_future_complete_rust_buffer,
158
+ /*freeFunc:*/ nativeModule()
159
+ .ubrn_ffi_shim_uniffi_rust_future_free_rust_buffer,
160
+ // Async returns always go through the JS-side converter: the
161
+ // FFI symbol returns the future handle (u64), and the user-level
162
+ // RustBuffer comes back via the shared `rust_future_complete_*`
163
+ // export. The bytes the runtime hands back must be deserialized
164
+ // here using the per-callable return-type converter.
165
+ /*liftFunc:*/ FfiConverterString.lift.bind(FfiConverterString),
166
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
167
+ /*asyncOpts:*/ asyncOpts_,
168
+ /*errorHandler:*/ FfiConverterTypeSshError.lift.bind(
169
+ FfiConverterTypeSshError
170
+ )
171
+ );
172
+ } catch (__error: any) {
173
+ if (uniffiIsDebug && __error instanceof Error) {
174
+ __error.stack = __stack;
175
+ }
176
+ throw __error;
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Create a non-SSH preview shell fed a canned snippet, bound by `previewId`.
182
+ * Render it with `<Terminal shellId={previewId} />` — the live config still flows
183
+ * through, so it reflows as Terminal settings change. Tear down with
184
+ * [`close_preview`]. Sync (no network round-trip).
185
+ */
186
+ export function createPreview(previewId: string, demo: ArrayBuffer): void {
187
+ uniffiCaller.rustCall(
188
+ /*caller:*/ (callStatus) => {
189
+ nativeModule().ubrn_uniffi_shim_uniffi_fn_func_create_preview(
190
+ FfiConverterString.lower(previewId, nativeModule().rustbuffer_alloc),
191
+ FfiConverterArrayBuffer.lower(demo, nativeModule().rustbuffer_alloc),
192
+ callStatus
193
+ );
194
+ },
195
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
196
+ );
197
+ }
198
+
199
+ /**
200
+ * Disconnect a connection (closes its shells first).
201
+ */
202
+ export async function disconnect(
203
+ connectionId: string,
204
+ asyncOpts_?: { signal: AbortSignal }
205
+ ): Promise<void> /*throws*/ {
206
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
207
+ try {
208
+ return await uniffiRustCallAsync(
209
+ /*rustCaller:*/ uniffiCaller,
210
+ /*rustFutureFunc:*/ () => {
211
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_disconnect(
212
+ FfiConverterString.lower(
213
+ connectionId,
214
+ nativeModule().rustbuffer_alloc
215
+ )
216
+ );
217
+ },
218
+ /*pollFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_poll_void,
219
+ /*cancelFunc:*/ nativeModule()
220
+ .ubrn_ffi_shim_uniffi_rust_future_cancel_void,
221
+ /*completeFunc:*/ nativeModule()
222
+ .ubrn_ffi_shim_uniffi_rust_future_complete_void,
223
+ /*freeFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_free_void,
224
+ /*liftFunc:*/ (_v) => {},
225
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
226
+ /*asyncOpts:*/ asyncOpts_,
227
+ /*errorHandler:*/ FfiConverterTypeSshError.lift.bind(
228
+ FfiConverterTypeSshError
229
+ )
230
+ );
231
+ } catch (__error: any) {
232
+ if (uniffiIsDebug && __error instanceof Error) {
233
+ __error.stack = __stack;
234
+ }
235
+ throw __error;
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Generate a new key pair (OpenSSH private-key string).
241
+ */
242
+ export function generateKeyPair(keyType: KeyType): string /*throws*/ {
243
+ return ((__rb: Uint8Array) => {
244
+ try {
245
+ return FfiConverterString.lift(__rb);
246
+ } finally {
247
+ nativeModule().rustbuffer_free(__rb);
248
+ }
249
+ })(
250
+ uniffiCaller.rustCallWithError(
251
+ /*liftError:*/ FfiConverterTypeSshError.lift.bind(
252
+ FfiConverterTypeSshError
253
+ ),
254
+ /*caller:*/ (callStatus) => {
255
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_generate_key_pair(
256
+ FfiConverterTypeKeyType.lower(
257
+ keyType,
258
+ nativeModule().rustbuffer_alloc
259
+ ),
260
+ callStatus
261
+ );
262
+ },
263
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
264
+ )
265
+ );
266
+ }
267
+
268
+ /**
269
+ * Resize a shell's terminal.
270
+ */
271
+ export async function resize(
272
+ shellId: string,
273
+ cols: number,
274
+ rows: number,
275
+ asyncOpts_?: { signal: AbortSignal }
276
+ ): Promise<void> /*throws*/ {
277
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
278
+ try {
279
+ return await uniffiRustCallAsync(
280
+ /*rustCaller:*/ uniffiCaller,
281
+ /*rustFutureFunc:*/ () => {
282
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_resize(
283
+ FfiConverterString.lower(shellId, nativeModule().rustbuffer_alloc),
284
+ FfiConverterUInt32.lower(cols, nativeModule().rustbuffer_alloc),
285
+ FfiConverterUInt32.lower(rows, nativeModule().rustbuffer_alloc)
286
+ );
287
+ },
288
+ /*pollFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_poll_void,
289
+ /*cancelFunc:*/ nativeModule()
290
+ .ubrn_ffi_shim_uniffi_rust_future_cancel_void,
291
+ /*completeFunc:*/ nativeModule()
292
+ .ubrn_ffi_shim_uniffi_rust_future_complete_void,
293
+ /*freeFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_free_void,
294
+ /*liftFunc:*/ (_v) => {},
295
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
296
+ /*asyncOpts:*/ asyncOpts_,
297
+ /*errorHandler:*/ FfiConverterTypeSshError.lift.bind(
298
+ FfiConverterTypeSshError
299
+ )
300
+ );
301
+ } catch (__error: any) {
302
+ if (uniffiIsDebug && __error instanceof Error) {
303
+ __error.stack = __stack;
304
+ }
305
+ throw __error;
306
+ }
307
+ }
308
+
309
+ /**
310
+ * Resume a parked host-key decision (accept/reject the server key).
311
+ */
312
+ export function respondToHostKey(connectionId: string, accept: boolean): void {
313
+ uniffiCaller.rustCall(
314
+ /*caller:*/ (callStatus) => {
315
+ nativeModule().ubrn_uniffi_shim_uniffi_fn_func_respond_to_host_key(
316
+ FfiConverterString.lower(connectionId, nativeModule().rustbuffer_alloc),
317
+ FfiConverterBool.lower(accept, nativeModule().rustbuffer_alloc),
318
+ callStatus
319
+ );
320
+ },
321
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
322
+ );
323
+ }
324
+
325
+ /**
326
+ * Run a one-off command on an existing connection without a PTY/shell. The
327
+ * interactive shell (if any) is untouched. Note: runs in the login/home dir — an
328
+ * `exec` channel does NOT inherit a live shell's cwd (use `cd … && …` if needed).
329
+ */
330
+ export async function runCommand(
331
+ connectionId: string,
332
+ command: string,
333
+ asyncOpts_?: { signal: AbortSignal }
334
+ ): Promise<CommandResult> /*throws*/ {
335
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
336
+ try {
337
+ return await uniffiRustCallAsync(
338
+ /*rustCaller:*/ uniffiCaller,
339
+ /*rustFutureFunc:*/ () => {
340
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_run_command(
341
+ FfiConverterString.lower(
342
+ connectionId,
343
+ nativeModule().rustbuffer_alloc
344
+ ),
345
+ FfiConverterString.lower(command, nativeModule().rustbuffer_alloc)
346
+ );
347
+ },
348
+ /*pollFunc:*/ nativeModule()
349
+ .ubrn_ffi_shim_uniffi_rust_future_poll_rust_buffer,
350
+ /*cancelFunc:*/ nativeModule()
351
+ .ubrn_ffi_shim_uniffi_rust_future_cancel_rust_buffer,
352
+ /*completeFunc:*/ nativeModule()
353
+ .ubrn_ffi_shim_uniffi_rust_future_complete_rust_buffer,
354
+ /*freeFunc:*/ nativeModule()
355
+ .ubrn_ffi_shim_uniffi_rust_future_free_rust_buffer,
356
+ // Async returns always go through the JS-side converter: the
357
+ // FFI symbol returns the future handle (u64), and the user-level
358
+ // RustBuffer comes back via the shared `rust_future_complete_*`
359
+ // export. The bytes the runtime hands back must be deserialized
360
+ // here using the per-callable return-type converter.
361
+ /*liftFunc:*/ FfiConverterTypeCommandResult.lift.bind(
362
+ FfiConverterTypeCommandResult
363
+ ),
364
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
365
+ /*asyncOpts:*/ asyncOpts_,
366
+ /*errorHandler:*/ FfiConverterTypeSshError.lift.bind(
367
+ FfiConverterTypeSshError
368
+ )
369
+ );
370
+ } catch (__error: any) {
371
+ if (uniffiIsDebug && __error instanceof Error) {
372
+ __error.stack = __stack;
373
+ }
374
+ throw __error;
375
+ }
376
+ }
377
+
378
+ /**
379
+ * Scroll a shell by `delta_px` physical px (positive = finger dragged down =
380
+ * older content). Honors mouse-reporting / alt-screen modes; otherwise moves the
381
+ * scrollback viewport. Touch gestures live in JS and call this by `shellId`.
382
+ */
383
+ export async function scroll(
384
+ shellId: string,
385
+ deltaPx: number,
386
+ asyncOpts_?: { signal: AbortSignal }
387
+ ): Promise<void> /*throws*/ {
388
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
389
+ try {
390
+ return await uniffiRustCallAsync(
391
+ /*rustCaller:*/ uniffiCaller,
392
+ /*rustFutureFunc:*/ () => {
393
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_scroll(
394
+ FfiConverterString.lower(shellId, nativeModule().rustbuffer_alloc),
395
+ FfiConverterFloat32.lower(deltaPx, nativeModule().rustbuffer_alloc)
396
+ );
397
+ },
398
+ /*pollFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_poll_void,
399
+ /*cancelFunc:*/ nativeModule()
400
+ .ubrn_ffi_shim_uniffi_rust_future_cancel_void,
401
+ /*completeFunc:*/ nativeModule()
402
+ .ubrn_ffi_shim_uniffi_rust_future_complete_void,
403
+ /*freeFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_free_void,
404
+ /*liftFunc:*/ (_v) => {},
405
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
406
+ /*asyncOpts:*/ asyncOpts_,
407
+ /*errorHandler:*/ FfiConverterTypeSshError.lift.bind(
408
+ FfiConverterTypeSshError
409
+ )
410
+ );
411
+ } catch (__error: any) {
412
+ if (uniffiIsDebug && __error instanceof Error) {
413
+ __error.stack = __stack;
414
+ }
415
+ throw __error;
416
+ }
417
+ }
418
+
419
+ /**
420
+ * Clear any active selection.
421
+ */
422
+ export function selectionClear(shellId: string): void {
423
+ uniffiCaller.rustCall(
424
+ /*caller:*/ (callStatus) => {
425
+ nativeModule().ubrn_uniffi_shim_uniffi_fn_func_selection_clear(
426
+ FfiConverterString.lower(shellId, nativeModule().rustbuffer_alloc),
427
+ callStatus
428
+ );
429
+ },
430
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
431
+ );
432
+ }
433
+
434
+ /**
435
+ * Begin a selection at a touch point (physical px, surface-relative).
436
+ */
437
+ export function selectionStart(
438
+ shellId: string,
439
+ x: number,
440
+ y: number,
441
+ kind: SelectionKind
442
+ ): void {
443
+ uniffiCaller.rustCall(
444
+ /*caller:*/ (callStatus) => {
445
+ nativeModule().ubrn_uniffi_shim_uniffi_fn_func_selection_start(
446
+ FfiConverterString.lower(shellId, nativeModule().rustbuffer_alloc),
447
+ FfiConverterFloat32.lower(x, nativeModule().rustbuffer_alloc),
448
+ FfiConverterFloat32.lower(y, nativeModule().rustbuffer_alloc),
449
+ FfiConverterTypeSelectionKind.lower(
450
+ kind,
451
+ nativeModule().rustbuffer_alloc
452
+ ),
453
+ callStatus
454
+ );
455
+ },
456
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
457
+ );
458
+ }
459
+
460
+ /**
461
+ * The currently selected text, if any.
462
+ */
463
+ export function selectionText(shellId: string): string | undefined {
464
+ return ((__rb: Uint8Array) => {
465
+ try {
466
+ return FfiConverterOptionalString.lift(__rb);
467
+ } finally {
468
+ nativeModule().rustbuffer_free(__rb);
469
+ }
470
+ })(
471
+ uniffiCaller.rustCall(
472
+ /*caller:*/ (callStatus) => {
473
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_selection_text(
474
+ FfiConverterString.lower(shellId, nativeModule().rustbuffer_alloc),
475
+ callStatus
476
+ );
477
+ },
478
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
479
+ )
480
+ );
481
+ }
482
+
483
+ /**
484
+ * Extend the active selection to a touch point (physical px).
485
+ */
486
+ export function selectionUpdate(shellId: string, x: number, y: number): void {
487
+ uniffiCaller.rustCall(
488
+ /*caller:*/ (callStatus) => {
489
+ nativeModule().ubrn_uniffi_shim_uniffi_fn_func_selection_update(
490
+ FfiConverterString.lower(shellId, nativeModule().rustbuffer_alloc),
491
+ FfiConverterFloat32.lower(x, nativeModule().rustbuffer_alloc),
492
+ FfiConverterFloat32.lower(y, nativeModule().rustbuffer_alloc),
493
+ callStatus
494
+ );
495
+ },
496
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
497
+ );
498
+ }
499
+
500
+ /**
501
+ * Send user input (stdin) to a shell. (Also available on the render plane.)
502
+ */
503
+ export async function sendData(
504
+ shellId: string,
505
+ data: ArrayBuffer,
506
+ asyncOpts_?: { signal: AbortSignal }
507
+ ): Promise<void> /*throws*/ {
508
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
509
+ try {
510
+ return await uniffiRustCallAsync(
511
+ /*rustCaller:*/ uniffiCaller,
512
+ /*rustFutureFunc:*/ () => {
513
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_send_data(
514
+ FfiConverterString.lower(shellId, nativeModule().rustbuffer_alloc),
515
+ FfiConverterArrayBuffer.lower(data, nativeModule().rustbuffer_alloc)
516
+ );
517
+ },
518
+ /*pollFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_poll_void,
519
+ /*cancelFunc:*/ nativeModule()
520
+ .ubrn_ffi_shim_uniffi_rust_future_cancel_void,
521
+ /*completeFunc:*/ nativeModule()
522
+ .ubrn_ffi_shim_uniffi_rust_future_complete_void,
523
+ /*freeFunc:*/ nativeModule().ubrn_ffi_shim_uniffi_rust_future_free_void,
524
+ /*liftFunc:*/ (_v) => {},
525
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
526
+ /*asyncOpts:*/ asyncOpts_,
527
+ /*errorHandler:*/ FfiConverterTypeSshError.lift.bind(
528
+ FfiConverterTypeSshError
529
+ )
530
+ );
531
+ } catch (__error: any) {
532
+ if (uniffiIsDebug && __error instanceof Error) {
533
+ __error.stack = __stack;
534
+ }
535
+ throw __error;
536
+ }
537
+ }
538
+
539
+ /**
540
+ * Install the JS event listener. Call once at module init.
541
+ */
542
+ export function setEventListener(listener: FresshEventListener): void {
543
+ uniffiCaller.rustCall(
544
+ /*caller:*/ (callStatus) => {
545
+ nativeModule().ubrn_uniffi_shim_uniffi_fn_func_set_event_listener(
546
+ FfiConverterTypeFresshEventListener.lower(
547
+ listener,
548
+ nativeModule().rustbuffer_alloc
549
+ ),
550
+ callStatus
551
+ );
552
+ },
553
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
554
+ );
555
+ }
556
+
557
+ /**
558
+ * Open a PTY + shell, returning the new shell id. Render with `<Terminal shellId=…/>`.
559
+ */
560
+ export async function startShell(
561
+ connectionId: string,
562
+ options: ShellOptions,
563
+ asyncOpts_?: { signal: AbortSignal }
564
+ ): Promise<string> /*throws*/ {
565
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
566
+ try {
567
+ return await uniffiRustCallAsync(
568
+ /*rustCaller:*/ uniffiCaller,
569
+ /*rustFutureFunc:*/ () => {
570
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_start_shell(
571
+ FfiConverterString.lower(
572
+ connectionId,
573
+ nativeModule().rustbuffer_alloc
574
+ ),
575
+ FfiConverterTypeShellOptions.lower(
576
+ options,
577
+ nativeModule().rustbuffer_alloc
578
+ )
579
+ );
580
+ },
581
+ /*pollFunc:*/ nativeModule()
582
+ .ubrn_ffi_shim_uniffi_rust_future_poll_rust_buffer,
583
+ /*cancelFunc:*/ nativeModule()
584
+ .ubrn_ffi_shim_uniffi_rust_future_cancel_rust_buffer,
585
+ /*completeFunc:*/ nativeModule()
586
+ .ubrn_ffi_shim_uniffi_rust_future_complete_rust_buffer,
587
+ /*freeFunc:*/ nativeModule()
588
+ .ubrn_ffi_shim_uniffi_rust_future_free_rust_buffer,
589
+ // Async returns always go through the JS-side converter: the
590
+ // FFI symbol returns the future handle (u64), and the user-level
591
+ // RustBuffer comes back via the shared `rust_future_complete_*`
592
+ // export. The bytes the runtime hands back must be deserialized
593
+ // here using the per-callable return-type converter.
594
+ /*liftFunc:*/ FfiConverterString.lift.bind(FfiConverterString),
595
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString),
596
+ /*asyncOpts:*/ asyncOpts_,
597
+ /*errorHandler:*/ FfiConverterTypeSshError.lift.bind(
598
+ FfiConverterTypeSshError
599
+ )
600
+ );
601
+ } catch (__error: any) {
602
+ if (uniffiIsDebug && __error instanceof Error) {
603
+ __error.stack = __stack;
604
+ }
605
+ throw __error;
606
+ }
607
+ }
608
+
609
+ /**
610
+ * Validate a private key; returns its canonical OpenSSH form.
611
+ */
612
+ export function validatePrivateKey(pem: string): string /*throws*/ {
613
+ return ((__rb: Uint8Array) => {
614
+ try {
615
+ return FfiConverterString.lift(__rb);
616
+ } finally {
617
+ nativeModule().rustbuffer_free(__rb);
618
+ }
619
+ })(
620
+ uniffiCaller.rustCallWithError(
621
+ /*liftError:*/ FfiConverterTypeSshError.lift.bind(
622
+ FfiConverterTypeSshError
623
+ ),
624
+ /*caller:*/ (callStatus) => {
625
+ return nativeModule().ubrn_uniffi_shim_uniffi_fn_func_validate_private_key(
626
+ FfiConverterString.lower(pem, nativeModule().rustbuffer_alloc),
627
+ callStatus
628
+ );
629
+ },
630
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
631
+ )
632
+ );
633
+ }
634
+
635
+ // Hermes (React Native ≥ 0.74) ships TextEncoder and encodeInto, but not
636
+ // TextDecoder. For single-string decode (bytesToString), we polyfill via the
637
+ // C++ string_from_buffer helper using a duck-typed object matching the
638
+ // standard TextDecoder.decode signature. Once Hermes ships a real
639
+ // TextDecoder, the `typeof` check will pick it up automatically.
640
+ //
641
+ // For array-of-strings decode (readStringFromBuffer), we keep a dedicated C++
642
+ // helper: the polyfill path (new Uint8Array view + decode) measured ~40%
643
+ // slower on getStringArray benchmarks than a direct (buf, offset, length)
644
+ // call, due to the per-read view allocation and extra property lookups in
645
+ // string_from_buffer.
646
+ const stringConverter = (() => {
647
+ const encoder = new TextEncoder();
648
+ const decoder: { decode(input: UniffiByteArray): string } =
649
+ typeof TextDecoder !== "undefined"
650
+ ? new TextDecoder()
651
+ : {
652
+ decode: (bytes: UniffiByteArray) =>
653
+ nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_from_buffer(
654
+ bytes,
655
+ undefined as any
656
+ ) as string,
657
+ };
658
+ return {
659
+ // Single-string lower() uses the C++ helper — TextEncoder.encode
660
+ // measured ~43% slower on takeString benchmarks.
661
+ stringToBytes: (s: string) =>
662
+ nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_buffer(
663
+ s,
664
+ undefined as any
665
+ ),
666
+ bytesToString: (ab: UniffiByteArray) => decoder.decode(ab),
667
+ // Direct C++ call — bypasses uniffiCaller.rustCall() overhead.
668
+ // Matters for N-element arrays.
669
+ stringByteLength: (s: string) =>
670
+ nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length(
671
+ s,
672
+ undefined as any
673
+ ) as number,
674
+ // Encode directly into the RustBuffer backing store via
675
+ // TextEncoder.encodeInto — zero intermediate allocation. Replaces
676
+ // the old C++ write_string_into_buffer helper.
677
+ writeStringIntoBuffer: (s: string, buf: any, offset: number): number => {
678
+ const view = new Uint8Array(
679
+ buf.arrayBuffer,
680
+ offset,
681
+ buf.arrayBuffer.byteLength - offset
682
+ );
683
+ return encoder.encodeInto(s, view).written;
684
+ },
685
+ // Dedicated C++ helper — avoids per-read Uint8Array allocation and
686
+ // the double property-lookup in string_from_buffer.
687
+ readStringFromBuffer: (buf: any, offset: number, length: number): string =>
688
+ nativeModule().ubrn_uniffi_internal_fn_func_ffi__read_string_from_buffer(
689
+ buf,
690
+ offset,
691
+ length
692
+ ) as string,
693
+ };
694
+ })();
695
+ const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
696
+
697
+ /**
698
+ * Output of a one-off [`run_command`]: stdout/stderr decoded UTF-8-lossy (for
699
+ * display) + the exit code (absent if killed by a signal).
700
+ */
701
+ export type CommandResult = {
702
+ stdout: string;
703
+ stderr: string;
704
+ exitCode?: number;
705
+ };
706
+
707
+ /**
708
+ * Generated factory for {@link CommandResult} record objects.
709
+ */
710
+ export const CommandResult = (() => {
711
+ const defaults = () => ({});
712
+ const create = (() => {
713
+ return uniffiCreateRecord<CommandResult, ReturnType<typeof defaults>>(
714
+ defaults
715
+ );
716
+ })();
717
+ return Object.freeze({
718
+ create,
719
+ new: create,
720
+ defaults: () => Object.freeze(defaults()) as Partial<CommandResult>,
721
+ });
722
+ })();
723
+
724
+ const FfiConverterTypeCommandResult = (() => {
725
+ type TypeName = CommandResult;
726
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
727
+ read(from: RustBuffer): TypeName {
728
+ return {
729
+ stdout: FfiConverterString.read(from),
730
+ stderr: FfiConverterString.read(from),
731
+ exitCode: FfiConverterOptionalInt32.read(from),
732
+ };
733
+ }
734
+ write(value: TypeName, into: RustBuffer): void {
735
+ FfiConverterString.write(value.stdout, into);
736
+ FfiConverterString.write(value.stderr, into);
737
+ FfiConverterOptionalInt32.write(value.exitCode, into);
738
+ }
739
+ allocationSize(value: TypeName): number {
740
+ return (
741
+ FfiConverterString.allocationSize(value.stdout) +
742
+ FfiConverterString.allocationSize(value.stderr) +
743
+ FfiConverterOptionalInt32.allocationSize(value.exitCode)
744
+ );
745
+ }
746
+ }
747
+ return new FFIConverter();
748
+ })();
749
+
750
+ // Enum: Security
751
+ export enum Security_Tags {
752
+ Password = "Password",
753
+ Key = "Key",
754
+ }
755
+ export const Security = (() => {
756
+ type Password__interface = {
757
+ tag: Security_Tags.Password;
758
+ inner: Readonly<{ password: string }>;
759
+ };
760
+ class Password_ extends UniffiEnum implements Password__interface {
761
+ /**
762
+ * @private
763
+ * This field is private and should not be used, use `tag` instead.
764
+ */
765
+ readonly [uniffiTypeNameSymbol] = "Security";
766
+ readonly tag = Security_Tags.Password;
767
+ readonly inner: Readonly<{ password: string }>;
768
+ constructor(inner: { password: string }) {
769
+ super("Security", "Password");
770
+
771
+ this.inner = Object.freeze(inner);
772
+ }
773
+ static new(inner: { password: string }): Password_ {
774
+ return new Password_(inner);
775
+ }
776
+
777
+ static instanceOf(obj: any): obj is Password_ {
778
+ return obj.tag === Security_Tags.Password;
779
+ }
780
+ }
781
+
782
+ type Key__interface = {
783
+ tag: Security_Tags.Key;
784
+ inner: Readonly<{ privateKeyContent: string }>;
785
+ };
786
+ class Key_ extends UniffiEnum implements Key__interface {
787
+ /**
788
+ * @private
789
+ * This field is private and should not be used, use `tag` instead.
790
+ */
791
+ readonly [uniffiTypeNameSymbol] = "Security";
792
+ readonly tag = Security_Tags.Key;
793
+ readonly inner: Readonly<{ privateKeyContent: string }>;
794
+ constructor(inner: { privateKeyContent: string }) {
795
+ super("Security", "Key");
796
+
797
+ this.inner = Object.freeze(inner);
798
+ }
799
+ static new(inner: { privateKeyContent: string }): Key_ {
800
+ return new Key_(inner);
801
+ }
802
+
803
+ static instanceOf(obj: any): obj is Key_ {
804
+ return obj.tag === Security_Tags.Key;
805
+ }
806
+ }
807
+
808
+ function instanceOf(obj: any): obj is Security {
809
+ return obj[uniffiTypeNameSymbol] === "Security";
810
+ }
811
+
812
+ return Object.freeze({
813
+ instanceOf,
814
+ Password: Password_,
815
+ Key: Key_,
816
+ });
817
+ })();
818
+ export type Security = InstanceType<(typeof Security)["Password" | "Key"]>;
819
+
820
+ // FfiConverter for enum Security
821
+ const FfiConverterTypeSecurity = (() => {
822
+ const ordinalConverter = FfiConverterInt32;
823
+ type TypeName = Security;
824
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
825
+ read(from: RustBuffer): TypeName {
826
+ switch (ordinalConverter.read(from)) {
827
+ case 1:
828
+ return new Security.Password({
829
+ password: FfiConverterString.read(from),
830
+ });
831
+ case 2:
832
+ return new Security.Key({
833
+ privateKeyContent: FfiConverterString.read(from),
834
+ });
835
+ default:
836
+ throw new UniffiInternalError.UnexpectedEnumCase();
837
+ }
838
+ }
839
+ write(value: TypeName, into: RustBuffer): void {
840
+ switch (value.tag) {
841
+ case Security_Tags.Password: {
842
+ ordinalConverter.write(1, into);
843
+ const inner = value.inner;
844
+ FfiConverterString.write(inner.password, into);
845
+ return;
846
+ }
847
+ case Security_Tags.Key: {
848
+ ordinalConverter.write(2, into);
849
+ const inner = value.inner;
850
+ FfiConverterString.write(inner.privateKeyContent, into);
851
+ return;
852
+ }
853
+ default:
854
+ // Throwing from here means that Security_Tags hasn't matched an ordinal.
855
+ throw new UniffiInternalError.UnexpectedEnumCase();
856
+ }
857
+ }
858
+ allocationSize(value: TypeName): number {
859
+ switch (value.tag) {
860
+ case Security_Tags.Password: {
861
+ const inner = value.inner;
862
+ let size = ordinalConverter.allocationSize(1);
863
+ size += FfiConverterString.allocationSize(inner.password);
864
+ return size;
865
+ }
866
+ case Security_Tags.Key: {
867
+ const inner = value.inner;
868
+ let size = ordinalConverter.allocationSize(2);
869
+ size += FfiConverterString.allocationSize(inner.privateKeyContent);
870
+ return size;
871
+ }
872
+ default:
873
+ throw new UniffiInternalError.UnexpectedEnumCase();
874
+ }
875
+ }
876
+ }
877
+ return new FFIConverter();
878
+ })();
879
+
880
+ export type ConnectionDetails = {
881
+ host: string;
882
+ port: number;
883
+ username: string;
884
+ security: Security;
885
+ };
886
+
887
+ /**
888
+ * Generated factory for {@link ConnectionDetails} record objects.
889
+ */
890
+ export const ConnectionDetails = (() => {
891
+ const defaults = () => ({});
892
+ const create = (() => {
893
+ return uniffiCreateRecord<ConnectionDetails, ReturnType<typeof defaults>>(
894
+ defaults
895
+ );
896
+ })();
897
+ return Object.freeze({
898
+ create,
899
+ new: create,
900
+ defaults: () => Object.freeze(defaults()) as Partial<ConnectionDetails>,
901
+ });
902
+ })();
903
+
904
+ const FfiConverterTypeConnectionDetails = (() => {
905
+ type TypeName = ConnectionDetails;
906
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
907
+ read(from: RustBuffer): TypeName {
908
+ return {
909
+ host: FfiConverterString.read(from),
910
+ port: FfiConverterUInt16.read(from),
911
+ username: FfiConverterString.read(from),
912
+ security: FfiConverterTypeSecurity.read(from),
913
+ };
914
+ }
915
+ write(value: TypeName, into: RustBuffer): void {
916
+ FfiConverterString.write(value.host, into);
917
+ FfiConverterUInt16.write(value.port, into);
918
+ FfiConverterString.write(value.username, into);
919
+ FfiConverterTypeSecurity.write(value.security, into);
920
+ }
921
+ allocationSize(value: TypeName): number {
922
+ return (
923
+ FfiConverterString.allocationSize(value.host) +
924
+ FfiConverterUInt16.allocationSize(value.port) +
925
+ FfiConverterString.allocationSize(value.username) +
926
+ FfiConverterTypeSecurity.allocationSize(value.security)
927
+ );
928
+ }
929
+ }
930
+ return new FFIConverter();
931
+ })();
932
+
933
+ export type ServerPublicKeyInfo = {
934
+ host: string;
935
+ port: number;
936
+ remoteIp?: string;
937
+ algorithm: string;
938
+ fingerprintSha256: string;
939
+ keyBase64: string;
940
+ };
941
+
942
+ /**
943
+ * Generated factory for {@link ServerPublicKeyInfo} record objects.
944
+ */
945
+ export const ServerPublicKeyInfo = (() => {
946
+ const defaults = () => ({});
947
+ const create = (() => {
948
+ return uniffiCreateRecord<ServerPublicKeyInfo, ReturnType<typeof defaults>>(
949
+ defaults
950
+ );
951
+ })();
952
+ return Object.freeze({
953
+ create,
954
+ new: create,
955
+ defaults: () => Object.freeze(defaults()) as Partial<ServerPublicKeyInfo>,
956
+ });
957
+ })();
958
+
959
+ const FfiConverterTypeServerPublicKeyInfo = (() => {
960
+ type TypeName = ServerPublicKeyInfo;
961
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
962
+ read(from: RustBuffer): TypeName {
963
+ return {
964
+ host: FfiConverterString.read(from),
965
+ port: FfiConverterUInt16.read(from),
966
+ remoteIp: FfiConverterOptionalString.read(from),
967
+ algorithm: FfiConverterString.read(from),
968
+ fingerprintSha256: FfiConverterString.read(from),
969
+ keyBase64: FfiConverterString.read(from),
970
+ };
971
+ }
972
+ write(value: TypeName, into: RustBuffer): void {
973
+ FfiConverterString.write(value.host, into);
974
+ FfiConverterUInt16.write(value.port, into);
975
+ FfiConverterOptionalString.write(value.remoteIp, into);
976
+ FfiConverterString.write(value.algorithm, into);
977
+ FfiConverterString.write(value.fingerprintSha256, into);
978
+ FfiConverterString.write(value.keyBase64, into);
979
+ }
980
+ allocationSize(value: TypeName): number {
981
+ return (
982
+ FfiConverterString.allocationSize(value.host) +
983
+ FfiConverterUInt16.allocationSize(value.port) +
984
+ FfiConverterOptionalString.allocationSize(value.remoteIp) +
985
+ FfiConverterString.allocationSize(value.algorithm) +
986
+ FfiConverterString.allocationSize(value.fingerprintSha256) +
987
+ FfiConverterString.allocationSize(value.keyBase64)
988
+ );
989
+ }
990
+ }
991
+ return new FFIConverter();
992
+ })();
993
+
994
+ export enum TerminalType {
995
+ Vanilla,
996
+ Vt100,
997
+ Vt102,
998
+ Vt220,
999
+ Ansi,
1000
+ Xterm,
1001
+ Xterm256,
1002
+ }
1003
+
1004
+ const FfiConverterTypeTerminalType = (() => {
1005
+ const ordinalConverter = FfiConverterInt32;
1006
+ type TypeName = TerminalType;
1007
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1008
+ read(from: RustBuffer): TypeName {
1009
+ switch (ordinalConverter.read(from)) {
1010
+ case 1:
1011
+ return TerminalType.Vanilla;
1012
+ case 2:
1013
+ return TerminalType.Vt100;
1014
+ case 3:
1015
+ return TerminalType.Vt102;
1016
+ case 4:
1017
+ return TerminalType.Vt220;
1018
+ case 5:
1019
+ return TerminalType.Ansi;
1020
+ case 6:
1021
+ return TerminalType.Xterm;
1022
+ case 7:
1023
+ return TerminalType.Xterm256;
1024
+ default:
1025
+ throw new UniffiInternalError.UnexpectedEnumCase();
1026
+ }
1027
+ }
1028
+ write(value: TypeName, into: RustBuffer): void {
1029
+ switch (value) {
1030
+ case TerminalType.Vanilla:
1031
+ return ordinalConverter.write(1, into);
1032
+ case TerminalType.Vt100:
1033
+ return ordinalConverter.write(2, into);
1034
+ case TerminalType.Vt102:
1035
+ return ordinalConverter.write(3, into);
1036
+ case TerminalType.Vt220:
1037
+ return ordinalConverter.write(4, into);
1038
+ case TerminalType.Ansi:
1039
+ return ordinalConverter.write(5, into);
1040
+ case TerminalType.Xterm:
1041
+ return ordinalConverter.write(6, into);
1042
+ case TerminalType.Xterm256:
1043
+ return ordinalConverter.write(7, into);
1044
+ }
1045
+ }
1046
+ allocationSize(value: TypeName): number {
1047
+ return ordinalConverter.allocationSize(0);
1048
+ }
1049
+ }
1050
+ return new FFIConverter();
1051
+ })();
1052
+
1053
+ export type ShellOptions = {
1054
+ term: TerminalType;
1055
+ cols: number;
1056
+ rows: number;
1057
+ scrollbackLines: number;
1058
+ /**
1059
+ * Auto-inject OSC 633 shell integration on connect (cwd / command lifecycle /
1060
+ * exit code / command text). `None` ⇒ default on. Set `false` from the app's
1061
+ * global kill-switch / per-host toggle to behave like a plain SSH client.
1062
+ */
1063
+ shellIntegration?: boolean;
1064
+ };
1065
+
1066
+ /**
1067
+ * Generated factory for {@link ShellOptions} record objects.
1068
+ */
1069
+ export const ShellOptions = (() => {
1070
+ const defaults = () => ({});
1071
+ const create = (() => {
1072
+ return uniffiCreateRecord<ShellOptions, ReturnType<typeof defaults>>(
1073
+ defaults
1074
+ );
1075
+ })();
1076
+ return Object.freeze({
1077
+ create,
1078
+ new: create,
1079
+ defaults: () => Object.freeze(defaults()) as Partial<ShellOptions>,
1080
+ });
1081
+ })();
1082
+
1083
+ const FfiConverterTypeShellOptions = (() => {
1084
+ type TypeName = ShellOptions;
1085
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1086
+ read(from: RustBuffer): TypeName {
1087
+ return {
1088
+ term: FfiConverterTypeTerminalType.read(from),
1089
+ cols: FfiConverterUInt32.read(from),
1090
+ rows: FfiConverterUInt32.read(from),
1091
+ scrollbackLines: FfiConverterUInt32.read(from),
1092
+ shellIntegration: FfiConverterOptionalBoolean.read(from),
1093
+ };
1094
+ }
1095
+ write(value: TypeName, into: RustBuffer): void {
1096
+ FfiConverterTypeTerminalType.write(value.term, into);
1097
+ FfiConverterUInt32.write(value.cols, into);
1098
+ FfiConverterUInt32.write(value.rows, into);
1099
+ FfiConverterUInt32.write(value.scrollbackLines, into);
1100
+ FfiConverterOptionalBoolean.write(value.shellIntegration, into);
1101
+ }
1102
+ allocationSize(value: TypeName): number {
1103
+ return (
1104
+ FfiConverterTypeTerminalType.allocationSize(value.term) +
1105
+ FfiConverterUInt32.allocationSize(value.cols) +
1106
+ FfiConverterUInt32.allocationSize(value.rows) +
1107
+ FfiConverterUInt32.allocationSize(value.scrollbackLines) +
1108
+ FfiConverterOptionalBoolean.allocationSize(value.shellIntegration)
1109
+ );
1110
+ }
1111
+ }
1112
+ return new FFIConverter();
1113
+ })();
1114
+
1115
+ export enum SshConnectionProgressEvent {
1116
+ TcpConnected,
1117
+ SshHandshake,
1118
+ }
1119
+
1120
+ const FfiConverterTypeSshConnectionProgressEvent = (() => {
1121
+ const ordinalConverter = FfiConverterInt32;
1122
+ type TypeName = SshConnectionProgressEvent;
1123
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1124
+ read(from: RustBuffer): TypeName {
1125
+ switch (ordinalConverter.read(from)) {
1126
+ case 1:
1127
+ return SshConnectionProgressEvent.TcpConnected;
1128
+ case 2:
1129
+ return SshConnectionProgressEvent.SshHandshake;
1130
+ default:
1131
+ throw new UniffiInternalError.UnexpectedEnumCase();
1132
+ }
1133
+ }
1134
+ write(value: TypeName, into: RustBuffer): void {
1135
+ switch (value) {
1136
+ case SshConnectionProgressEvent.TcpConnected:
1137
+ return ordinalConverter.write(1, into);
1138
+ case SshConnectionProgressEvent.SshHandshake:
1139
+ return ordinalConverter.write(2, into);
1140
+ }
1141
+ }
1142
+ allocationSize(value: TypeName): number {
1143
+ return ordinalConverter.allocationSize(0);
1144
+ }
1145
+ }
1146
+ return new FFIConverter();
1147
+ })();
1148
+
1149
+ // Enum: FresshEvent
1150
+ export enum FresshEvent_Tags {
1151
+ ConnectProgress = "ConnectProgress",
1152
+ HostKeyPending = "HostKeyPending",
1153
+ ConnectionClosed = "ConnectionClosed",
1154
+ ShellClosed = "ShellClosed",
1155
+ WorkingDirectoryChanged = "WorkingDirectoryChanged",
1156
+ PromptStart = "PromptStart",
1157
+ CommandStart = "CommandStart",
1158
+ CommandFinished = "CommandFinished",
1159
+ CommandText = "CommandText",
1160
+ }
1161
+ export const FresshEvent = (() => {
1162
+ type ConnectProgress__interface = {
1163
+ tag: FresshEvent_Tags.ConnectProgress;
1164
+ inner: Readonly<{
1165
+ connectionId: string;
1166
+ event: SshConnectionProgressEvent;
1167
+ }>;
1168
+ };
1169
+ class ConnectProgress_
1170
+ extends UniffiEnum
1171
+ implements ConnectProgress__interface
1172
+ {
1173
+ /**
1174
+ * @private
1175
+ * This field is private and should not be used, use `tag` instead.
1176
+ */
1177
+ readonly [uniffiTypeNameSymbol] = "FresshEvent";
1178
+ readonly tag = FresshEvent_Tags.ConnectProgress;
1179
+ readonly inner: Readonly<{
1180
+ connectionId: string;
1181
+ event: SshConnectionProgressEvent;
1182
+ }>;
1183
+ constructor(inner: {
1184
+ connectionId: string;
1185
+ event: SshConnectionProgressEvent;
1186
+ }) {
1187
+ super("FresshEvent", "ConnectProgress");
1188
+
1189
+ this.inner = Object.freeze(inner);
1190
+ }
1191
+ static new(inner: {
1192
+ connectionId: string;
1193
+ event: SshConnectionProgressEvent;
1194
+ }): ConnectProgress_ {
1195
+ return new ConnectProgress_(inner);
1196
+ }
1197
+
1198
+ static instanceOf(obj: any): obj is ConnectProgress_ {
1199
+ return obj.tag === FresshEvent_Tags.ConnectProgress;
1200
+ }
1201
+ }
1202
+
1203
+ type HostKeyPending__interface = {
1204
+ tag: FresshEvent_Tags.HostKeyPending;
1205
+ inner: Readonly<{ connectionId: string; info: ServerPublicKeyInfo }>;
1206
+ };
1207
+ class HostKeyPending_
1208
+ extends UniffiEnum
1209
+ implements HostKeyPending__interface
1210
+ {
1211
+ /**
1212
+ * @private
1213
+ * This field is private and should not be used, use `tag` instead.
1214
+ */
1215
+ readonly [uniffiTypeNameSymbol] = "FresshEvent";
1216
+ readonly tag = FresshEvent_Tags.HostKeyPending;
1217
+ readonly inner: Readonly<{
1218
+ connectionId: string;
1219
+ info: ServerPublicKeyInfo;
1220
+ }>;
1221
+ constructor(inner: { connectionId: string; info: ServerPublicKeyInfo }) {
1222
+ super("FresshEvent", "HostKeyPending");
1223
+
1224
+ this.inner = Object.freeze(inner);
1225
+ }
1226
+ static new(inner: {
1227
+ connectionId: string;
1228
+ info: ServerPublicKeyInfo;
1229
+ }): HostKeyPending_ {
1230
+ return new HostKeyPending_(inner);
1231
+ }
1232
+
1233
+ static instanceOf(obj: any): obj is HostKeyPending_ {
1234
+ return obj.tag === FresshEvent_Tags.HostKeyPending;
1235
+ }
1236
+ }
1237
+
1238
+ type ConnectionClosed__interface = {
1239
+ tag: FresshEvent_Tags.ConnectionClosed;
1240
+ inner: Readonly<{ connectionId: string }>;
1241
+ };
1242
+ class ConnectionClosed_
1243
+ extends UniffiEnum
1244
+ implements ConnectionClosed__interface
1245
+ {
1246
+ /**
1247
+ * @private
1248
+ * This field is private and should not be used, use `tag` instead.
1249
+ */
1250
+ readonly [uniffiTypeNameSymbol] = "FresshEvent";
1251
+ readonly tag = FresshEvent_Tags.ConnectionClosed;
1252
+ readonly inner: Readonly<{ connectionId: string }>;
1253
+ constructor(inner: { connectionId: string }) {
1254
+ super("FresshEvent", "ConnectionClosed");
1255
+
1256
+ this.inner = Object.freeze(inner);
1257
+ }
1258
+ static new(inner: { connectionId: string }): ConnectionClosed_ {
1259
+ return new ConnectionClosed_(inner);
1260
+ }
1261
+
1262
+ static instanceOf(obj: any): obj is ConnectionClosed_ {
1263
+ return obj.tag === FresshEvent_Tags.ConnectionClosed;
1264
+ }
1265
+ }
1266
+
1267
+ type ShellClosed__interface = {
1268
+ tag: FresshEvent_Tags.ShellClosed;
1269
+ inner: Readonly<{ shellId: string }>;
1270
+ };
1271
+ class ShellClosed_ extends UniffiEnum implements ShellClosed__interface {
1272
+ /**
1273
+ * @private
1274
+ * This field is private and should not be used, use `tag` instead.
1275
+ */
1276
+ readonly [uniffiTypeNameSymbol] = "FresshEvent";
1277
+ readonly tag = FresshEvent_Tags.ShellClosed;
1278
+ readonly inner: Readonly<{ shellId: string }>;
1279
+ constructor(inner: { shellId: string }) {
1280
+ super("FresshEvent", "ShellClosed");
1281
+
1282
+ this.inner = Object.freeze(inner);
1283
+ }
1284
+ static new(inner: { shellId: string }): ShellClosed_ {
1285
+ return new ShellClosed_(inner);
1286
+ }
1287
+
1288
+ static instanceOf(obj: any): obj is ShellClosed_ {
1289
+ return obj.tag === FresshEvent_Tags.ShellClosed;
1290
+ }
1291
+ }
1292
+
1293
+ type WorkingDirectoryChanged__interface = {
1294
+ tag: FresshEvent_Tags.WorkingDirectoryChanged;
1295
+ inner: Readonly<{ shellId: string; path: string }>;
1296
+ };
1297
+ class WorkingDirectoryChanged_
1298
+ extends UniffiEnum
1299
+ implements WorkingDirectoryChanged__interface
1300
+ {
1301
+ /**
1302
+ * @private
1303
+ * This field is private and should not be used, use `tag` instead.
1304
+ */
1305
+ readonly [uniffiTypeNameSymbol] = "FresshEvent";
1306
+ readonly tag = FresshEvent_Tags.WorkingDirectoryChanged;
1307
+ readonly inner: Readonly<{ shellId: string; path: string }>;
1308
+ constructor(inner: { shellId: string; path: string }) {
1309
+ super("FresshEvent", "WorkingDirectoryChanged");
1310
+
1311
+ this.inner = Object.freeze(inner);
1312
+ }
1313
+ static new(inner: {
1314
+ shellId: string;
1315
+ path: string;
1316
+ }): WorkingDirectoryChanged_ {
1317
+ return new WorkingDirectoryChanged_(inner);
1318
+ }
1319
+
1320
+ static instanceOf(obj: any): obj is WorkingDirectoryChanged_ {
1321
+ return obj.tag === FresshEvent_Tags.WorkingDirectoryChanged;
1322
+ }
1323
+ }
1324
+
1325
+ type PromptStart__interface = {
1326
+ tag: FresshEvent_Tags.PromptStart;
1327
+ inner: Readonly<{ shellId: string }>;
1328
+ };
1329
+ class PromptStart_ extends UniffiEnum implements PromptStart__interface {
1330
+ /**
1331
+ * @private
1332
+ * This field is private and should not be used, use `tag` instead.
1333
+ */
1334
+ readonly [uniffiTypeNameSymbol] = "FresshEvent";
1335
+ readonly tag = FresshEvent_Tags.PromptStart;
1336
+ readonly inner: Readonly<{ shellId: string }>;
1337
+ constructor(inner: { shellId: string }) {
1338
+ super("FresshEvent", "PromptStart");
1339
+
1340
+ this.inner = Object.freeze(inner);
1341
+ }
1342
+ static new(inner: { shellId: string }): PromptStart_ {
1343
+ return new PromptStart_(inner);
1344
+ }
1345
+
1346
+ static instanceOf(obj: any): obj is PromptStart_ {
1347
+ return obj.tag === FresshEvent_Tags.PromptStart;
1348
+ }
1349
+ }
1350
+
1351
+ type CommandStart__interface = {
1352
+ tag: FresshEvent_Tags.CommandStart;
1353
+ inner: Readonly<{ shellId: string }>;
1354
+ };
1355
+ class CommandStart_ extends UniffiEnum implements CommandStart__interface {
1356
+ /**
1357
+ * @private
1358
+ * This field is private and should not be used, use `tag` instead.
1359
+ */
1360
+ readonly [uniffiTypeNameSymbol] = "FresshEvent";
1361
+ readonly tag = FresshEvent_Tags.CommandStart;
1362
+ readonly inner: Readonly<{ shellId: string }>;
1363
+ constructor(inner: { shellId: string }) {
1364
+ super("FresshEvent", "CommandStart");
1365
+
1366
+ this.inner = Object.freeze(inner);
1367
+ }
1368
+ static new(inner: { shellId: string }): CommandStart_ {
1369
+ return new CommandStart_(inner);
1370
+ }
1371
+
1372
+ static instanceOf(obj: any): obj is CommandStart_ {
1373
+ return obj.tag === FresshEvent_Tags.CommandStart;
1374
+ }
1375
+ }
1376
+
1377
+ type CommandFinished__interface = {
1378
+ tag: FresshEvent_Tags.CommandFinished;
1379
+ inner: Readonly<{
1380
+ shellId: string;
1381
+ exitCode?: number;
1382
+ durationMs?: bigint;
1383
+ }>;
1384
+ };
1385
+ class CommandFinished_
1386
+ extends UniffiEnum
1387
+ implements CommandFinished__interface
1388
+ {
1389
+ /**
1390
+ * @private
1391
+ * This field is private and should not be used, use `tag` instead.
1392
+ */
1393
+ readonly [uniffiTypeNameSymbol] = "FresshEvent";
1394
+ readonly tag = FresshEvent_Tags.CommandFinished;
1395
+ readonly inner: Readonly<{
1396
+ shellId: string;
1397
+ exitCode?: number;
1398
+ durationMs?: bigint;
1399
+ }>;
1400
+ constructor(inner: {
1401
+ shellId: string;
1402
+ exitCode?: number;
1403
+ durationMs?: bigint;
1404
+ }) {
1405
+ super("FresshEvent", "CommandFinished");
1406
+
1407
+ this.inner = Object.freeze(inner);
1408
+ }
1409
+ static new(inner: {
1410
+ shellId: string;
1411
+ exitCode?: number;
1412
+ durationMs?: bigint;
1413
+ }): CommandFinished_ {
1414
+ return new CommandFinished_(inner);
1415
+ }
1416
+
1417
+ static instanceOf(obj: any): obj is CommandFinished_ {
1418
+ return obj.tag === FresshEvent_Tags.CommandFinished;
1419
+ }
1420
+ }
1421
+
1422
+ type CommandText__interface = {
1423
+ tag: FresshEvent_Tags.CommandText;
1424
+ inner: Readonly<{ shellId: string; command: string }>;
1425
+ };
1426
+ class CommandText_ extends UniffiEnum implements CommandText__interface {
1427
+ /**
1428
+ * @private
1429
+ * This field is private and should not be used, use `tag` instead.
1430
+ */
1431
+ readonly [uniffiTypeNameSymbol] = "FresshEvent";
1432
+ readonly tag = FresshEvent_Tags.CommandText;
1433
+ readonly inner: Readonly<{ shellId: string; command: string }>;
1434
+ constructor(inner: { shellId: string; command: string }) {
1435
+ super("FresshEvent", "CommandText");
1436
+
1437
+ this.inner = Object.freeze(inner);
1438
+ }
1439
+ static new(inner: { shellId: string; command: string }): CommandText_ {
1440
+ return new CommandText_(inner);
1441
+ }
1442
+
1443
+ static instanceOf(obj: any): obj is CommandText_ {
1444
+ return obj.tag === FresshEvent_Tags.CommandText;
1445
+ }
1446
+ }
1447
+
1448
+ function instanceOf(obj: any): obj is FresshEvent {
1449
+ return obj[uniffiTypeNameSymbol] === "FresshEvent";
1450
+ }
1451
+
1452
+ return Object.freeze({
1453
+ instanceOf,
1454
+ ConnectProgress: ConnectProgress_,
1455
+ HostKeyPending: HostKeyPending_,
1456
+ ConnectionClosed: ConnectionClosed_,
1457
+ ShellClosed: ShellClosed_,
1458
+ WorkingDirectoryChanged: WorkingDirectoryChanged_,
1459
+ PromptStart: PromptStart_,
1460
+ CommandStart: CommandStart_,
1461
+ CommandFinished: CommandFinished_,
1462
+ CommandText: CommandText_,
1463
+ });
1464
+ })();
1465
+ export type FresshEvent = InstanceType<
1466
+ (typeof FresshEvent)[
1467
+ | "ConnectProgress"
1468
+ | "HostKeyPending"
1469
+ | "ConnectionClosed"
1470
+ | "ShellClosed"
1471
+ | "WorkingDirectoryChanged"
1472
+ | "PromptStart"
1473
+ | "CommandStart"
1474
+ | "CommandFinished"
1475
+ | "CommandText"]
1476
+ >;
1477
+
1478
+ // FfiConverter for enum FresshEvent
1479
+ const FfiConverterTypeFresshEvent = (() => {
1480
+ const ordinalConverter = FfiConverterInt32;
1481
+ type TypeName = FresshEvent;
1482
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1483
+ read(from: RustBuffer): TypeName {
1484
+ switch (ordinalConverter.read(from)) {
1485
+ case 1:
1486
+ return new FresshEvent.ConnectProgress({
1487
+ connectionId: FfiConverterString.read(from),
1488
+ event: FfiConverterTypeSshConnectionProgressEvent.read(from),
1489
+ });
1490
+ case 2:
1491
+ return new FresshEvent.HostKeyPending({
1492
+ connectionId: FfiConverterString.read(from),
1493
+ info: FfiConverterTypeServerPublicKeyInfo.read(from),
1494
+ });
1495
+ case 3:
1496
+ return new FresshEvent.ConnectionClosed({
1497
+ connectionId: FfiConverterString.read(from),
1498
+ });
1499
+ case 4:
1500
+ return new FresshEvent.ShellClosed({
1501
+ shellId: FfiConverterString.read(from),
1502
+ });
1503
+ case 5:
1504
+ return new FresshEvent.WorkingDirectoryChanged({
1505
+ shellId: FfiConverterString.read(from),
1506
+ path: FfiConverterString.read(from),
1507
+ });
1508
+ case 6:
1509
+ return new FresshEvent.PromptStart({
1510
+ shellId: FfiConverterString.read(from),
1511
+ });
1512
+ case 7:
1513
+ return new FresshEvent.CommandStart({
1514
+ shellId: FfiConverterString.read(from),
1515
+ });
1516
+ case 8:
1517
+ return new FresshEvent.CommandFinished({
1518
+ shellId: FfiConverterString.read(from),
1519
+ exitCode: FfiConverterOptionalInt32.read(from),
1520
+ durationMs: FfiConverterOptionalUInt64.read(from),
1521
+ });
1522
+ case 9:
1523
+ return new FresshEvent.CommandText({
1524
+ shellId: FfiConverterString.read(from),
1525
+ command: FfiConverterString.read(from),
1526
+ });
1527
+ default:
1528
+ throw new UniffiInternalError.UnexpectedEnumCase();
1529
+ }
1530
+ }
1531
+ write(value: TypeName, into: RustBuffer): void {
1532
+ switch (value.tag) {
1533
+ case FresshEvent_Tags.ConnectProgress: {
1534
+ ordinalConverter.write(1, into);
1535
+ const inner = value.inner;
1536
+ FfiConverterString.write(inner.connectionId, into);
1537
+ FfiConverterTypeSshConnectionProgressEvent.write(inner.event, into);
1538
+ return;
1539
+ }
1540
+ case FresshEvent_Tags.HostKeyPending: {
1541
+ ordinalConverter.write(2, into);
1542
+ const inner = value.inner;
1543
+ FfiConverterString.write(inner.connectionId, into);
1544
+ FfiConverterTypeServerPublicKeyInfo.write(inner.info, into);
1545
+ return;
1546
+ }
1547
+ case FresshEvent_Tags.ConnectionClosed: {
1548
+ ordinalConverter.write(3, into);
1549
+ const inner = value.inner;
1550
+ FfiConverterString.write(inner.connectionId, into);
1551
+ return;
1552
+ }
1553
+ case FresshEvent_Tags.ShellClosed: {
1554
+ ordinalConverter.write(4, into);
1555
+ const inner = value.inner;
1556
+ FfiConverterString.write(inner.shellId, into);
1557
+ return;
1558
+ }
1559
+ case FresshEvent_Tags.WorkingDirectoryChanged: {
1560
+ ordinalConverter.write(5, into);
1561
+ const inner = value.inner;
1562
+ FfiConverterString.write(inner.shellId, into);
1563
+ FfiConverterString.write(inner.path, into);
1564
+ return;
1565
+ }
1566
+ case FresshEvent_Tags.PromptStart: {
1567
+ ordinalConverter.write(6, into);
1568
+ const inner = value.inner;
1569
+ FfiConverterString.write(inner.shellId, into);
1570
+ return;
1571
+ }
1572
+ case FresshEvent_Tags.CommandStart: {
1573
+ ordinalConverter.write(7, into);
1574
+ const inner = value.inner;
1575
+ FfiConverterString.write(inner.shellId, into);
1576
+ return;
1577
+ }
1578
+ case FresshEvent_Tags.CommandFinished: {
1579
+ ordinalConverter.write(8, into);
1580
+ const inner = value.inner;
1581
+ FfiConverterString.write(inner.shellId, into);
1582
+ FfiConverterOptionalInt32.write(inner.exitCode, into);
1583
+ FfiConverterOptionalUInt64.write(inner.durationMs, into);
1584
+ return;
1585
+ }
1586
+ case FresshEvent_Tags.CommandText: {
1587
+ ordinalConverter.write(9, into);
1588
+ const inner = value.inner;
1589
+ FfiConverterString.write(inner.shellId, into);
1590
+ FfiConverterString.write(inner.command, into);
1591
+ return;
1592
+ }
1593
+ default:
1594
+ // Throwing from here means that FresshEvent_Tags hasn't matched an ordinal.
1595
+ throw new UniffiInternalError.UnexpectedEnumCase();
1596
+ }
1597
+ }
1598
+ allocationSize(value: TypeName): number {
1599
+ switch (value.tag) {
1600
+ case FresshEvent_Tags.ConnectProgress: {
1601
+ const inner = value.inner;
1602
+ let size = ordinalConverter.allocationSize(1);
1603
+ size += FfiConverterString.allocationSize(inner.connectionId);
1604
+ size += FfiConverterTypeSshConnectionProgressEvent.allocationSize(
1605
+ inner.event
1606
+ );
1607
+ return size;
1608
+ }
1609
+ case FresshEvent_Tags.HostKeyPending: {
1610
+ const inner = value.inner;
1611
+ let size = ordinalConverter.allocationSize(2);
1612
+ size += FfiConverterString.allocationSize(inner.connectionId);
1613
+ size += FfiConverterTypeServerPublicKeyInfo.allocationSize(
1614
+ inner.info
1615
+ );
1616
+ return size;
1617
+ }
1618
+ case FresshEvent_Tags.ConnectionClosed: {
1619
+ const inner = value.inner;
1620
+ let size = ordinalConverter.allocationSize(3);
1621
+ size += FfiConverterString.allocationSize(inner.connectionId);
1622
+ return size;
1623
+ }
1624
+ case FresshEvent_Tags.ShellClosed: {
1625
+ const inner = value.inner;
1626
+ let size = ordinalConverter.allocationSize(4);
1627
+ size += FfiConverterString.allocationSize(inner.shellId);
1628
+ return size;
1629
+ }
1630
+ case FresshEvent_Tags.WorkingDirectoryChanged: {
1631
+ const inner = value.inner;
1632
+ let size = ordinalConverter.allocationSize(5);
1633
+ size += FfiConverterString.allocationSize(inner.shellId);
1634
+ size += FfiConverterString.allocationSize(inner.path);
1635
+ return size;
1636
+ }
1637
+ case FresshEvent_Tags.PromptStart: {
1638
+ const inner = value.inner;
1639
+ let size = ordinalConverter.allocationSize(6);
1640
+ size += FfiConverterString.allocationSize(inner.shellId);
1641
+ return size;
1642
+ }
1643
+ case FresshEvent_Tags.CommandStart: {
1644
+ const inner = value.inner;
1645
+ let size = ordinalConverter.allocationSize(7);
1646
+ size += FfiConverterString.allocationSize(inner.shellId);
1647
+ return size;
1648
+ }
1649
+ case FresshEvent_Tags.CommandFinished: {
1650
+ const inner = value.inner;
1651
+ let size = ordinalConverter.allocationSize(8);
1652
+ size += FfiConverterString.allocationSize(inner.shellId);
1653
+ size += FfiConverterOptionalInt32.allocationSize(inner.exitCode);
1654
+ size += FfiConverterOptionalUInt64.allocationSize(inner.durationMs);
1655
+ return size;
1656
+ }
1657
+ case FresshEvent_Tags.CommandText: {
1658
+ const inner = value.inner;
1659
+ let size = ordinalConverter.allocationSize(9);
1660
+ size += FfiConverterString.allocationSize(inner.shellId);
1661
+ size += FfiConverterString.allocationSize(inner.command);
1662
+ return size;
1663
+ }
1664
+ default:
1665
+ throw new UniffiInternalError.UnexpectedEnumCase();
1666
+ }
1667
+ }
1668
+ }
1669
+ return new FFIConverter();
1670
+ })();
1671
+
1672
+ export enum KeyType {
1673
+ Rsa,
1674
+ Ecdsa,
1675
+ Ed25519,
1676
+ Ed448,
1677
+ }
1678
+
1679
+ const FfiConverterTypeKeyType = (() => {
1680
+ const ordinalConverter = FfiConverterInt32;
1681
+ type TypeName = KeyType;
1682
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1683
+ read(from: RustBuffer): TypeName {
1684
+ switch (ordinalConverter.read(from)) {
1685
+ case 1:
1686
+ return KeyType.Rsa;
1687
+ case 2:
1688
+ return KeyType.Ecdsa;
1689
+ case 3:
1690
+ return KeyType.Ed25519;
1691
+ case 4:
1692
+ return KeyType.Ed448;
1693
+ default:
1694
+ throw new UniffiInternalError.UnexpectedEnumCase();
1695
+ }
1696
+ }
1697
+ write(value: TypeName, into: RustBuffer): void {
1698
+ switch (value) {
1699
+ case KeyType.Rsa:
1700
+ return ordinalConverter.write(1, into);
1701
+ case KeyType.Ecdsa:
1702
+ return ordinalConverter.write(2, into);
1703
+ case KeyType.Ed25519:
1704
+ return ordinalConverter.write(3, into);
1705
+ case KeyType.Ed448:
1706
+ return ordinalConverter.write(4, into);
1707
+ }
1708
+ }
1709
+ allocationSize(value: TypeName): number {
1710
+ return ordinalConverter.allocationSize(0);
1711
+ }
1712
+ }
1713
+ return new FFIConverter();
1714
+ })();
1715
+
1716
+ /**
1717
+ * Which kind of selection a touch starts. Maps to `fressh_core::SelectionKind`.
1718
+ */
1719
+ export enum SelectionKind {
1720
+ Simple,
1721
+ Word,
1722
+ Line,
1723
+ }
1724
+
1725
+ const FfiConverterTypeSelectionKind = (() => {
1726
+ const ordinalConverter = FfiConverterInt32;
1727
+ type TypeName = SelectionKind;
1728
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1729
+ read(from: RustBuffer): TypeName {
1730
+ switch (ordinalConverter.read(from)) {
1731
+ case 1:
1732
+ return SelectionKind.Simple;
1733
+ case 2:
1734
+ return SelectionKind.Word;
1735
+ case 3:
1736
+ return SelectionKind.Line;
1737
+ default:
1738
+ throw new UniffiInternalError.UnexpectedEnumCase();
1739
+ }
1740
+ }
1741
+ write(value: TypeName, into: RustBuffer): void {
1742
+ switch (value) {
1743
+ case SelectionKind.Simple:
1744
+ return ordinalConverter.write(1, into);
1745
+ case SelectionKind.Word:
1746
+ return ordinalConverter.write(2, into);
1747
+ case SelectionKind.Line:
1748
+ return ordinalConverter.write(3, into);
1749
+ }
1750
+ }
1751
+ allocationSize(value: TypeName): number {
1752
+ return ordinalConverter.allocationSize(0);
1753
+ }
1754
+ }
1755
+ return new FFIConverter();
1756
+ })();
1757
+
1758
+ // Error type: SshError
1759
+ export enum SshError_Tags {
1760
+ Disconnected = "Disconnected",
1761
+ UnsupportedKeyType = "UnsupportedKeyType",
1762
+ Auth = "Auth",
1763
+ ShellAlreadyRunning = "ShellAlreadyRunning",
1764
+ HostKeyRejected = "HostKeyRejected",
1765
+ NotFound = "NotFound",
1766
+ Ssh = "Ssh",
1767
+ Keys = "Keys",
1768
+ }
1769
+ export const SshError = (() => {
1770
+ type Disconnected__interface = {
1771
+ tag: SshError_Tags.Disconnected;
1772
+ };
1773
+ class Disconnected_ extends UniffiError implements Disconnected__interface {
1774
+ /**
1775
+ * @private
1776
+ * This field is private and should not be used, use `tag` instead.
1777
+ */
1778
+ readonly [uniffiTypeNameSymbol] = "SshError";
1779
+ readonly tag = SshError_Tags.Disconnected;
1780
+ constructor() {
1781
+ super("SshError", "Disconnected");
1782
+ }
1783
+
1784
+ static new(): Disconnected_ {
1785
+ return new Disconnected_();
1786
+ }
1787
+
1788
+ static instanceOf(obj: any): obj is Disconnected_ {
1789
+ return obj.tag === SshError_Tags.Disconnected;
1790
+ }
1791
+ static hasInner(obj: any): obj is Disconnected_ {
1792
+ return false;
1793
+ }
1794
+ }
1795
+
1796
+ type UnsupportedKeyType__interface = {
1797
+ tag: SshError_Tags.UnsupportedKeyType;
1798
+ };
1799
+ class UnsupportedKeyType_
1800
+ extends UniffiError
1801
+ implements UnsupportedKeyType__interface
1802
+ {
1803
+ /**
1804
+ * @private
1805
+ * This field is private and should not be used, use `tag` instead.
1806
+ */
1807
+ readonly [uniffiTypeNameSymbol] = "SshError";
1808
+ readonly tag = SshError_Tags.UnsupportedKeyType;
1809
+ constructor() {
1810
+ super("SshError", "UnsupportedKeyType");
1811
+ }
1812
+
1813
+ static new(): UnsupportedKeyType_ {
1814
+ return new UnsupportedKeyType_();
1815
+ }
1816
+
1817
+ static instanceOf(obj: any): obj is UnsupportedKeyType_ {
1818
+ return obj.tag === SshError_Tags.UnsupportedKeyType;
1819
+ }
1820
+ static hasInner(obj: any): obj is UnsupportedKeyType_ {
1821
+ return false;
1822
+ }
1823
+ }
1824
+
1825
+ type Auth__interface = {
1826
+ tag: SshError_Tags.Auth;
1827
+ inner: Readonly<[string]>;
1828
+ };
1829
+ class Auth_ extends UniffiError implements Auth__interface {
1830
+ /**
1831
+ * @private
1832
+ * This field is private and should not be used, use `tag` instead.
1833
+ */
1834
+ readonly [uniffiTypeNameSymbol] = "SshError";
1835
+ readonly tag = SshError_Tags.Auth;
1836
+ readonly inner: Readonly<[string]>;
1837
+ constructor(v0: string) {
1838
+ super("SshError", "Auth");
1839
+
1840
+ this.inner = Object.freeze([v0]);
1841
+ }
1842
+ static new(v0: string): Auth_ {
1843
+ return new Auth_(v0);
1844
+ }
1845
+
1846
+ static instanceOf(obj: any): obj is Auth_ {
1847
+ return obj.tag === SshError_Tags.Auth;
1848
+ }
1849
+ static hasInner(obj: any): obj is Auth_ {
1850
+ return Auth_.instanceOf(obj);
1851
+ }
1852
+
1853
+ static getInner(obj: Auth_): Readonly<[string]> {
1854
+ return obj.inner;
1855
+ }
1856
+ }
1857
+
1858
+ type ShellAlreadyRunning__interface = {
1859
+ tag: SshError_Tags.ShellAlreadyRunning;
1860
+ };
1861
+ class ShellAlreadyRunning_
1862
+ extends UniffiError
1863
+ implements ShellAlreadyRunning__interface
1864
+ {
1865
+ /**
1866
+ * @private
1867
+ * This field is private and should not be used, use `tag` instead.
1868
+ */
1869
+ readonly [uniffiTypeNameSymbol] = "SshError";
1870
+ readonly tag = SshError_Tags.ShellAlreadyRunning;
1871
+ constructor() {
1872
+ super("SshError", "ShellAlreadyRunning");
1873
+ }
1874
+
1875
+ static new(): ShellAlreadyRunning_ {
1876
+ return new ShellAlreadyRunning_();
1877
+ }
1878
+
1879
+ static instanceOf(obj: any): obj is ShellAlreadyRunning_ {
1880
+ return obj.tag === SshError_Tags.ShellAlreadyRunning;
1881
+ }
1882
+ static hasInner(obj: any): obj is ShellAlreadyRunning_ {
1883
+ return false;
1884
+ }
1885
+ }
1886
+
1887
+ type HostKeyRejected__interface = {
1888
+ tag: SshError_Tags.HostKeyRejected;
1889
+ };
1890
+ class HostKeyRejected_
1891
+ extends UniffiError
1892
+ implements HostKeyRejected__interface
1893
+ {
1894
+ /**
1895
+ * @private
1896
+ * This field is private and should not be used, use `tag` instead.
1897
+ */
1898
+ readonly [uniffiTypeNameSymbol] = "SshError";
1899
+ readonly tag = SshError_Tags.HostKeyRejected;
1900
+ constructor() {
1901
+ super("SshError", "HostKeyRejected");
1902
+ }
1903
+
1904
+ static new(): HostKeyRejected_ {
1905
+ return new HostKeyRejected_();
1906
+ }
1907
+
1908
+ static instanceOf(obj: any): obj is HostKeyRejected_ {
1909
+ return obj.tag === SshError_Tags.HostKeyRejected;
1910
+ }
1911
+ static hasInner(obj: any): obj is HostKeyRejected_ {
1912
+ return false;
1913
+ }
1914
+ }
1915
+
1916
+ type NotFound__interface = {
1917
+ tag: SshError_Tags.NotFound;
1918
+ inner: Readonly<[string]>;
1919
+ };
1920
+ class NotFound_ extends UniffiError implements NotFound__interface {
1921
+ /**
1922
+ * @private
1923
+ * This field is private and should not be used, use `tag` instead.
1924
+ */
1925
+ readonly [uniffiTypeNameSymbol] = "SshError";
1926
+ readonly tag = SshError_Tags.NotFound;
1927
+ readonly inner: Readonly<[string]>;
1928
+ constructor(v0: string) {
1929
+ super("SshError", "NotFound");
1930
+
1931
+ this.inner = Object.freeze([v0]);
1932
+ }
1933
+ static new(v0: string): NotFound_ {
1934
+ return new NotFound_(v0);
1935
+ }
1936
+
1937
+ static instanceOf(obj: any): obj is NotFound_ {
1938
+ return obj.tag === SshError_Tags.NotFound;
1939
+ }
1940
+ static hasInner(obj: any): obj is NotFound_ {
1941
+ return NotFound_.instanceOf(obj);
1942
+ }
1943
+
1944
+ static getInner(obj: NotFound_): Readonly<[string]> {
1945
+ return obj.inner;
1946
+ }
1947
+ }
1948
+
1949
+ type Ssh__interface = {
1950
+ tag: SshError_Tags.Ssh;
1951
+ inner: Readonly<[string]>;
1952
+ };
1953
+ class Ssh_ extends UniffiError implements Ssh__interface {
1954
+ /**
1955
+ * @private
1956
+ * This field is private and should not be used, use `tag` instead.
1957
+ */
1958
+ readonly [uniffiTypeNameSymbol] = "SshError";
1959
+ readonly tag = SshError_Tags.Ssh;
1960
+ readonly inner: Readonly<[string]>;
1961
+ constructor(v0: string) {
1962
+ super("SshError", "Ssh");
1963
+
1964
+ this.inner = Object.freeze([v0]);
1965
+ }
1966
+ static new(v0: string): Ssh_ {
1967
+ return new Ssh_(v0);
1968
+ }
1969
+
1970
+ static instanceOf(obj: any): obj is Ssh_ {
1971
+ return obj.tag === SshError_Tags.Ssh;
1972
+ }
1973
+ static hasInner(obj: any): obj is Ssh_ {
1974
+ return Ssh_.instanceOf(obj);
1975
+ }
1976
+
1977
+ static getInner(obj: Ssh_): Readonly<[string]> {
1978
+ return obj.inner;
1979
+ }
1980
+ }
1981
+
1982
+ type Keys__interface = {
1983
+ tag: SshError_Tags.Keys;
1984
+ inner: Readonly<[string]>;
1985
+ };
1986
+ class Keys_ extends UniffiError implements Keys__interface {
1987
+ /**
1988
+ * @private
1989
+ * This field is private and should not be used, use `tag` instead.
1990
+ */
1991
+ readonly [uniffiTypeNameSymbol] = "SshError";
1992
+ readonly tag = SshError_Tags.Keys;
1993
+ readonly inner: Readonly<[string]>;
1994
+ constructor(v0: string) {
1995
+ super("SshError", "Keys");
1996
+
1997
+ this.inner = Object.freeze([v0]);
1998
+ }
1999
+ static new(v0: string): Keys_ {
2000
+ return new Keys_(v0);
2001
+ }
2002
+
2003
+ static instanceOf(obj: any): obj is Keys_ {
2004
+ return obj.tag === SshError_Tags.Keys;
2005
+ }
2006
+ static hasInner(obj: any): obj is Keys_ {
2007
+ return Keys_.instanceOf(obj);
2008
+ }
2009
+
2010
+ static getInner(obj: Keys_): Readonly<[string]> {
2011
+ return obj.inner;
2012
+ }
2013
+ }
2014
+
2015
+ function instanceOf(obj: any): obj is SshError {
2016
+ return obj[uniffiTypeNameSymbol] === "SshError";
2017
+ }
2018
+
2019
+ return Object.freeze({
2020
+ instanceOf,
2021
+ Disconnected: Disconnected_,
2022
+ UnsupportedKeyType: UnsupportedKeyType_,
2023
+ Auth: Auth_,
2024
+ ShellAlreadyRunning: ShellAlreadyRunning_,
2025
+ HostKeyRejected: HostKeyRejected_,
2026
+ NotFound: NotFound_,
2027
+ Ssh: Ssh_,
2028
+ Keys: Keys_,
2029
+ });
2030
+ })();
2031
+ export type SshError = InstanceType<
2032
+ (typeof SshError)[
2033
+ | "Disconnected"
2034
+ | "UnsupportedKeyType"
2035
+ | "Auth"
2036
+ | "ShellAlreadyRunning"
2037
+ | "HostKeyRejected"
2038
+ | "NotFound"
2039
+ | "Ssh"
2040
+ | "Keys"]
2041
+ >;
2042
+
2043
+ // FfiConverter for enum SshError
2044
+ const FfiConverterTypeSshError = (() => {
2045
+ const ordinalConverter = FfiConverterInt32;
2046
+ type TypeName = SshError;
2047
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
2048
+ read(from: RustBuffer): TypeName {
2049
+ switch (ordinalConverter.read(from)) {
2050
+ case 1:
2051
+ return new SshError.Disconnected();
2052
+ case 2:
2053
+ return new SshError.UnsupportedKeyType();
2054
+ case 3:
2055
+ return new SshError.Auth(FfiConverterString.read(from));
2056
+ case 4:
2057
+ return new SshError.ShellAlreadyRunning();
2058
+ case 5:
2059
+ return new SshError.HostKeyRejected();
2060
+ case 6:
2061
+ return new SshError.NotFound(FfiConverterString.read(from));
2062
+ case 7:
2063
+ return new SshError.Ssh(FfiConverterString.read(from));
2064
+ case 8:
2065
+ return new SshError.Keys(FfiConverterString.read(from));
2066
+ default:
2067
+ throw new UniffiInternalError.UnexpectedEnumCase();
2068
+ }
2069
+ }
2070
+ write(value: TypeName, into: RustBuffer): void {
2071
+ switch (value.tag) {
2072
+ case SshError_Tags.Disconnected: {
2073
+ ordinalConverter.write(1, into);
2074
+ return;
2075
+ }
2076
+ case SshError_Tags.UnsupportedKeyType: {
2077
+ ordinalConverter.write(2, into);
2078
+ return;
2079
+ }
2080
+ case SshError_Tags.Auth: {
2081
+ ordinalConverter.write(3, into);
2082
+ const inner = value.inner;
2083
+ FfiConverterString.write(inner[0], into);
2084
+ return;
2085
+ }
2086
+ case SshError_Tags.ShellAlreadyRunning: {
2087
+ ordinalConverter.write(4, into);
2088
+ return;
2089
+ }
2090
+ case SshError_Tags.HostKeyRejected: {
2091
+ ordinalConverter.write(5, into);
2092
+ return;
2093
+ }
2094
+ case SshError_Tags.NotFound: {
2095
+ ordinalConverter.write(6, into);
2096
+ const inner = value.inner;
2097
+ FfiConverterString.write(inner[0], into);
2098
+ return;
2099
+ }
2100
+ case SshError_Tags.Ssh: {
2101
+ ordinalConverter.write(7, into);
2102
+ const inner = value.inner;
2103
+ FfiConverterString.write(inner[0], into);
2104
+ return;
2105
+ }
2106
+ case SshError_Tags.Keys: {
2107
+ ordinalConverter.write(8, into);
2108
+ const inner = value.inner;
2109
+ FfiConverterString.write(inner[0], into);
2110
+ return;
2111
+ }
2112
+ default:
2113
+ // Throwing from here means that SshError_Tags hasn't matched an ordinal.
2114
+ throw new UniffiInternalError.UnexpectedEnumCase();
2115
+ }
2116
+ }
2117
+ allocationSize(value: TypeName): number {
2118
+ switch (value.tag) {
2119
+ case SshError_Tags.Disconnected: {
2120
+ return ordinalConverter.allocationSize(1);
2121
+ }
2122
+ case SshError_Tags.UnsupportedKeyType: {
2123
+ return ordinalConverter.allocationSize(2);
2124
+ }
2125
+ case SshError_Tags.Auth: {
2126
+ const inner = value.inner;
2127
+ let size = ordinalConverter.allocationSize(3);
2128
+ size += FfiConverterString.allocationSize(inner[0]);
2129
+ return size;
2130
+ }
2131
+ case SshError_Tags.ShellAlreadyRunning: {
2132
+ return ordinalConverter.allocationSize(4);
2133
+ }
2134
+ case SshError_Tags.HostKeyRejected: {
2135
+ return ordinalConverter.allocationSize(5);
2136
+ }
2137
+ case SshError_Tags.NotFound: {
2138
+ const inner = value.inner;
2139
+ let size = ordinalConverter.allocationSize(6);
2140
+ size += FfiConverterString.allocationSize(inner[0]);
2141
+ return size;
2142
+ }
2143
+ case SshError_Tags.Ssh: {
2144
+ const inner = value.inner;
2145
+ let size = ordinalConverter.allocationSize(7);
2146
+ size += FfiConverterString.allocationSize(inner[0]);
2147
+ return size;
2148
+ }
2149
+ case SshError_Tags.Keys: {
2150
+ const inner = value.inner;
2151
+ let size = ordinalConverter.allocationSize(8);
2152
+ size += FfiConverterString.allocationSize(inner[0]);
2153
+ return size;
2154
+ }
2155
+ default:
2156
+ throw new UniffiInternalError.UnexpectedEnumCase();
2157
+ }
2158
+ }
2159
+ }
2160
+ return new FFIConverter();
2161
+ })();
2162
+
2163
+ /**
2164
+ * JS implements this to receive the low-frequency event stream (§10 event plane).
2165
+ */
2166
+ export interface FresshEventListener {
2167
+ onEvent(event: FresshEvent): void;
2168
+ }
2169
+
2170
+ /**
2171
+ * JS implements this to receive the low-frequency event stream (§10 event plane).
2172
+ */
2173
+ export class FresshEventListenerImpl
2174
+ extends UniffiAbstractObject
2175
+ implements FresshEventListener
2176
+ {
2177
+ readonly [uniffiTypeNameSymbol] = "FresshEventListenerImpl";
2178
+ readonly [destructorGuardSymbol]: UniffiGcObject;
2179
+ readonly [pointerLiteralSymbol]: UniffiHandle;
2180
+ // No primary constructor declared for this class.
2181
+ private constructor(pointer: UniffiHandle) {
2182
+ super();
2183
+ this[pointerLiteralSymbol] = pointer;
2184
+ this[destructorGuardSymbol] =
2185
+ uniffiTypeFresshEventListenerImplObjectFactory.bless(pointer);
2186
+ }
2187
+
2188
+ onEvent(event: FresshEvent): void {
2189
+ uniffiCaller.rustCall(
2190
+ /*caller:*/ (callStatus) => {
2191
+ nativeModule().ubrn_uniffi_shim_uniffi_fn_method_fressheventlistener_on_event(
2192
+ uniffiTypeFresshEventListenerImplObjectFactory.clonePointer(this),
2193
+ FfiConverterTypeFresshEvent.lower(
2194
+ event,
2195
+ nativeModule().rustbuffer_alloc
2196
+ ),
2197
+ callStatus
2198
+ );
2199
+ },
2200
+ /*liftString:*/ FfiConverterString.lift.bind(FfiConverterString)
2201
+ );
2202
+ }
2203
+
2204
+ uniffiDestroy(): void {
2205
+ const ptr = (this as any)[destructorGuardSymbol];
2206
+ if (ptr !== undefined) {
2207
+ const pointer =
2208
+ uniffiTypeFresshEventListenerImplObjectFactory.pointer(this);
2209
+ uniffiTypeFresshEventListenerImplObjectFactory.freePointer(pointer);
2210
+ uniffiTypeFresshEventListenerImplObjectFactory.unbless(ptr);
2211
+ delete (this as any)[destructorGuardSymbol];
2212
+ }
2213
+ }
2214
+
2215
+ static instanceOf(obj_: any): obj_ is FresshEventListenerImpl {
2216
+ return uniffiTypeFresshEventListenerImplObjectFactory.isConcreteType(obj_);
2217
+ }
2218
+ }
2219
+
2220
+ const uniffiTypeFresshEventListenerImplObjectFactory: UniffiObjectFactory<FresshEventListener> =
2221
+ (() => {
2222
+ return {
2223
+ create(pointer: UniffiHandle): FresshEventListener {
2224
+ const instance = Object.create(FresshEventListenerImpl.prototype);
2225
+ instance[pointerLiteralSymbol] = pointer;
2226
+ instance[destructorGuardSymbol] = this.bless(pointer);
2227
+ instance[uniffiTypeNameSymbol] = "FresshEventListenerImpl";
2228
+ return instance;
2229
+ },
2230
+
2231
+ bless(p: UniffiHandle): UniffiGcObject {
2232
+ return uniffiCaller.rustCall(
2233
+ /*caller:*/ (status) =>
2234
+ nativeModule().ubrn_uniffi_internal_fn_method_fressheventlistener_ffi__bless_pointer(
2235
+ p,
2236
+ status
2237
+ ),
2238
+ /*liftString:*/ FfiConverterString.lift
2239
+ );
2240
+ },
2241
+
2242
+ unbless(ptr_: UniffiGcObject) {
2243
+ ptr_.markDestroyed();
2244
+ },
2245
+
2246
+ pointer(obj_: FresshEventListener): UniffiHandle {
2247
+ if ((obj_ as any)[destructorGuardSymbol] === undefined) {
2248
+ throw new UniffiInternalError.UnexpectedNullPointer();
2249
+ }
2250
+ return (obj_ as any)[pointerLiteralSymbol];
2251
+ },
2252
+
2253
+ clonePointer(obj_: FresshEventListener): UniffiHandle {
2254
+ const pointer = this.pointer(obj_);
2255
+ return uniffiCaller.rustCall(
2256
+ /*caller:*/ (callStatus) =>
2257
+ nativeModule().ubrn_uniffi_shim_uniffi_fn_clone_fressheventlistener(
2258
+ pointer,
2259
+ callStatus
2260
+ ),
2261
+ /*liftString:*/ FfiConverterString.lift
2262
+ );
2263
+ },
2264
+
2265
+ freePointer(pointer: UniffiHandle): void {
2266
+ uniffiCaller.rustCall(
2267
+ /*caller:*/ (callStatus) =>
2268
+ nativeModule().ubrn_uniffi_shim_uniffi_fn_free_fressheventlistener(
2269
+ pointer,
2270
+ callStatus
2271
+ ),
2272
+ /*liftString:*/ FfiConverterString.lift
2273
+ );
2274
+ },
2275
+
2276
+ isConcreteType(obj_: any): obj_ is FresshEventListener {
2277
+ return (
2278
+ obj_[destructorGuardSymbol] &&
2279
+ obj_[uniffiTypeNameSymbol] === "FresshEventListenerImpl"
2280
+ );
2281
+ },
2282
+ };
2283
+ })();
2284
+ const FfiConverterTypeFresshEventListener = new FfiConverterObjectWithCallbacks(
2285
+ uniffiTypeFresshEventListenerImplObjectFactory
2286
+ );
2287
+
2288
+ // Add a vtable for the callbacks that go in FresshEventListener.
2289
+
2290
+ // Put the implementation in a struct so we don't pollute the top-level namespace
2291
+ const uniffiCallbackInterfaceFresshEventListener: {
2292
+ vtable: any;
2293
+ register: () => void;
2294
+ } = {
2295
+ // Create the VTable using a series of closures.
2296
+ // ts automatically converts these into C callback functions.
2297
+ vtable: {
2298
+ on_event: (uniffiHandle: bigint, event: Uint8Array) => {
2299
+ const uniffiMakeCall = (): void => {
2300
+ const jsCallback =
2301
+ FfiConverterTypeFresshEventListener.lift(uniffiHandle);
2302
+ return jsCallback.onEvent(FfiConverterTypeFresshEvent.lift(event));
2303
+ };
2304
+ const uniffiResult = UniffiResult.ready<void>();
2305
+ const uniffiHandleSuccess = (obj: any) => {};
2306
+ const uniffiHandleError = (code: number, errBuf: UniffiByteArray) => {
2307
+ UniffiResult.writeError(uniffiResult, code, errBuf);
2308
+ };
2309
+ uniffiTraitInterfaceCall(
2310
+ /*makeCall:*/ uniffiMakeCall,
2311
+ /*handleSuccess:*/ uniffiHandleSuccess,
2312
+ /*handleError:*/ uniffiHandleError,
2313
+ /*lowerString:*/ FfiConverterString.lower.bind(FfiConverterString),
2314
+ /*alloc:*/ nativeModule().rustbuffer_alloc
2315
+ );
2316
+ return uniffiResult;
2317
+ },
2318
+ uniffi_free: (uniffiHandle: UniffiHandle): void => {
2319
+ // this will throw a stale handle error if the handle isn't found.
2320
+ FfiConverterTypeFresshEventListener.drop(uniffiHandle);
2321
+ },
2322
+ uniffi_clone: (uniffiHandle: UniffiHandle): UniffiHandle => {
2323
+ return FfiConverterTypeFresshEventListener.clone(uniffiHandle);
2324
+ },
2325
+ },
2326
+ register: () => {
2327
+ nativeModule().ubrn_uniffi_shim_uniffi_fn_init_callback_vtable_fressheventlistener(
2328
+ uniffiCallbackInterfaceFresshEventListener.vtable
2329
+ );
2330
+ },
2331
+ };
2332
+
2333
+ // FfiConverter for number | undefined
2334
+ const FfiConverterOptionalInt32 = new FfiConverterOptional(FfiConverterInt32);
2335
+
2336
+ // FfiConverter for string | undefined
2337
+ const FfiConverterOptionalString = new FfiConverterOptional(FfiConverterString);
2338
+
2339
+ // FfiConverter for boolean | undefined
2340
+ const FfiConverterOptionalBoolean = new FfiConverterOptional(FfiConverterBool);
2341
+
2342
+ // FfiConverter for bigint | undefined
2343
+ const FfiConverterOptionalUInt64 = new FfiConverterOptional(FfiConverterUInt64);
2344
+
2345
+ /**
2346
+ * This should be called before anything else.
2347
+ *
2348
+ * It is likely that this is being done for you by the library's `index.ts`.
2349
+ *
2350
+ * It checks versions of uniffi between when the Rust scaffolding was generated
2351
+ * and when the bindings were generated.
2352
+ *
2353
+ * It also initializes the machinery to enable Rust to talk back to Javascript.
2354
+ */
2355
+ function uniffiEnsureInitialized() {
2356
+ // Get the bindings contract version from our ComponentInterface
2357
+ const bindingsContractVersion = 30;
2358
+ // Get the scaffolding contract version by calling the into the dylib
2359
+ const scaffoldingContractVersion =
2360
+ nativeModule().ubrn_ffi_shim_uniffi_uniffi_contract_version();
2361
+ if (bindingsContractVersion !== scaffoldingContractVersion) {
2362
+ throw new UniffiInternalError.ContractVersionMismatch(
2363
+ scaffoldingContractVersion,
2364
+ bindingsContractVersion
2365
+ );
2366
+ }
2367
+ if (
2368
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_close_preview() !==
2369
+ 6557
2370
+ ) {
2371
+ throw new UniffiInternalError.ApiChecksumMismatch(
2372
+ "uniffi_shim_uniffi_checksum_func_close_preview"
2373
+ );
2374
+ }
2375
+ if (
2376
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_close_shell() !== 65197
2377
+ ) {
2378
+ throw new UniffiInternalError.ApiChecksumMismatch(
2379
+ "uniffi_shim_uniffi_checksum_func_close_shell"
2380
+ );
2381
+ }
2382
+ if (
2383
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_connect() !== 61665
2384
+ ) {
2385
+ throw new UniffiInternalError.ApiChecksumMismatch(
2386
+ "uniffi_shim_uniffi_checksum_func_connect"
2387
+ );
2388
+ }
2389
+ if (
2390
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_create_preview() !==
2391
+ 11782
2392
+ ) {
2393
+ throw new UniffiInternalError.ApiChecksumMismatch(
2394
+ "uniffi_shim_uniffi_checksum_func_create_preview"
2395
+ );
2396
+ }
2397
+ if (
2398
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_disconnect() !== 57410
2399
+ ) {
2400
+ throw new UniffiInternalError.ApiChecksumMismatch(
2401
+ "uniffi_shim_uniffi_checksum_func_disconnect"
2402
+ );
2403
+ }
2404
+ if (
2405
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_generate_key_pair() !==
2406
+ 45777
2407
+ ) {
2408
+ throw new UniffiInternalError.ApiChecksumMismatch(
2409
+ "uniffi_shim_uniffi_checksum_func_generate_key_pair"
2410
+ );
2411
+ }
2412
+ if (nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_resize() !== 49250) {
2413
+ throw new UniffiInternalError.ApiChecksumMismatch(
2414
+ "uniffi_shim_uniffi_checksum_func_resize"
2415
+ );
2416
+ }
2417
+ if (
2418
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_respond_to_host_key() !==
2419
+ 36974
2420
+ ) {
2421
+ throw new UniffiInternalError.ApiChecksumMismatch(
2422
+ "uniffi_shim_uniffi_checksum_func_respond_to_host_key"
2423
+ );
2424
+ }
2425
+ if (
2426
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_run_command() !== 27618
2427
+ ) {
2428
+ throw new UniffiInternalError.ApiChecksumMismatch(
2429
+ "uniffi_shim_uniffi_checksum_func_run_command"
2430
+ );
2431
+ }
2432
+ if (nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_scroll() !== 59613) {
2433
+ throw new UniffiInternalError.ApiChecksumMismatch(
2434
+ "uniffi_shim_uniffi_checksum_func_scroll"
2435
+ );
2436
+ }
2437
+ if (
2438
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_selection_clear() !==
2439
+ 34920
2440
+ ) {
2441
+ throw new UniffiInternalError.ApiChecksumMismatch(
2442
+ "uniffi_shim_uniffi_checksum_func_selection_clear"
2443
+ );
2444
+ }
2445
+ if (
2446
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_selection_start() !==
2447
+ 35689
2448
+ ) {
2449
+ throw new UniffiInternalError.ApiChecksumMismatch(
2450
+ "uniffi_shim_uniffi_checksum_func_selection_start"
2451
+ );
2452
+ }
2453
+ if (
2454
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_selection_text() !==
2455
+ 36953
2456
+ ) {
2457
+ throw new UniffiInternalError.ApiChecksumMismatch(
2458
+ "uniffi_shim_uniffi_checksum_func_selection_text"
2459
+ );
2460
+ }
2461
+ if (
2462
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_selection_update() !==
2463
+ 35856
2464
+ ) {
2465
+ throw new UniffiInternalError.ApiChecksumMismatch(
2466
+ "uniffi_shim_uniffi_checksum_func_selection_update"
2467
+ );
2468
+ }
2469
+ if (
2470
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_send_data() !== 45530
2471
+ ) {
2472
+ throw new UniffiInternalError.ApiChecksumMismatch(
2473
+ "uniffi_shim_uniffi_checksum_func_send_data"
2474
+ );
2475
+ }
2476
+ if (
2477
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_set_event_listener() !==
2478
+ 9714
2479
+ ) {
2480
+ throw new UniffiInternalError.ApiChecksumMismatch(
2481
+ "uniffi_shim_uniffi_checksum_func_set_event_listener"
2482
+ );
2483
+ }
2484
+ if (
2485
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_start_shell() !== 23755
2486
+ ) {
2487
+ throw new UniffiInternalError.ApiChecksumMismatch(
2488
+ "uniffi_shim_uniffi_checksum_func_start_shell"
2489
+ );
2490
+ }
2491
+ if (
2492
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_func_validate_private_key() !==
2493
+ 19734
2494
+ ) {
2495
+ throw new UniffiInternalError.ApiChecksumMismatch(
2496
+ "uniffi_shim_uniffi_checksum_func_validate_private_key"
2497
+ );
2498
+ }
2499
+ if (
2500
+ nativeModule().ubrn_uniffi_shim_uniffi_checksum_method_fressheventlistener_on_event() !==
2501
+ 36275
2502
+ ) {
2503
+ throw new UniffiInternalError.ApiChecksumMismatch(
2504
+ "uniffi_shim_uniffi_checksum_method_fressheventlistener_on_event"
2505
+ );
2506
+ }
2507
+
2508
+ uniffiCallbackInterfaceFresshEventListener.register();
2509
+ }
2510
+
2511
+ export default Object.freeze({
2512
+ initialize: uniffiEnsureInitialized,
2513
+ converters: {
2514
+ FfiConverterTypeCommandResult,
2515
+ FfiConverterTypeConnectionDetails,
2516
+ FfiConverterTypeFresshEvent,
2517
+ FfiConverterTypeFresshEventListener,
2518
+ FfiConverterTypeKeyType,
2519
+ FfiConverterTypeSecurity,
2520
+ FfiConverterTypeSelectionKind,
2521
+ FfiConverterTypeServerPublicKeyInfo,
2522
+ FfiConverterTypeShellOptions,
2523
+ FfiConverterTypeSshConnectionProgressEvent,
2524
+ FfiConverterTypeSshError,
2525
+ FfiConverterTypeTerminalType,
2526
+ },
2527
+ });