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

@laravelka/capacitor-nsd

v0.0.2

Published

Capacitor plugin for Network Service Discovery

Readme

@satoru/capacitor-nsd

Capacitor плагин для работы с Network Service Discovery (NSD) в локальной сети. Позволяет обнаруживать устройства и обмениваться данными между ними без необходимости в интернет-соединении.

Установка

npm install @satoru/capacitor-nsd
npx cap sync

Разработка

Требования

  • Node.js 14+
  • npm 6+
  • Android Studio и Android SDK для Android разработки
  • Xcode 12+ для iOS разработки (только macOS)

Сборка

npm install
npm run build

Проверка

# На Windows
npm run verify

# На macOS (включая iOS)
npm run verify:ios

Конфигурация

Android

Добавьте следующие разрешения в android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />

iOS

Специальная конфигурация не требуется. Плагин использует Network.framework, который доступен по умолчанию.

API

Методы

registerService(options: { serviceName: string, serviceType: string, port: number })

Регистрирует сервис в локальной сети.

await CapacitorNsd.registerService({
  serviceName: "MyService",
  serviceType: "_http._tcp.",
  port: 8080
});

unregisterService()

Отменяет регистрацию сервиса.

await CapacitorNsd.unregisterService();

startDiscovery(options: { serviceType: string })

Начинает поиск сервисов указанного типа в локальной сети.

await CapacitorNsd.startDiscovery({
  serviceType: "_http._tcp."
});

stopDiscovery()

Останавливает поиск сервисов.

await CapacitorNsd.stopDiscovery();

getDiscoveredServices()

Возвращает список найденных сервисов.

const { services } = await CapacitorNsd.getDiscoveredServices();

resolveService(options: { serviceName: string, serviceType: string })

Подключается к выбранному сервису.

const serviceInfo = await CapacitorNsd.resolveService({
  serviceName: "MyService",
  serviceType: "_http._tcp."
});

startWebSocketServer(options: { port: number })

Запускает WebSocket сервер для обмена данными.

await CapacitorNsd.startWebSocketServer({
  port: 8080
});

stopWebSocketServer()

Останавливает WebSocket сервер.

await CapacitorNsd.stopWebSocketServer();

sendData(options: { data: string })

Отправляет данные подключенному устройству.

await CapacitorNsd.sendData({
  data: JSON.stringify({ message: "Hello!" })
});

События

dataReceived

Событие, возникающее при получении данных.

CapacitorNsd.addListener('dataReceived', (data: { data: string }) => {
  console.log('Получены данные:', data.data);
});

Пример использования

Устройство A (Сервер)

// Регистрация сервиса
await CapacitorNsd.registerService({
  serviceName: "MyService",
  serviceType: "_http._tcp.",
  port: 8080
});

// Запуск WebSocket сервера
await CapacitorNsd.startWebSocketServer({
  port: 8080
});

// Прослушивание входящих сообщений
CapacitorNsd.addListener('dataReceived', (data) => {
  console.log('Получены данные:', data.data);
});

Устройство B (Клиент)

// Поиск сервисов
await CapacitorNsd.startDiscovery({
  serviceType: "_http._tcp."
});

// Получение списка сервисов
const { services } = await CapacitorNsd.getDiscoveredServices();

// Подключение к сервису
await CapacitorNsd.resolveService({
  serviceName: services[0].serviceName,
  serviceType: services[0].serviceType
});

// Отправка данных
await CapacitorNsd.sendData({
  data: JSON.stringify({ message: "Hello from client!" })
});

Поддерживаемые платформы

  • Android
  • iOS

Лицензия

MIT