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 🙏

© 2025 – Pkg Stats / Ryan Hefner

razumai

v1.0.3

Published

## Документация

Downloads

9

Readme

RAZUMAI API

Документация

Жизненный цикл плагина

Класс Plugin определяет жизненный цикл плагина и предоставляет операции, доступные для всех плагинов:

import { Plugin } from "razumai";

class ExamplePlugin extends Plugin {
  onload() {
    // Настройте ресурсы, необходимые плагину.
    console.log('loading plugin')
  }
  onunload() {
    // Освободите все ресурсы, настроенные плагином.
    console.log('unloading plugin')
  }
}

render(new ExamplePlugin('example_plugin'))

Создание страницы плагина

Чтобы создать страниц плагина, воспользуйтесь классом View:

onOpen()

Функция onOpen() вызывается, когда страница открывается, и отвечает за формирование содержимого.

createEl()

Функция createEl() добавляет элемент на страницу.

render()

Функция render() формирует содержимое страницу.

onClose()

Функция onClose() вызывается, когда страница закрывается, и отвечает за очистку любых ресурсов.

clean()

Функция clean() отчищает содержимое страницы.

import {Plugin, render, View, ViewLeaf} from 'razumai'

class ExampleView extends View {
    constructor(leaf: ViewLeaf) {
        super(leaf);
    }

    onOpen() {
        const h6 = document.createElement('h2')
        h6.innerHTML = "Lorem ipsum dolor"

        const text = document.createElement('span')
        text.innerHTML = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce convallis sed mi ac fringilla."

        this.createEl(h6)
        this.createEl(text)

        this.render()
    }

    onClose() {
        this.clean()
    }
}

class ExamplePlugin extends Plugin {
  onload() {
      this.registerView('view_example', (leaf) => new ExampleView(leaf))
  }
}

render(new ExamplePlugin('example_plugin'))

Использование React

Создайте новый файл под названием ReactView.tsx в корневом каталоге плагина со следующим содержимым:

const ReactView: React.FC = () => {
    return(
        <>
            <h4>ReactView</h4>
        </>
    );
};

Если вы хотите получить доступ к объекту Plugin из одного из ваших компонентов React, вам нужно передать его как зависимость:

const PluginContext = createContext();

const usePlugin = () => {
    return useContext(PluginContext);
};

const ReactView: React.FC = () => {
    const plugin = usePlugin();
    
    return(
        <>
            <h4>ReactView</h4>
        </>
    );
};

Чтобы использовать компонент React, его необходимо установить на HTML-элемент. В следующем примере компонент ReactView устанавливается на элемент this.leaf.containerEl:

import {Plugin, render, View, ViewLeaf} from 'razumai'
import { StrictMode } from "react";
import { Root, createRoot } from "react-dom/client";
import { ReactView } from "./ReactView";

class ExampleView extends View {
    
    root: Root | null = null;
    
    constructor(leaf: ViewLeaf) {
        super(leaf);
    }

    onOpen() {
        this.root = createRoot(this.leaf.containerEl);
        this.root.render(<StrictMode><ReactView /></StrictMode>);
    }

    onClose() {
        this.root?.unmount();
    }
}

class ExamplePlugin extends Plugin {
  onload() {
      this.registerView('view_example', (leaf) => new ExampleView(leaf))
  }
}

render(new ExamplePlugin('example_plugin'))