Closed waterbang closed 2 years ago
赋能给 ts/js 的一个 runtime
对标 nodejs( tcp/udp)/deno(http1/2) appliction
操作系统级别 D:/ /user/root
底层网络是 bnrtc(golang=webrtc+udp)->websocket->js-controller
文件系统:(未定)/sys/ /user/address
GUI/TUI: (Webview=>http/https) => DWebview
nodejs
import { http } from "http"; http.createServer(staticDir("./www")).listen(8080); import { Webview } from "@microsoft/webview2"; new Webview("http://localhost:8080");
v8 nodejs deno https://deno.land/x@0.0.1
bfs
import { bnrtc } from "node:bnrtc"; import { DWebServer } from "@bnrtc/dweb"; const dwebserver = new DWebServer({ publicKey, privateKey }).listen("dport"); import { Webview } from "@microsoft/webview2"; import { Webview } from "@android/webiew"; new Webview(dwebserver.resolveUrl()); // http://haahshsahashshshahssa.localhost:128920/ class AppRuntime { constructor(app_root: string) { const worker = new Worker(""); worker.module_loader = { linker(spe) { if (spe === "node:bnrtc") { return new ScriptModule(code, "node:bnrtc"); } if (spe.startsWith("./")) { return new FileModule(new URL(spe, app_root)); } if (spe === "dwebview") { return DWebviewModule; } }, }; worker.injectFFI({ op_fs_read: (path) => { fs.read(new URL(path, app_root)); }, }); } } const app = new AppRuntime(); app.import("./myapp.js");
bfs-gui-application bfs-cmd-application
app_manifest.json index.bfs.js // 主程序入口 assets index.html main.js
import { DWebview } from "@bfs/dwebview"; import { writePicture, openUserPictureLib } from "@bfs/media"; const dwebview = new DWebview(); dwebview.url = new URL("./assets/index.html", import.meta.url); dwebview.statubar.bgcolor = 'transparent' dwebview.statubar.ftcolor = 'dark' dwebview.on("request",(req,res)=>{ if(req.url==='/statubar/bgcolor/set'){ dwebview.statubar.bgcolor = 'transparent' res.end('{success:true}') } if(req.url==='/picture/pick'){ openUserPictureLib() res.end('{success:true}') } if(req.url === 'index.html'){ res.wirte(render(<a>)) } }); // 区块链地址 address 就是域名 // // dweb:localhost.xx // url重定向 dweb:localhost.xx => http://localhost:98092 // https://app-id.dweb.bfchain.org/ 分享出去的 // https://app-id.bfchain.dweb/ 应用内部的 dwebview.acitive(); openBrl(other_app_id);
// android
java/kotlin -> webview -(java_interface)-> html/js obj-c/swift -> webview -(jsCore-api)-> html/js
deno <-(java_interface)-> java/kotlin -> webview -> html/js '----(http/ws-server)-------> html/js
[] statusbar
[] read/write picture
[] authority management
[] navigation
[] notification
[] Startup screen
[] Qr code scanning
shuibang.bfs-app.js
<script src="./shuibang-dweb-sdk.js"/> <script> await shuibangDwebSdk.setStatubarBgColor('transaparent') </script> <a href='./b.html' target="_blank"> <dweb-plugin> <dweb-statubar/> </dweb-plugin> <script> $("dweb-statubar").ready().then(apis=>{ apis. }) </script>
第一步deno <-(java_interface)-> java/kotlin 流程需要走通。
deno的runtime作为中间桥梁,提供代替cordova的方法(1.采用直接函数回调。2.采用事件注册。3.如果都不行使用ws)。
由deno去操控,kotlin启动webview(Dwebview)。
Plaoc(BFS)
赋能给 ts/js 的一个 runtime
对标 nodejs( tcp/udp)/deno(http1/2) appliction
操作系统级别 D:/ /user/root
底层网络是 bnrtc(golang=webrtc+udp)->websocket->js-controller
文件系统:(未定)/sys/ /user/address
GUI/TUI: (Webview=>http/https) => DWebview
nodejs
v8 nodejs deno https://deno.land/x@0.0.1
bfs
bfs-gui-application bfs-cmd-application
// android
java/kotlin -> webview -(java_interface)-> html/js obj-c/swift -> webview -(jsCore-api)-> html/js
deno <-(java_interface)-> java/kotlin -> webview -> html/js '----(http/ws-server)-------> html/js
开发第一里程碑目标
tudo
[] statusbar
[] read/write picture
[] authority management
[] navigation
[] notification
[] Startup screen
[] Qr code scanning
webcompont
shuibang.bfs-app.js