@basenative /市场
社区组件市场——浏览、安装和管理BaseNative包和主题
部分 BaseNative 生态系统——基于信号的web运行时,基于原生HTML。
安装
npm install @basenative/marketplace
快速入门
import { createRegistry, createInstaller, createThemeManager } from '@basenative/marketplace';
// Search the registry
const registry = createRegistry({ url: 'https://registry.basenative.dev' });
const { packages } = await registry.search('calendar', { limit: 10 });
// Get details for a specific package
const pkg = await registry.getPackage('bn-calendar');
const versions = await registry.getVersions('bn-calendar');
// Install a package into the current project
const installer = createInstaller({ projectRoot: process.cwd() });
await installer.install('[email protected]');
await installer.uninstall('bn-calendar');
const installed = await installer.list();
主题
import { createThemeManager } from '@basenative/marketplace';
const themes = createThemeManager({ registry });
// Browse and apply themes
const available = await themes.list();
await themes.apply('basenative-midnight');
await themes.reset();
API
createRegistry(options?)
创建市场注册中心客户端。选项: url (默认值: 'https://registry.basenative.dev'), token (发布的认证令牌)。
search(query, options?)—搜索包。选项:offset,limit,tag,category,sort。返回{ packages, total }.getPackage(name)-按名称返回包的完整元数据。getVersions(name)-返回包的已发布版本数组。publish(manifest, tarball)—将包发布到注册表(必需)token)。
createInstaller(options?)
创建本地安装程序。选项: projectRoot -项目目录的路径。
install(packageSpec)—安装软件包(例如:'bn-calendar'或者'[email protected]')。uninstall(name)—移除已安装的软件包。list()-返回当前安装的市场包的数组。update(name)—将已安装的软件包更新到最新版本。
createThemeManager(options)
创建主题管理器。选项: registry -注册表客户端实例。
list()-从注册表返回可用主题。apply(themeName)-下载并应用主题到项目。reset()-删除当前应用的主题并恢复默认设置。
许可证
apache - 2.0