@asteby/metacore-marketplace

中文文档
153.1.0发布于 2026/10/21Apache-2.0TypeScriptES Module零依赖近 30 天下载 3729

Metacore marketplace SDK — Hub catalog + Ops install/upgrade client, React hooks, and headless UI primitives shared across host apps (Ops, link).

原始使用文档
文档目录8 节
  1. What's in the box
  2. Quickstart
  3. Provider pattern
  4. Manifest v2 + v3
  5. Consent rule
  6. Tailwind v4 wiring
  7. Peer dependencies
  8. Consumers (planned)

@asteby/metacore-marketplace

Marketplace SDK for the metacore ecosystem — a transport-agnostic Hub catalog + local Ops kernel client, React Query hooks, and headless UI primitives shared by every host app (Ops, link, future apps).

What's in the box

src/
  client/       # HubClient (catalog + install initiation)
                # OpsClient (install/upgrade/uninstall against local kernel)
                # types + manifest normalization (v2 ⇆ v3) + diff helpers
  hooks/        # React Query wrappers: useCatalog, useAddonDetail,
                # useInstalledAddons, useInstallAddon (chained 2-step),
                # useUninstallAddon, useUpgradeAddon
  components/   # MarketplaceCatalog, AddonCard, AddonDetailPanel,
                # InstallConfirmModal, InstalledAddonsList, PermissionsDiff
  providers/    # MarketplaceProvider (wires hub + ops + labels into context)

Quickstart

import {
  MarketplaceProvider,
  createHubClient,
  createOpsClient,
  createFetchFetcher,
  MarketplaceCatalog,
} from '@asteby/metacore-marketplace'

const hubFetcher = createFetchFetcher({
  baseUrl: 'https://hub.metacore.dev',
  headers: () => ({ authorization: `Bearer ${getHubToken()}` }),
})

const opsFetcher = createFetchFetcher({
  baseUrl: '/api', // your own ops/link API base
  headers: () => ({ authorization: `Bearer ${getAccessToken()}` }),
})

const hub = createHubClient({ fetcher: hubFetcher })
const ops = createOpsClient({ fetcher: opsFetcher })

export function MarketplacePage() {
  return (
    <MarketplaceProvider hub={hub} ops={ops} organizationId={currentOrgId}>
      <MarketplaceCatalog onSelectAddon={(a) => navigate(`/marketplace/${a.key}`)} />
    </MarketplaceProvider>
  )
}

Provider pattern

Mirrors @asteby/metacore-app-providers — the consumer wires transport once at the app root and every hook/component reads from context. The package itself ships zero global state.

  • hub: catalog reader + install initiator (talks to the public Hub).
  • ops: lifecycle writer (talks to the host's local kernel).
  • organizationId: required — install requests carry it.
  • labels: optional i18n overrides.

Manifest v2 + v3

The marketplace already has two manifest shapes in production. This package exposes:

  • RawManifest (ManifestV2 | ManifestV3) — discriminated union as the Hub returns it.
  • Manifest — normalized shape: capabilities + permissions collapsed into one ordered, de-duplicated list, with the original raw payload preserved.

Use normalizeManifest() once per version you display; pass the result to PermissionsDiff and InstallConfirmModal. The hooks accept normalized manifests directly.

Per the kernel security policy, any capability addition or modification between versions REQUIRES a re-consent prompt on upgrade. The helper diffRequiresConsent(diffPermissions(current, next)) returns true when that's the case — InstallConfirmModal already uses it internally.

Tailwind v4 wiring

Following the SDK rule for @source declarations (reference), consumers MUST include this package's source in their main CSS file so the utility classes used by the components land in the bundle:

/* app.css */
@import 'tailwindcss';
@source "../../node_modules/@asteby/metacore-marketplace/dist";

Skip this and your MarketplaceCatalog will render unstyled.

Peer dependencies

  • react >= 18
  • react-dom >= 18
  • @tanstack/react-query >= 5
  • @asteby/metacore-app-providers ^7 (optional — only if you want the PlatformConfigProvider brand variables to drive marketplace colors)

The components use plain Tailwind classes plus the CSS variables shipped by @asteby/metacore-app-providers (--primary, --background, --border, …). They do NOT pull @asteby/metacore-ui so any host that prefers a different design system can still use the catalog without extra deps.

Consumers (planned)

  • Ops — /marketplace browse + install for org admins.
  • link — /integrations shows kernel-installed addons alongside the flow-runtime tools registry.
  • Pitsline preset UI — pre-curated bundle install via this package's primitives (next step).

版本与发布记录

@asteby/metacore-marketplace 共发布 152 个版本,首次发布于 2026/05/28;过去 12 个月发布了 152 个版本。

版本发布日期距今
153.1.0latest2026/10/2118 天前
153.0.02026/10/1821 天前
152.0.02026/10/1821 天前
151.0.02026/10/1524 天前
150.0.02026/10/1424 天前
149.0.02026/10/1425 天前

关于 @asteby/metacore-marketplace 的常见问题

@asteby/metacore-marketplace 是什么?

Metacore marketplace SDK — Hub catalog + Ops install/upgrade client, React hooks, and headless UI primitives shared across host apps (Ops, link).

如何安装 @asteby/metacore-marketplace?

在项目目录运行 npm install @asteby/metacore-marketplace,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18)、react-dom(>=18)、@tanstack/react-query(>=5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@asteby/metacore-marketplace 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@asteby/metacore-marketplace 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@asteby/metacore-marketplace 可以商用吗?

@asteby/metacore-marketplace 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@asteby/metacore-marketplace 的下载量有多少?

根据 npm 官方下载统计,@asteby/metacore-marketplace 在 2026/10/07 – 2026/11/05 这 30 天内被下载 3,729 次,日均约 124 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@asteby/metacore-marketplace 还在维护吗?

最新版本 153.1.0 发布于 2026/10/21(18 天前);至今共发布 152 个版本,其中过去 12 个月发布了 152 个;首次发布于 2026/05/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。