@cesium-extends/common

中文文档
1.0.2发布于 2024/11/25MITTypeScriptES Module零依赖近 30 天下载 1767
  • Widget is a base class that you can extend to create your own widgets. You can import it into your project: - DomUtil is a utility class that provides some DOM manipulation methods. 中文 Readme
原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. Widget
  4. API
  5. DomUtil
  6. API

@cesium-extends/common

  • Widget is a base class that you can extend to create your own widgets. You can import it into your project:
  • DomUtil is a utility class that provides some DOM manipulation methods. 中文 Readme

Installation

npm install --save @cesium-extends/common

Usage

import { Widget, DomUtil } from "@cesium-extends/common";

Widget

Widget is a base class for widgets based on Cesium applications. It provides some common widget manipulation methods and properties.

API

constructor(viewer: Cesium.Viewer, wrapper: HTMLElement)

Creates a new instance of the Widget class and attaches it to the specified Cesium Viewer.

Parameters
  • viewer: The Cesium Viewer instance to attach the widget to.
  • wrapper: The DOM element to mount the widget to.

enabled

A boolean property that controls whether the widget is enabled or not.

ready

A boolean property indicating whether the widget is ready or not.

setContent(content: string | Element): Widget

A method for setting the content of the widget.

Parameters
  • content: A string or DOM element representing the content to set.

hide()

A method for hiding the widget.

show()

A method for showing the widget.

destroy()

A method for destroying the widget.

DomUtil

DomUtil is a utility class that provides some DOM manipulation methods.

API

create(tagName: string, className: string, container: Element | null = null): HTMLElement

Creates an HTML element with the specified tagName, sets its class to className, and optionally appends it to the container element.

Parameters
  • tagName: The HTML tag name to create.
  • className: The class name to set on the HTML element.
  • container (optional): The container element to append the new element to.

parseDom(domStr: string, className: string): HTMLDivElement

Parses a string into a DOM element and returns a DIV element containing the element.

Parameters
  • domStr: The string to parse.
  • className: The class name to set on the DIV element.

版本与发布记录

@cesium-extends/common 共发布 3 个版本,首次发布于 2023/04/10;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.2latest2024/11/252 年前
1.0.12023/05/113 年前
1.0.02023/04/103 年前

关于 @cesium-extends/common 的常见问题

@cesium-extends/common 是什么?

Widget is a base class that you can extend to create your own widgets. You can import it into your project: - DomUtil is a utility class that provides some DOM manipulation methods. 中文 Readme

如何安装 @cesium-extends/common?

在项目目录运行 npm install @cesium-extends/common,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:cesium(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cesium-extends/common 支持 TypeScript 吗?

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

@cesium-extends/common 支持 ESM 还是 CommonJS?

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

@cesium-extends/common 可以商用吗?

@cesium-extends/common 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cesium-extends/common 的下载量有多少?

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

@cesium-extends/common 还在维护吗?

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