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

lan-he-shared-core

v1.0.9

Published

Smart home automation shared core SDK for cross-platform development

Readme

HA Shared Core SDK

一个跨平台的核心SDK,为多种运行环境提供统一的API和服务,包括移动设备(Android/iOS)、鸿蒙系统、桌面应用、小程序和车载系统。

功能特性

  • 跨平台支持:适配多种运行环境,提供统一的API接口
  • 认证服务:灵活的认证策略,支持自定义认证实现
  • 平台检测:自动检测运行环境并应用相应的兼容性策略
  • 兼容性处理:针对不同平台的输入标准化和功能特性支持检测
  • 设备抽象:统一的设备接口,屏蔽不同平台的实现差异
  • 同步引擎:数据同步机制,支持事件驱动的数据更新

支持的平台

  • mobile-android - Android移动设备
  • mobile-ios - iOS移动设备
  • harmony - 鸿蒙系统
  • desktop - 桌面应用(Electron/Node.js)
  • mini-program - 小程序环境
  • car-system - 车载系统
  • desktop-browser - 桌面浏览器

安装

npm install lanhe-core-sdk

使用方法

基本导入

import { 
  AuthService, 
  detectPlatform, 
  DeviceAPI, 
  getCompatibilityManager 
} from 'lanhe-core-sdk';

认证服务

// 创建认证服务实例
const authService = new AuthService(logger, deviceInfoService);

// 登录
const user = await authService.login('username', 'password');

// 登出
authService.logout(user.id);

// 自定义认证策略
authService.setAuthStrategy(customAuthStrategy);

平台检测

// 自动检测平台
const platform = detectPlatform();

// 在测试中设置特定平台
setPlatformForTesting('harmony');

兼容性处理

// 获取兼容性管理器
const manager = getCompatibilityManager();

// 标准化输入
const normalizedText = manager.normalizeInput("  Hello\tWorld\n");

// 检查功能支持
const canUseWebSockets = manager.isFeatureSupported("websocket");

// 使用快捷函数
import { normalizeInput, isFeatureSupported } from 'lanhe-core-sdk';

const text = normalizeInput(inputValue);
if (isFeatureSupported('geolocation')) {
  // 使用定位功能
}

设备API

// 创建设备API实例
const deviceAPI = new DeviceAPI();

// 获取设备ID
const deviceId = deviceAPI.getDeviceId();

// 请求权限
const hasPermission = await deviceAPI.requestPermission('record_audio');

// 获取蓝牙设备
const bluetoothDevices = await deviceAPI.getBluetoothDevices();

自定义平台策略

import { registerPlatformStrategy } from 'lanhe-core-sdk';

// 注册自定义平台策略
registerPlatformStrategy('custom-platform', {
  normalizeInput: input => input.trim().toLowerCase(),
  resolveFeatureConflict: featureName => featureName !== 'restricted-feature'
});

开发

构建项目

# 构建通用版本
npm run build

# 构建鸿蒙版本
npm run build:harmony

运行测试

# 运行所有测试
npm test

# 运行鸿蒙环境测试
npm run test:harmony

React Native项目集成

有关如何在React Native项目中集成和使用此共享核心层的详细指南,请参阅 React Native集成指南

该指南包含:

  • React Native项目目录结构建议
  • UI框架选择建议
  • 共享核心层npm包配置
  • 在React Native项目中使用共享核心层的方法(包括npm导入和npm-link本地连接)
  • 核心功能使用示例

项目结构

src/
├── core/           # 核心模块
│   ├── models/     # 数据模型
│   ├── services/   # 核心服务
│   └── sync-engine.ts # 同步引擎
├── platforms/      # 平台适配层
├── utils/          # 工具函数
└── typings/        # 类型定义

许可证

MIT