thunder-webview
TypeScript icon, indicating that this package has built-in type declarations

1.10.1 • Public • Published

This is a small library to normalize webview messaging with different browser engines. This is not fully tested with every browser engine at this point.

This project is part of the Thunder.WebView project which is C# library for writing a multi-platform webview in a more native manner without requiring node (aka Electron).

To use, in a hosted webview, you can either add the browser script manually:

//include script
<scripts src="/dist/thunder.webview.browser.js" />

//create request object
var request = {
    RequestId: "requestId",
    Message: {} // object to be parsed as the message handler args
};

//using callbacks
_webview.sendRequest(request, function(response)
    {
        //do something with response
    });

//or using async/await
var response = await _webview.sendRequestAsync(request)

If you don't want the global scope _webview (e.g. want to reference the module), you can reference WebViewMessenger directly instead:

//import 
import {WebViewMessenger} from "thunder-webview/lib/webViewMessenger"

var messenger = new WebViewMessenger();

//using callbacks
messenger.sendRequest(request, function(response)
{
    //do something with response
});

//or using async/await
var response = await messenger.sendRequestAsync(request)

Package Sidebar

Install

npm i thunder-webview

Weekly Downloads

2

Version

1.10.1

License

AGPL-3.0-only

Unpacked Size

27 kB

Total Files

31

Last publish

Collaborators

  • thundersizzle