diff --git a/src/Tauri/Dialog.js b/src/Tauri/Dialog.js new file mode 100644 index 0000000..4f3eb3b --- /dev/null +++ b/src/Tauri/Dialog.js @@ -0,0 +1 @@ +exports.dialog = require("tauri/api/dialog"); diff --git a/src/Tauri/Dialog.purs b/src/Tauri/Dialog.purs new file mode 100644 index 0000000..68f83a2 --- /dev/null +++ b/src/Tauri/Dialog.purs @@ -0,0 +1,21 @@ +module Tauri.Dialog + ( OpenDialogOptions + , open + ) where + +import Prelude + +import Control.Promise (Promise, toAffE) +import Effect.Aff (Aff) +import Effect.Uncurried (EffectFn1, runEffectFn1) + +type OpenDialogOptions = + { directory :: Boolean + } + +foreign import dialog :: + { open :: EffectFn1 OpenDialogOptions (Promise String) + } + +open :: OpenDialogOptions -> Aff String +open opts = toAffE $ runEffectFn1 dialog.open opts diff --git a/src/Tauri/FS.js b/src/Tauri/FS.js index b9d63dc..b8cb850 100644 --- a/src/Tauri/FS.js +++ b/src/Tauri/FS.js @@ -1 +1 @@ -exports.unsafeRequireFS = require("tauri/api/fs"); +exports.fs = require("tauri/api/fs"); diff --git a/src/Tauri/FS.purs b/src/Tauri/FS.purs index 44a47c2..6e126fb 100644 --- a/src/Tauri/FS.purs +++ b/src/Tauri/FS.purs @@ -76,15 +76,12 @@ type FileEntry = type FilePath = String -foreign import unsafeRequireFS :: forall r. Record r - -fs :: +foreign import fs :: { readTextFile :: EffectFn2 FilePath Json (Promise String) , writeFile :: EffectFn2 FsTextFileOption Json (Promise Unit) , readDir :: EffectFn2 FilePath Json (Promise Json) , createDir :: EffectFn2 FilePath Json (Promise Unit) } -fs = unsafeRequireFS readTextFile :: FilePath -> FsOptions -> Aff String readTextFile path opts = toAffE $ runEffectFn2 fs.readTextFile path (encodeJson opts)