src/happyx_native/app/app

App

Provides main app loop

Vars

websocketClient: WebSocket

Procs

proc cfgAndroidPackageId(): string {.compileTime, ...raises: [], tags: [],
                                     forbids: [].}
proc cfgAndroidSdk(): string {.compileTime, ...raises: [], tags: [], forbids: [].}
proc cfgAppDirectory(): string {.compileTime, ...raises: [], tags: [], forbids: [].}
proc cfgKind(): string {.compileTime, ...raises: [], tags: [], forbids: [].}
proc cfgName(): string {.compileTime, ...raises: [], tags: [], forbids: [].}
proc cfgPort(): int {.compileTime, ...raises: [], tags: [], forbids: [].}
proc createHpxWebview(w, h: int; port: int; resizeable: bool) {....raises: [],
    tags: [], forbids: [].}

Macros

macro callback(body: untyped)
Creates callbacks for JS side

Example

import happyx_native


callback:
  proc test(x: int) =
    callJs("test", x * x)

nativeApp("/assets")

macro callJs(funcName: string; params: varargs[untyped])
macro callJsAsync(funcName: string; params: varargs[untyped])
macro fetchFiles(directory: static[string]): untyped
macro getIndexHtml(directory: static[string]): untyped
macro onExit(body: untyped)

Templates

template nativeApp(appDirectory: string = "/assets"; port: int = 5123;
                   x: int = 512; y: int = 128; w: int = 720; h: int = 320;
                   appMode: bool = true; title: string = "";
                   resizeable: bool = true; establish: bool = true) {.dirty.}
template nativeAppImpl(appDirectory: string = "/assets"; port: int = 5123;
                       x: int = 512; y: int = 128; w: int = 720; h: int = 320;
                       appMode: bool = true; title: string = "";
                       resizeable: bool = true; establish: bool = true) {.dirty.}

Compiles main happyx file, opens browser in appMode and starts serving at localhost with port

Your project should have this structure:

assets/
├─ index.html
├─ main.nim
app.nim