fairOS-dfs now Supports wasm
make build-all
This will create two binaries in dist
folder
20665380 fairos.wasm
5721514 fairos.wasm.gz // a gzip compressed wasm binary
<html>
<head>
/*
* Download https://github.com/fairDataSociety/fairOS-dfs-wasm/blob/main/example/wasm_exec.js in your project
* this is also availabe in your go root. `$(go env GOROOT)/misc/wasm/wasm_exec.js`
* load wasm_exec.js before loading wasm itself, this is required for wasm build with golang
*/
<script src="wasm_exec.js"></script>
// Load wasm
<script>
const go = new Go();
let mod, inst, sessionID;
WebAssembly.instantiateStreaming(fetch("fairos.wasm"), go.importObject).then(
result => {
mod = result.module;
inst = result.instance;
go.run(inst).then( r => {
console.log("exiting...")
})
}
);
</script>
</head>
...
</html>
<html>
<head>
/*
* Download https://github.com/fairDataSociety/fairOS-dfs-wasm/blob/main/example/wasm_exec.js in your project
* this is also availabe in your go root. `$(go env GOROOT)/misc/wasm/wasm_exec.js`
* load wasm_exec.js before loading wasm itself, this is required for wasm build with golang
*/
<script src="wasm_exec.js"></script>
// We can use pako to load compressed wasm
<script src="pako.min.js"></script>
// Load wasm
<script>
const go = new Go();
let mod, inst, sessionID;
const go = new Go();
let sessionID;
fetch("fairos.wasm.gz").then( r => {
r.arrayBuffer().then( async b => {
let buffer = pako.ungzip(b);
if (buffer[0] === 0x1f && buffer[1] === 0x8b) {
buffer = pako.ungzip(buffer);
}
const result = await WebAssembly.instantiate(buffer, go.importObject);
go.run(result.instance).then( r => {
console.log("exiting...")
})
})
})
</script>
</head>
...
</html>
let resp = await connect("BEE_API", "BATCH_ID", "IS_USING_BEE_GATEWAY_PROXY", "RPC_ENDPOINT", "NETWORK")
console.log(resp)
stop()
let resp = await login(USER, PASSWORD)
let r = JSON.parse(resp)
console.log(r.sessionId)
Note: fairOS-dfs maintains state for a logged-in user. we have to send sessionId
for user specific operations.
let resp = await userPresent(username)
console.log(resp)
let resp = await userIsLoggedIn(username)
console.log(resp)
let resp = await userLogout(sessionId)
console.log(resp)
let resp = await userDelete(sessionId)
console.log(resp)
let resp = await userStat(sessionId)
console.log(resp)
let resp = await podNew(sessionId, podName)
console.log(resp)
let resp = await podOpen(sessionId, podName)
console.log(resp)
let resp = await podClose(sessionId, podName)
console.log(resp)
let resp = await podSync(sessionId, podName)
console.log(resp)
let resp = await podDelete(sessionId, podName)
console.log(resp)
let resp = await podList(sessionId)
console.log(resp)
let resp = await podStat(sessionId, podName)
console.log(resp)
let resp = await podShare(sessionId, podName, shareAs)
console.log(resp)
let resp = await podReceive(sessionId, pod_sharing_reference)
console.log(resp)
let resp = await podReceiveInfo(sessionId, pod_sharing_reference)
console.log(resp)
let resp = await dirPresent(sessionId, podName, dirPath)
console.log(resp)
let resp = await dirMake(sessionId, podName, dirPath)
console.log(resp)
let resp = await dirRemove(sessionId, podName, dirPath)
console.log(resp)
let resp = await dirList(sessionId, podName, dirPath)
console.log(resp)
let resp = await dirStat(sessionId, podName, dirPath)
console.log(resp)
let resp = await fileDownload(sessionId, podName, filePath)
console.log(resp)
let resp = await fileUpload(sessionId, podName, dirPath, fileByteArray, fileName, size, blockSize, compression)
console.log(resp)
let resp = await fileShare(sessionId, podName, dirPath, destinationUser)
console.log(resp)
let resp = await fileReceive(sessionId, podName, directory, file_sharing_reference)
console.log(resp)
let resp = await fileReceiveInfo(sessionId, podName, file_sharing_reference)
console.log(resp)
let resp = await fileReceiveInfo(sessionId, podName, filePath)
console.log(resp)
let resp = await fileStat(sessionId, podName, filePath)
console.log(resp)
let resp = await kvNewStore(sessionId, podName, tableName, indexType)
console.log(resp)
Note: indexType is any of "string" or "number"
let resp = await kvList(sessionId, podName)
console.log(resp)
let resp = await kvOpen(sessionId, podName, tableName)
console.log(resp)
let resp = await kvDelete(sessionId, podName, tableName)
console.log(resp)
let resp = await kvCount(sessionId, podName, tableName)
console.log(resp)
let resp = await kvEntryPut(sessionId, podName, tableName, key, value)
console.log(resp)
let resp = await kvEntryGet(sessionId, podName, tableName, key)
console.log(resp)
let resp = await kvEntryDelete(sessionId, podName, tableName, key)
console.log(resp)
let resp = await kvLoadCSV(sessionId, podName, tableName, memory, file)
console.log(resp)
let resp = await kvSeek(sessionId, podName, tableName, start, end, limit)
let resp = await kvSeekNext(sessionId, podName, tableName)
console.log(resp)
let resp = await docNewStore(sessionId, podName, tableName, simpleIndexes, mutable)
console.log(resp)
Note: simpleIndexes is string_of_field=indexType pairs seperated with comma (first_name=string,age=number,tags=map)
let resp = await docList(sessionId, podName)
console.log(resp)
let resp = await docOpen(sessionId, podName, tableName)
console.log(resp)
let resp = await docCount(sessionId, podName, tableName, expression)
console.log(resp)
let resp = await docDelete(sessionId, podName, tableName)
console.log(resp)
let resp = await docFind(sessionId, podName, tableName, expression, limit)
console.log(resp)
let resp = await docEntryPut(sessionId, podName, tableName, value)
console.log(resp)
let resp = await docEntryGet(sessionId, podName, tableName, id)
console.log(resp)
let resp = await docEntryDelete(sessionId, podName, tableName, id)
console.log(resp)
let resp = await docLoadJson(sessionId, podName, tableName, file)
console.log(resp)
let resp = await docIndexJson(sessionId, podName, tableName, filePath)
console.log(resp)