Skip to content

cross platform framework using web technologies

Notifications You must be signed in to change notification settings

Promignis/knack

Repository files navigation

Knack

Knack is a framework to build cross platform applications using the web stack - HTML, CSS and Javascript. It is built using https://github.com/zserge/webview as the webview. The size is much smaller compared to electron.

It is under development.

go get github.com/promignis/knack

Current usage(it will change)

  html/svg  files in views  folder (will pick index.html by default)
  css       files in styles folder
  js        files in js     folder
  image     files in images folder

Inject

window.onRuntimeLoad = function() {
      _runtime.loadView("contacts.html") // replaces the current html with ./views/contacts.html

      _runtime.loadCss("filename.css") // injects from ./styles/filename.css

      _runtime.loadJs("bundle.js") // injects from ./js/bundle.js

      _runtime.loadImage("test.png", "test") // injects ./images/test.png to img tag with id "test"
}

Files

Open file and get data in callback(will open native file browser)

_runtime.openFile((fileData) => {
      // do something with file data
})

if callback not present returns Promise

_runtime.openFile().then(fileData => {

})

Save file with fileData

_runtime.saveFile(fileData)

Fuzzy match

Do fuzzy match over a any dictionary

// dict, word, levenshtein_distance, callback

_runtime.fuzzyMatch(["asd", "abc"], "ab", 1, (results) => {
  // returns array of results
  // in this case "abc" as 1 distance away from "ab"
})

if callback not present it returns Promise

_runtime.fuzzyMatch(["asd", "abc"], "ab", 1).then(results => {
      // output
})

Examples

Fuzzy search on files

_runtime.getFileWalker("../", (fileList) => {
  let fileDict = JSON.parse(fileList).map(file => file.name)
  _runtime.fuzzyMatch(fileDict, "main.g", 3, (fuzzyResults) => {
    
  })
})

if you have babel-async-await setup

_runtime.getFileWalker("../", async (fileList) => {
  let fileDict = JSON.parse(fileList).map(file => file.name)
  let fuzzyResults = await _runtime.fuzzyMatch(fileDict, "main.g", 3)
})

better use via Promises

getFileWalker is planned to return Promise in future

OSX

Build

./build-app.sh

Run

./run-app.sh

About

cross platform framework using web technologies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published