New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

iframe-ipc

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iframe-ipc

iframe ipc

  • 2.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by88.89%
Maintainers
0
Weekly downloads
 
Created
Source

iframe-ipc

NPM Version NPM Downloads NPM License

跨iframe通讯,对齐promise调用体验

Install

npm install iframe-ipc --save

Usage

支持promise编程

import { IframeIPC } from 'iframe-ipc';
const iframeIpc = new IframeIPC('namespace');

const serverApi = iframeIpc.defServerAPI('api123', async (args: number): Promise<string> => {
  return '' + args;
});

// top 外层 ifreame
iframeIpc.initFrameServer();

// client 内层 iframe
serverApi(1234).then((result) => console.log(result));

支持传递回调函数

import { IframeIPC } from 'iframe-ipc';
const iframeIpc = new IframeIPC('namespace');

const funcid = iframeIpc.defTempAPI((info, arg1) => {
  // info 中有onmessage的event对象
});
const serverApi2 = iframeIpc.defServerAPIExt('serverApi2', async function({ handlers }, arg11) {
  // hanlders 中有使用funcid解析后额函数
  const ret = await handlers[arg11.click_funcid](arg22);
  // ...
});
serverApi2({ funcids: [funcid] }, arg11);

Example

click

Keywords

FAQs

Package last updated on 10 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc