0.0.2 • Published 5 months ago

meteor-iframe v0.0.2

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

meteor-iframe

Make dataverse-kernel running in iframe.

Installation

pnpm install meteor-iframe

Run demo

requirements

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-iframe/meteor-iframe";

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

import { IframeCommunicator } from "meteor-iframe";

const communicator = new IframeCommunicator({
  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;
    }
  }
});