1.0.0 • Published 4 months ago

ywpackage v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

ywpackage

test for npm library (build, ci, and publish)

const protocol = createMessageProtocol({
  events: {
    LOG_IN: {
      username: z.string(),
      password: z.string(),
    },
    LOG_OUT: {},
  },
});

// iframe.ts

const sendToParent = protocol.createHandler(window.parent.postMessage);

const handleParentEvent = protocol.createHandler((event) => {
  console.log(event);
});

window.addEventListener("message", (event) => {
  handleParentEvent(event.data);
});

// parent.ts

const iframe = document.querySelector("iframe");

const sendToChild = protocol.createHandler(iframe!.contentWindow!.postMessage);

Installation

npm i ywpackage

0.1.0

4 months ago

1.0.0

4 months ago

0.0.3

4 months ago

0.1.1

4 months ago

0.0.2

5 months ago