fission-suite/webnative-elm/2.0.0

NOTE: the latest version is 7.0.0

Renamed to fission-codes/webnative-elm. It is published under that name, and new versions come out there.

Versions published as fission-suite/webnative-elm still install under that name. 9 versions of 9 come from the new location (see their notes).

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/fission-codes/webnative-elm.

What we checked: The repo moved to github.com/fission-codes/webnative-elm. Rebuilt with git archive from commit f976b1bd3885 of https://github.com/fission-codes/webnative-elm (zip prefix fission-suite-webnative-elm-f976b1b/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 2f4849b895abd1172d8e5e17d198971860608368.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/fission-suite/webnative-elm/zipball/2.0.0/

Webnative

Generic types across all ports, and general webnative functions.

🚀

init : Permissions -> Request

Check if we're authenticated, process any lobby query-parameters present in the URL, and initiate the user's filesystem if authenticated (can be disabled using initWithOptions).

See loadFileSystem if you want to load the user's filesystem yourself. NOTE: Only works on the main/ui thread, as it uses window.location.

type alias InitOptions =
{ autoRemoveUrlParams : Bool
, loadFilesystem : Bool
}

Options for initWithOptions.

initWithOptions : InitOptions -> Permissions -> Request

Initialise webnative, with options.

initialise : Permissions -> Request

Alias for init.

initialize : Permissions -> Request

Alias for init.

Authentication

Are we authenticated?

type State
= NotAuthorised
| AuthSucceeded AuthSucceededState
| AuthCancelled AuthCancelledState
| Continuation ContinuationState

Initialisation state, result from init.

type alias AuthSucceededState =
{ newUser : Bool
, throughLobby : Bool
, username : String
}

State attributes when auth has succeeded.

type alias AuthCancelledState =
{ cancellationReason : String
, throughLobby : Bool
}

State attributes when auth was cancelled.

type alias ContinuationState =
{ newUser : Bool
, throughLobby : Bool
, username : String
}

State attributes when continueing a session.

Authorisation

redirectToLobby : RedirectTo -> Permissions -> Request

Redirect to the authorisation lobby.

= CurrentUrl
| RedirectTo Url

Where the authorisation lobby should redirect to after authorisation.

type alias AppPermissions =
{ creator : String
, name : String
}

Application permissions.

{ privatePaths : List String
, publicPaths : List String
}

Filesystem permissions.

type alias Permissions =
{ app : Maybe AppPermissions
, fs : Maybe FileSystemPermissions
}

Permissions to ask the user.

Ports

Data passing through the ports.

(String -> Result String tag)
-> Response
-> Result
( Maybe Context, String )
( Context, Maybe tag, Artifact )

Function to be used to decode the response from webnative we got through our port.

GotWebnativeResponse response ->
    case Webnative.decodeResponse tagFromString response of
        Ok ( Webnative, Initialise, Initialisation state ) ->
            if Webnative.isAuthenticated state then
                loadUserData
            else
                welcome


        Ok ( Wnfs, ReadHelloTxt, Wnfs.Utf8Content helloContents ) ->
            -- Do something with content from hello.txt


        Ok ( Wnfs, Mutation, _ ) ->
            ( model
            , Ports.wnfsRequest Wnfs.publish
            )


        Err ( maybeContext, errString ) ->
            -- Decoding, or tag parse, error.

See the README for the full example.

= NoArtifact
| Initialisation State
| Boolean Bool
| CID String
| DirectoryContent (List Entry)
| FileContent Bytes
| Utf8Content String

Artifact we receive in the response.

type alias Request =
{ context : String
, tag : String
, method : String
, arguments : List Value
}

Request from webnative.

type alias Response =
{ context : String
, error : Maybe String
, tag : String
, method : String
, data : Value
}

Response from webnative.

Filesystem

loadFilesystem : Permissions -> Request

Load in the filesystem manually.

Miscellaneous

Cast a Context to a String.

contextFromString : String -> Maybe Context

Derive a Context from a String.

type Context
= Webnative
| Wnfs

Request, or response, context.