@reearth/visualizer-plugin-api

中文文档
2.1.0发布于 2026/11/02Apache-2.0TypeScript零依赖

TypeScript type definitions for the Re:Earth Visualizer plugin API

原始使用文档
文档目录11 节
  1. Installation
  2. Usage
  3. API Overview
  4. TypeScript configuration
  5. Versioning
  6. Source of truth
  7. Releasing
  8. One-time SRE setup
  9. First publish (manual — one time only)
  10. Subsequent releases
  11. License

@reearth/visualizer-plugin-api

TypeScript type definitions for the Re:Earth Visualizer plugin API.

Installation

npm install --save-dev @reearth/visualizer-plugin-api @reearth/[email protected]
# or
yarn add -D @reearth/visualizer-plugin-api @reearth/[email protected]

@reearth/core is a peer dependency, pinned to the version the Visualizer runs (0.0.7-alpha.81). Install that exact version, not latest, so the types match the Visualizer. Install it alongside this package so TypeScript can resolve the layer and feature types used in the declarations.

Note: @reearth/core brings React and Cesium with it (about 350 packages), only for the type imports.

Usage

Create a reearth.d.ts file in your plugin project:

import type { Reearth } from "@reearth/visualizer-plugin-api";

declare global {
  const reearth: Reearth;
}

Then use reearth with full TypeScript IntelliSense:

reearth.camera.flyTo({ lat: 35.68, lng: 139.76, height: 1000 });
reearth.layers.show("layer-id");
reearth.ui.show("<h1>Hello from plugin</h1>");
reearth.camera.on("move", (pos) => console.log(pos.lat, pos.lng));

API Overview

NamespaceDescription
reearth.cameraCamera control: flyTo, lookAt, zoom, rotate, events
reearth.layersLayer management: add, delete, find, select, override
reearth.viewerViewport, tools, coordinate conversion, interaction mode
reearth.timelinePlayback control: play, pause, setTime, setSpeed
reearth.sketchDrawing tools: marker, polyline, polygon, rectangle
reearth.uiPlugin panel: show HTML, postMessage, resize
reearth.modalModal dialog: show, update, close
reearth.popupPopup: show, update, position, close
reearth.extensionInter-plugin messaging, widget/block context
reearth.dataClient-side persistent storage
reearth.spatialIdPLATEAU spatial ID picking
reearth.engineRendering engine metadata

TypeScript configuration

Add "skipLibCheck": true to your tsconfig.json. This package depends on @reearth/core, which references React and Cesium types internally. Without skipLibCheck, those transitive declarations cause errors in projects that do not install React or Cesium types directly.

Versioning

This package version tracks the Re:Earth plugin API version directly. @reearth/[email protected] corresponds to plugin API version 2.1.0. When the plugin API version bumps, a new version of this package is released with the same version number.

See CHANGELOG.md for the full history.

Source of truth

This package is the single source of truth for the plugin API types. The Visualizer web app (web/) imports them from here, so there is no second copy to keep in sync. To change the API types:

  1. Edit visualizer-plugin-api/src, bump the version in package.json, and update CHANGELOG.md.
  2. Release the package (see below).
  3. Update the @reearth/visualizer-plugin-api version in web/package.json and run yarn install.

To try a change in web/ before releasing, build the package (npm run build) and point web at it with yarn add @reearth/visualizer-plugin-api@portal:../visualizer-plugin-api. Do not commit that; the web Dockerfile only builds from web/.

When @reearth/core is upgraded in web/, upgrade the pinned peer version here and release too.

Releasing

Publishing uses npm OIDC Trusted Publishing — no NPM_TOKEN needed.

One-time SRE setup

  1. Create the npm-publish environment on this GitHub repo with a required reviewer (Settings → Environments → New environment). Restrict deployment refs to tags matching visualizer-plugin-api-v*.
  2. Configure OIDC Trusted Publishing on npmjs.com for @reearth/visualizer-plugin-api:
    • Repository: reearth/reearth-visualizer
    • Workflow filename: plugin_api_release.yml
    • Environment: npm-publish

First publish (manual — one time only)

The package name must be claimed on the registry before Trusted Publishing can take over:

cd visualizer-plugin-api
npm publish --access public

Subsequent releases

  1. Bump the version in visualizer-plugin-api/package.json and update CHANGELOG.md.
  2. Go to GitHub Actions → Publish @reearth/visualizer-plugin-api → Run workflow.
  3. Enter the version number (must match package.json) and confirm.
  4. Approve the manual gate in the npm-publish environment.

License

Apache-2.0

版本与发布记录

@reearth/visualizer-plugin-api 共发布 2 个版本,首次发布于 2026/11/02;过去 12 个月发布了 2 个版本。

版本发布日期距今
2.1.0latest2026/11/021 天前
0.0.0-stage2026/11/021 天前

关于 @reearth/visualizer-plugin-api 的常见问题

@reearth/visualizer-plugin-api 是什么?

reearth Visualizer插件API的TypeScript类型定义

如何安装 @reearth/visualizer-plugin-api?

在项目目录运行 npm install @reearth/visualizer-plugin-api,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@reearth/core(0.0.7-alpha.81)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@reearth/visualizer-plugin-api 支持 TypeScript 吗?

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

@reearth/visualizer-plugin-api 可以商用吗?

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

@reearth/visualizer-plugin-api 还在维护吗?

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