npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ce1pers/window-helpers

v1.1.9

Published

Window Web APIs helpers powered by vanilla javascript.

Downloads

91

Readme

@ce1pers/window-helpers

브라우저 popup과 postMessage 통신을 제어하는 vanilla JavaScript helper입니다. React hook이 아닙니다.

설치

npm install @ce1pers/window-helpers

공개 API

useWindow(inputs?)

open, message 송수신, source/target origin 상태, event listener 제어 메서드를 반환합니다.

| 반환 API | 동작 | | --- | --- | | open(input) | windowTarget에 따라 현재 창 또는 새 browsing context를 열고 창 참조 반환 | | sendMessage(input) | to: "targetOrigin" | "sourceOrigin"에 따라 메시지 전송, 성공 여부 반환 | | sendMessageToTargetOrigin, sendMessageToSourceOrigin | 지정한 방향으로 { type, data } 전송 | | getWindow, getSourceOrigin, getTargetOrigin | 현재 상태 조회 | | setSourceOrigin, setTargetOrigin | 현재 origin 상태 설정 | | openDeepLink(url) | 현재 창을 deep link로 이동 | | subscribe, unsubscribe | message·unload listener 등록·해제 |

open 입력에는 targetOrigin이 필수이고 windowTarget, width, height, left, top, options, isPopup, callback을 선택적으로 전달합니다. windowTarget 기본값은 _self이므로 현재 창을 이동하며, 새 창이나 탭을 열려면 _blank 또는 재사용할 이름을 전달해야 합니다. sendMessage에는 to, type, data가 모두 필요합니다.

import { useWindow } from "@ce1pers/window-helpers";

function onMessageCallback(event: MessageEvent) {
  if (event.origin !== "https://child.example.com") return;
  // event.data를 애플리케이션 계약에 따라 검증합니다.
}

const popup = useWindow({ onMessageCallback });
popup.open({
  targetOrigin: "https://child.example.com",
  windowTarget: "_blank",
  isPopup: true,
  width: 400,
  height: 400,
});

popup.sendMessage({
  to: "targetOrigin",
  type: "connection",
  data: { source: "parent" },
});

targetOrigin은 scheme과 host를 포함한 실제 origin으로 설정하고, 수신 측에서 event.origin을 검증해야 합니다. 이 패키지는 메시지 payload의 schema 검증을 제공하지 않습니다.

공개 타입

OpenWindowInputs, SendMessageInputs, SendMessageToOriginInputs, UsePopupInputs를 export합니다.

검증

npm run build
npm test