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

@edv4h/usketch-plugin-free-position

v0.1.9

Published

指定した位置から**最も近い、既存 shape と被らない位置**を求める機能を提供するプラグイン(Issue #581)。 貼り付け/複製/ドロップ/AI 生成などで新規 shape を重ねずに配置したいときに使う。UI は持たない。

Downloads

1,356

Readme

@edv4h/usketch-plugin-free-position

指定した位置から最も近い、既存 shape と被らない位置を求める機能を提供するプラグイン(Issue #581)。 貼り付け/複製/ドロップ/AI 生成などで新規 shape を重ねずに配置したいときに使う。UI は持たない。

使い方

import { createFreePositionPlugin } from "@edv4h/usketch-plugin-free-position";

const plugins = [
  // ...
  createFreePositionPlugin({ strategy: "ring" }), // "ring"(既定)| "push"
];

登録すると、free-position:find イベントで問い合わせできる(snap の snap:get-settings と同じ 同期コールバック方式):

import type { BoundingBox } from "@edv4h/usketch-shared";

let result: BoundingBox | undefined;
ctx.events.emit("free-position:find", {
  desired: { x, y, width, height },   // 置きたい位置・サイズ
  excludeIds: ["shape-1"],            // 任意: 衝突判定から除外(移動対象自身など)
  strategy: "push",                   // 任意: このリクエストだけ戦略を上書き
  onResult: (free) => { result = free; },
});
// result が「最も近い空き位置」(同サイズ)。プラグイン未登録なら onResult は呼ばれない。

探索戦略

  • ring(既定): desired 中心から同心リングを外へ広げ、衝突しない最近傍を返す。
  • push: desired を起点に、重なる相手から最小重なり軸方向へ押し出して分離する。

回転した shape は getRotatedAABB で外接矩形にして衝突判定する。

連携

@edv4h/usketch-plugin-keyboard-shortcuts の paste/duplicate はこのイベントを使い、複数 shape を 相対配置を保ったままグループ単位で空き位置へずらす(本プラグイン未登録時は従来の +20 オフセット)。 drop など他の配置経路も同じイベントを呼べば利用できる。

純ロジックは @edv4h/usketch-shape-utilsfindFreePosition / overlapsAny として単体でも使える。