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

@sidri-fe/imodel-hooks

v0.1.1

Published

一个在 iModel 项目中使用的 react hook。

Readme

iModel Hooks

一个在 iModel 项目中使用的 react hook。

为了避免多重嵌套,重复创建 connection,自动获取 child,在组件卸载时自动销毁实例。

使用方法

  1. 引入 ImodelFrame 作为初始化 iframe 以及 context 的容器
// index.tsx
import { ImodelFrame } from '@sidri/imodel-hooks';

const App = () => {
  return (
    <Wrapper>
      <ImodelFrame>
        <Father>
          <Son />
        </Father>
      </ImodelFrame>
    </Wrapper>
  );
};
  1. ImodelFrame 内(请注意一定要在该组件内)任意级别的子组件内使用 useImodel 来获取 child ,方便快捷的调用 iModel Frame 提供的 API。
// Son.tsx
import React from 'react';
import { useImodel } from '@sidri/imodel-hooks';

const Son = () => {
  const { child } = useImodel();

  return (
    <div
      onClick={() => {
        child?.test('42');
      }}
    >
      don't panic
    </div>
  );
};

export default Son;
  1. ImodelFrame 接受的主要参数如下图所示(另外接受的参数包含 iframe 作为 element 的所有属性):

注:为了避免嵌套,此 hooks 已经将 onCompleted 集成在内部,不再需要使用方监听

// index.tsx
import { ImodelFrame } from '@sidri/imodel-hooks';

const App = () => {
  return (
    <Wrapper>
      <ImodelFrame
        onError={(error) => {
          // `error` 为握手时发生的错误
        }}
        methods={{
          // 具体请参考 iModel Frame 的 API 文档
          onLeftClick(info) {
            console.log(info);
          },
          onToolChange(toolName) {
            console.log(toolName);
          },
        }}
        // 是否展示调试日志(默认为否)
        debug={false}
        // 握手的超时时间,默认为 10000(单位:毫秒)
        timeout={10000}
        // 以下常用 props 就不再赘述了
        className={}
        style={}
      >
        <Father>
          <Son />
        </Father>
      </ImodelFrame>
    </Wrapper>
  );
};

引入方法

  1. 使用 nrm 或者 cgr 之类的工具将 npm 源切换为 http://10.190.44.202:4444 (内网用户)
yarn add @sidri-fe/imodel-hooks
  1. 直接使用 tgz 包(内网用户)
{
  "dependencies": {
    "@sidri-fe/imodel-hooks": "http://10.190.44.202:4444/@sidri-fe/imodel-hooks/-/imodel-hooks-0.1.1.tgz"
  }
}
  1. 从 npm 市场下载(非内网用户),请注意:最新的 patch 会优先发布在内网
yarn add @sidri-fe/imodel-hooks