Gathering detailed insights and metrics for @sap-devx/webview-rpc
Gathering detailed insights and metrics for @sap-devx/webview-rpc
Gathering detailed insights and metrics for @sap-devx/webview-rpc
Gathering detailed insights and metrics for @sap-devx/webview-rpc
npm install @sap-devx/webview-rpc
Typescript
Module System
Node Version
NPM Version
79
Supply Chain
99.5
Quality
81.3
Maintenance
100
Vulnerability
100
License
TypeScript (88.38%)
HTML (7.77%)
JavaScript (3.85%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
451,448
Last Day
259
Last Week
3,270
Last Month
13,780
Last Year
173,960
Apache-2.0 License
35 Stars
190 Commits
5 Forks
5 Watchers
8 Branches
608 Contributors
Updated on Jan 26, 2025
Latest Version
1.0.0
Package Id
@sap-devx/webview-rpc@1.0.0
Unpacked Size
42.60 kB
Size
10.73 kB
File Count
21
NPM Version
10.5.0
Node Version
18.20.2
Published on
Apr 21, 2024
Cumulative downloads
Total Downloads
Last Day
-8.5%
259
Compared to previous day
Last Week
-2.7%
3,270
Compared to previous week
Last Month
17.8%
13,780
Compared to previous month
Last Year
15.7%
173,960
Compared to previous year
Provides a conventient way to communicate between VSCode extension and its webviews. Use RPC calls to invoke functions on the webview, receive callbacks and vice versa.
You need to have node.js installed on your machine. Also, to use this library, you need to run it inside a VSCode extension using VSCode or Theia.
An example of using this libary can be seen under the "example" folder.
This will install the library in your node_modules folder. The extension library can be used as any node.js module (with TypeScript). The webview library needs to be imported to your html.1npm install @sap-devx/webview-rpc
1<head> 2 <script>var exports = {};</script> 3 <script type="module" src="vscode-resource:/node_modules/@sap-devx/webview-rpc/out.browser/rpc-common.js"></script> 4 <script type="module" src="vscode-resource:/node_modules/@sap-devx/webview-rpc/out.browser/rpc-browser.js"></script> 5 <script type="module" src="vscode-resource:/out/media/main.js"></script> 6</head>
Create new instance of the Rpc in the extension side and the Webview side
1this._rpc = new RpcExtension(this._panel.webview);
1const vscode = acquireVsCodeApi(); 2let rpc = new RpcBrowser(window, vscode);
In order to invoke an extension method from the webbiew or webview method from the extension, you will have to register the functions that can be invoked. Here is an example on how to register the methods
1function add(a,b) { 2 return a+b; 3} 4 5rpc.registerMethod({func: add});
To invoke a method use the invoke method on the rpc instance. You can pass a callback that will be invoked once the response received.
For version < 1.x :
1rpc.invoke("add", [1,2]).then((response)=>{ 2 console.log("1+2="+response); 3});
Since version 1.x :
1rpc.invoke("add", 1,2).then((response)=>{ 2 console.log("1+2="+response); 3});
To build for development purpose do the following:
1npm install @sap-devx/webview-rpc
1npm run compile-ext
1npm run compile-browser
1npm run test
Browser library is does not generate d.ts files.
overcome Cors issue preventing post message to get through and hit the window: use the setHost method and sent the host name from the webview - and then the message should get through.
Contributing information can be found in the CONTRIBUTING.md file.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 4/23 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
10 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More