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

@eihrteam/xml

v0.4.0

Published

Convert SKLand Endfield Wiki public item JSON and XML locally.

Downloads

346

Readme

@eihrteam/xml

Node License GitHub top language NPM Downloads Work With Agent Skill

SKLand Endfield Wiki JSON 与 XML 的本地互转工具包。处理 item/info 公开读取模型,不含网络请求、签名、认证或 API replay。

安装

pnpm add @eihrteam/xml

基本用法

import { wikiJsonToXml, wikiJsonToXmlBatch, xmlToWikiJson } from '@eihrteam/xml'

// InfoRoot 或 InfoItem JSON -> XML
const xml = wikiJsonToXml(infoRootJsonText).text

// 批量转换
const batch = wikiJsonToXmlBatch([
  { source: infoRootJsonText, meta: { itemId: '1', path: '终末地百科/物品/id1.json' } },
])

// XML -> InfoItem JSON
const infoItemJson = xmlToWikiJson(xml).text

// XML -> InfoRoot JSON(带外层 envelope)
const infoRootJson = xmlToWikiJson(xml, { wrapInfoRoot: true }).text

CLI

# JSON -> XML
xml convert --from json --to xml --input item.json --output item.xml

# XML -> JSON
xml convert --from xml --to json --input item.xml --output item.json

# 管道模式
cat item.json | xml convert --from json --to xml

格式说明:json 对应 wiki InfoItem/InfoRoot JSON,xml 对应 <sklandDocument> XML。

API

转换函数

| 函数 | 说明 | |------|------| | wikiJsonToXml(json) | InfoItem/InfoRoot JSON -> XML | | xmlToWikiJson(xml, options?) | XML -> InfoItem/InfoRoot JSON | | wikiJsonToXmlBatch(entries) | 批量 JSON -> XML | | xmlToWikiJsonBatch(entries, options?) | 批量 XML -> JSON | | convert(source, options) | 通用双向转换 |

解析与渲染

| 函数 | 说明 | |------|------| | parseWikiJson(source) | 解析 JSON 为 DocumentModel | | parseXml(source) | 解析 XML 为 DocumentModel | | renderXml(document) | DocumentModel 渲染为 XML | | renderWikiJson(document, options?) | DocumentModel 渲染为 JSON |

类型

| 导出 | 说明 | |------|------| | XmlWikiConversionError | 转换过程中的错误类型 | | ConvertOptions | convert() 的选项类型 | | RenderWikiJsonOptions | renderWikiJson() 的选项类型 | | ConversionResult | 返回 { text, warnings } | | DocumentModel 及相关 block/inline 类型 | 中间表示模型 |

ConversionResult

interface ConversionResult {
  text: string
  warnings: string[]
}

批量转换

wikiJsonToXmlBatch(entries) 接收 { source, meta? }[]source 为单个 InfoRoot 或 InfoItem(字符串或对象)。返回:

interface WikiJsonToXmlBatchResult<TMeta = unknown> {
  items: Array<ConversionResult & { meta?: TMeta }>
  warnings: string[]
}

每个 item 保留输入 meta 和单项 warnings;顶层 warnings 带 batch index 前缀的汇总。单条失败直接抛错,错误信息含 batch index。

xmlToWikiJsonBatch(entries, options?) 同理,接收 XML 字符串数组。

数据范围

  • JSON 范围是 item/info 正式页结构(InfoRoot 或 InfoItem),非通用 JSON。
  • XML 根节点为 <sklandDocument>
  • <publicMeta> 保存正式页元数据,如 langstatustagIdscreatedUserlastUpdatedUserpublishedAtTsmainTypesubType 等。
  • brief.description: null 会保留空简介状态,XML 中表现为 <description source="null">

兼容性说明

转换以 DocumentModel 语义等价为目标,不承诺字节级 round-trip。生成 JSON 时会重新生成 widgetCommonMapdocumentMap、block、tab、audio 等内部 id,但保持引用关系一致。

接受的公开响应边界值:空章节标题、空 content / intro.description 文档引用、brief.description: null、图片 URL 无法反推 id/format 时由 XML 显式保存 <id><format>、低于 100px 的表格列宽、复杂表格单元格覆盖关系。

运行时

  • Node.js 20 及以上。
  • 浏览器环境优先使用 globalThis.DOMParser
  • Node 环境使用 @xmldom/xmldom

鸣谢

  • 曾小皮 - XML 格式标准与初版 XML-JSON 互转工具

许可证

MIT