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

@weavix/tracker-plugin-sdk-react

v0.0.6

Published

React hooks for Tracker plugin SDK

Readme

@weavix/tracker-plugin-sdk-react

React SDK for Tracker plugins (Weavix / npm). Mirrors @yandex-data-ui/tracker-plugin-sdk-react.

Для удобства написания плагинов:

Этот пакет предоставляет TrackerPluginProvider, хуки, а также реэкспортирует trackerApi и hostApi из core.

Для агентов и AI: AGENTS.mdCOOKBOOK. Core API: tracker-plugin-external.

Установка

npm install @weavix/tracker-plugin-sdk-react

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

Инициализация плагина

Оберните приложение в TrackerPluginProvider в корне. Компонент управляет инициализацией, состояниями загрузки и ошибок, а также уведомляет хост о готовности плагина.

import { TrackerPluginProvider } from '@weavix/tracker-plugin-sdk-react';
import { createRoot } from 'react-dom/client';
import { App } from './App';

const root = createRoot(document.getElementById('root')!);

root.render(
  <TrackerPluginProvider>
    <App />
  </TrackerPluginProvider>,
);

Получение темы, языка и контекста слота (basic)

По умолчанию в манифесте contextLevel: "basic" (или поле не задано) — в slotContext только entityId и опционально entityMeta.

import { useTrackerPluginContext } from '@weavix/tracker-plugin-sdk-react';

function MyComponent() {
  const { theme, language, slot, slotContext } = useTrackerPluginContext();

  return (
    <div className={theme}>
      <p>Язык: {language}</p>
      <p>Слот: {slot}</p>
      <p>Сущность: {slotContext?.entityId}</p>
    </div>
  );
}

Полный контекст слота (Issue)

Требуется "contextLevel": "full" в манифесте плагина.

import { useTrackerPluginContext } from '@weavix/tracker-plugin-sdk-react';

function IssuePlugin() {
  const { slotContext } = useTrackerPluginContext<'issue.action'>('full');

  return (
    <div>
      <h1>Задача: {slotContext?.key}</h1>
      <p>Версия: {slotContext?.version}</p>
    </div>
  );
}

Тип Issue в контексте слота — из @weavix/tracker-core (реэкспорт из core). Типы ответов trackerApi.v3 — из @weavix/tracker-api-types.

Локализация

import { useLocalizedString } from '@weavix/tracker-plugin-sdk-react';

function MyComponent() {
  const localize = useLocalizedString();

  const field = {
    name: { ru: 'Название', en: 'Summary' },
  };

  return <h1>{localize(field.name)}</h1>;
}

Кастомные состояния загрузки и ошибок

import { TrackerPluginProvider } from '@weavix/tracker-plugin-sdk-react';

root.render(
  <TrackerPluginProvider
    autoResize={false}
    fallback={<div>Загрузка...</div>}
    errorFallback={(error) => <div>Ошибка: {error.message}</div>}
    autoNotifyReady={false}
  >
    <App />
  </TrackerPluginProvider>,
);

Ручной вызов notifyReady

import { TrackerPluginProvider, hostApi } from '@weavix/tracker-plugin-sdk-react';
import { useEffect } from 'react';

function App() {
  useEffect(() => {
    initializeApp().then(() => {
      hostApi.notifyReady();
    });
  }, []);

  return <div>My Plugin</div>;
}

root.render(
  <TrackerPluginProvider autoNotifyReady={false}>
    <App />
  </TrackerPluginProvider>,
);

Компоненты

TrackerPluginProvider

Оборачивает приложение и управляет жизненным циклом плагина.

Props:

| Prop | Тип | По умолчанию | Описание | |------|-----|--------------|----------| | autoResize | boolean | true | Автоматически изменять размер контейнера при изменении контента | | fallback | ReactNode | <PluginLoader /> | Отображается во время инициализации | | errorFallback | (error: Error) => ReactNode | <PluginError /> | Отображается при ошибке инициализации | | autoNotifyReady | boolean | true | Автоматически уведомлять хост о готовности плагина |

Хуки

useTrackerPluginContext<TSlot>(level?)

Возвращает тему, язык, имя слота и контекст слота.

  • level: 'basic' (по умолчанию) — slotContext: { entityId, entityMeta? }
  • level: 'full' — полный контекст слота (Issue для issue.action); нужен contextLevel: "full" в манифесте

Возвращает: { theme, language, slot, slotContext, registerHandler }

Подробнее: API Reference — useTrackerPluginContext.

useToaster()

Хук для показа toast-уведомлений в хост-приложении.

Permission: "toaster" в permissions.ui манифеста.

import { useToaster } from '@weavix/tracker-plugin-sdk-react';

function MyComponent() {
  const toaster = useToaster();

  const handleSave = async () => {
    await saveData();
    toaster.add({ title: 'Сохранено', theme: 'success' });
  };

  return <button onClick={handleSave}>Сохранить</button>;
}

Параметры add(options) — в README tracker-core.

useLocalizedString(fallbackLanguage?)

Возвращает (value: LocalizedString) => string для текущего языка из контекста.

Полная документация

📖 AGENTS.md — вход для агентов.

📖 COOKBOOK — рецепты.

📖 API Reference — Provider, хуки, contextLevel.

📖 README tracker-coretrackerApi, hostApi, типы, ошибки.

Лицензия

UNLICENSED