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

tdt-vts-core

v1.0.0

Published

Framework-agnostic Tianditu private VTS decoding, style and worker utilities

Downloads

293

Readme

tdt-vts-core

天地图私有矢量瓦片的框架无关核心包,供 OpenLayers、MapLibre 等地图适配包共同使用。

包含:

  • PK 编解码与瓦片 URL 构造
  • 私有字节恢复、Protobuf/MVT 解析和标准 MVT 重编码
  • 瓦片请求与响应元数据
  • 可取消、可超时的 Worker 解码客户端

不依赖 OpenLayers、MapLibre 或 Cesium,也不创建地图图层或处理地图样式。样式合并由业务层完成;Style v8 JSON 地址或最终对象传给地图适配包,由适配包负责加载和应用。

import {
  createTdtVtsUrl,
  loadAndNormalizeTdtVts,
  TdtDecoderWorkerClient
} from 'tdt-vts-core'

地图引擎相关的数据源、图层适配分别保留在对应地图包中。

TdtDecoderWorkerClient.dispose() 可重复调用;关闭时会终止 Worker、清理监听器,并拒绝全部尚未完成的解码请求。Worker 未捕获错误走同一关闭流程,后续请求会立即失败。

Worker 的加载方式

默认情况下客户端用 new Worker(new URL('./tdt-vts/decoder.worker.mjs', import.meta.url), { type: 'module' }) 创建解码 Worker,适用于浏览器和能识别该写法的打包器(Vite、webpack 5、Rspack 等)。

以下场景必须自行注入 Worker,否则构造函数会明确抛错提示:

  • Node、SSR 预渲染等没有全局 Worker 的环境;
  • 使用 CJS 产物的宿主;
  • 需要自托管 Worker 资源、或走同源代理下发的部署。

Worker 脚本通过 tdt-vts-core/worker 子路径提供。它是资源入口,用于取得脚本地址后自行构造 Worker,不要在主线程直接 import 执行:

// Vite:以 URL 形式取得 Worker 脚本
import workerUrl from 'tdt-vts-core/worker?url'

const client = new TdtDecoderWorkerClient(restoreMode, {
  workerFactory: () => new Worker(workerUrl, { type: 'module' })
})

开发与验证

# 在仓库根目录执行
pnpm --dir packages/tdt-vts-core build       # tsdown 产出 esm + cjs + d.ts(压缩),含独立的 Worker 入口
pnpm --dir packages/tdt-vts-core check:types # tsc --noEmit
pnpm --dir packages/tdt-vts-core test        # build + check:types + node:test
pnpm --dir packages/tdt-vts-core dev         # watch 模式
pnpm lint:check                              # 仓库统一的只读 lint

本包零运行时依赖、零对等依赖,protobuf 解码为手写实现(src/protobuf.ts)。tdt-cesium 面向不相交的消费者,刻意保留了一份同语义的独立实现,两处修改需要互相核对。