@meteor-web3/meteor-iframe
TypeScript icon, indicating that this package has built-in type declarations

1.0.17 • Public • Published

meteor-iframe

Make dataverse-kernel running in iframe.

Installation

pnpm install @meteor-web3/meteor-iframe

Run demo

requirements

  • MetaMask - A cryptocurrency wallet browser extension.
  • Node.js version >= 16.
  • pnpm version >= 7.
pnpm install // install dependencies
pnpm build  // build the package
pnpm demo // run demo

the demo will be running on http://localhost:5173/.

Usage

Directly import in your project, and it will automatically inject the iframe with id meteor-iframe.

import "@meteor-web3/meteor-iframe";

To communicate with the kernel in iframe, you can use the Communicator.

import { Communicator } from "@meteor-web3/communicator";

const communicator = new Communicator({
  source: window,
  target: iframeWindow,
  runningEnv: "Client",
  // (required) only external-wallet is supported for now, so you need to handle the ethereumRequest method yourself.
  methodHandler: async (args) => {
    console.log("Client received method call:", args);
    if (args.method === "ethereumRequest") {
      const res = await window.ethereum.request(args.params);
      console.log("Client responded to ethereumRequest:", res);
      return res;
    }
  }
});

Readme

Keywords

none

Package Sidebar

Install

npm i @meteor-web3/meteor-iframe

Weekly Downloads

14

Version

1.0.17

License

none

Unpacked Size

7.54 MB

Total Files

31

Last publish

Collaborators

  • tagbug
  • ownershiplabs-dataverse