1-- | Run explicitly allowlisted executables beside the native application.
2-- | Register tauri-plugin-bundled-process and grant its command permissions only
3-- | to the webview that owns a process stream. `stdout` and `stderr` require
4-- | bundled-process:allow-stdout and bundled-process:allow-stderr respectively.
5module Tauri.Process (Result, Stream, run, spawn, write, finish, cancel, stdout, stderr) where
7import Data.ArrayBuffer.Types (ArrayBuffer)
11import Promise (Promise)
12import Promise.Aff (toAffE)
21-- | Send UTF-8 input, close stdin, and collect both output streams concurrently.
22-- | Nonzero child exits return a Result; host and spawn failures reject the Aff.
23-- | A code of -1 means termination without a numeric exit status. Output bytes
24-- | that are not valid UTF-8 are replaced with the Unicode replacement character.
25run :: { executable :: String, arguments :: Array String, stdin :: String } -> Aff Result
26run options = toAffE (runImpl options)
28-- | Start an allowlisted child with open stdin. The stream is usable only by the
29-- | webview that created it.
30spawn :: { executable :: String, arguments :: Array String } -> Aff Stream
31spawn options = toAffE (spawnImpl options)
33-- | Write one raw ArrayBuffer to child stdin. Awaiting this Aff acknowledges that
34-- | all bytes were accepted by the child pipe. At most one write may be in flight.
35-- | Requires the octet-stream IPC transport; JSON/postMessage fallback is rejected.
36write :: Stream -> ArrayBuffer -> Aff Unit
37write stream buffer = toAffE (writeImpl stream buffer)
39-- | Close stdin, wait for the child, and collect its output. Nonzero exits return
40-- | a Result; native failures reject the Aff.
41finish :: Stream -> Aff Result
42finish stream = toAffE (finishImpl stream)
44-- | Kill the child and reap it. This does not return the child's output.
45cancel :: Stream -> Aff Unit
46cancel stream = toAffE (cancelImpl stream)
48-- | Write UTF-8 text to the native application's standard output and flush it.
49-- | Native I/O failures reject the Aff.
50stdout :: String -> Aff Unit
51stdout text = toAffE (stdoutImpl text)
53-- | Write UTF-8 text to the native application's standard error and flush it.
54-- | Native I/O failures reject the Aff.
55stderr :: String -> Aff Unit
56stderr text = toAffE (stderrImpl text)
58-- | An opaque stream owned by the webview that spawned it.
59foreign import data Stream :: Type
61foreign import runImpl :: { executable :: String, arguments :: Array String, stdin :: String } -> Effect (Promise Result)
62foreign import spawnImpl :: { executable :: String, arguments :: Array String } -> Effect (Promise Stream)
63foreign import writeImpl :: Stream -> ArrayBuffer -> Effect (Promise Unit)
64foreign import finishImpl :: Stream -> Effect (Promise Result)
65foreign import cancelImpl :: Stream -> Effect (Promise Unit)
66foreign import stdoutImpl :: String -> Effect (Promise Unit)
67foreign import stderrImpl :: String -> Effect (Promise Unit)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list