@galcraft/plugins

中文文档
0.1.0发布于 2026/11/01MPL-2.0TypeScriptES Module

The galcraft-plugin development CLI supports Node.js 22.12.0 or later. Use the latest Node.js 24 LTS patch for an independent plugin project; source development and CI use Node.js 24.21.0 with pnpm 12.3.4. Generated Node service and native entries targe

原始使用文档

GalCraft plugin SDK

The galcraft-plugin development CLI supports Node.js 22.12.0 or later. Use the latest Node.js 24 LTS patch for an independent plugin project; source development and CI use Node.js 24.21.0 with pnpm 12.3.4. Generated Node service and native entries target Node.js 22.12; browser entries retain their browser target. The contracts and optional DSL parser exports also serve browser consumers and do not require a Node runtime in those consumers. Plugin authors install exact SDK versions from npm: npm install @galcraft/[email protected] @galcraft/[email protected]. Parser consumers also install @galcraft/[email protected].

The SDK exports plugin contracts at @galcraft/plugins/contracts, the host-shared React instance at @galcraft/plugins/react, the host-shared Pixi namespace at @galcraft/plugins/pixi, and authoring tools at @galcraft/plugins/development. Plugins use these public exports; host assembly uses @galcraft/plugins/host and @galcraft/plugins/registry.

galcraft-plugin create <directory> <pluginId> <template> creates an independent TypeScript project. Templates are author-tool, game-system, resource-stage, service-provider, and complete. Install contracts and plugins with npm install @galcraft/[email protected] @galcraft/[email protected], then run npm run typecheck, npm run build, npm run check, and npm run pack. The package directory supports Studio development loading; .galplugin files support the ordinary installer.

Manifest v1 remains supported. Manifest v2 requires a DOM-free definition entry and supports separate editor, Node services, and runtime entries plus environment dependencies. The host checks SDK major 0 together with the declared engine range. Engine, plugin and SDK package versions stay at 0.1.0 for current local development; example plugins declare ^0.1.0. Ordinary installation can refresh the same package version, and active leases retain a complete graph outside the replaceable package directory until release. An exact project Lock remains authoritative for package versions, including missing-version diagnostics. Plugin state uses one system contribution per plugin.

Package versions do not replace manifest versions, contractVersion: 1, or independent type, operation and state data versions. Existing document, asset-index, snapshot, task, candidate, draft and recipe envelopes remain at schemaVersion 1. Older records keep their original read mapping; opening them does not write extension fields or submit generation requests.

Manifest name and description contain the author's source text. Optional localizations maps locale keys to complete { name, description } translations, for example localizations.en and localizations.ja. Studio resolves display text using the current interface locale, then its language, then the source text. pluginDisplayMetadata(manifest, locale) exposes this rule through @galcraft/plugins/contracts. Display text does not change package IDs, versions or project locks.

The SDK distribution consists of the contracts and plugins package artifacts, plus the optional DSL parser artifact for authoring plugins that read GalCraft statements through @galcraft/dsl/parser. The distribution command builds and packs these artifacts; ordinary plugins install contracts/plugins, while parser consumers also install the matching DSL artifact. Builds bundle ordinary dependencies, preserve the host-shared React entry, and validate the ESM graph for each execution environment. Before measuring manifest file sizes, the build removes trailing spaces and tabs from generated JavaScript syntax in every environment, including native entries. Literal contents and files copied through include retain their original bytes. Services may use node: imports. Definition entries contain synchronous data callbacks and stay independent of UI and service execution.

See the repository developer guide at docs/reference/plugins.md for lifecycle, document mapping, services, and acceptance boundaries. GalCraft SDK code uses MPL-2.0. Distributed SDK tarballs carry the license and a source-availability notice under dist/licenses/project/. The development builder collects a plugin project's own LICENSE, COPYING, NOTICE and licenses/ files plus bundled dependency license reports; it preserves the author's declared license. New projects start with UNLICENSED until their author chooses terms. Read LICENSING.md in the source tree for the project material scope.

Asset UI extensions use AssetEditorContribution, AssetPreviewContribution, and AssetThumbnailContribution from the contracts export. A type descriptor associates editorKey, previewKey, and thumbnailKey with matching manifest declarations and editor contributions. Editor targets distinguish asset metadata, command fields, and stage instances; submit only through the context callback. The context also exposes the selected resource/version and a read-only flag.

Preview contexts identify an indexed asset or an unadopted candidate, carry its exact variant/typeData and read-only resource collection, and provide signal plus onDispose. Mounts may return a synchronous cleanup or a promise for cleanup. Register resources acquired before an awaited operation with onDispose; check signal before appending asynchronous results. Studio isolates each mount and releases old ranges on switching, deactivation, reload, and close. The external custom-asset example demonstrates real vertices/color editing, static previews, thumbnails, formal references, and an exact scalar filterFields declaration.

Typed production operations declare their fields and media ports in a DOM-free definition. The host provides generic controls for each port's type, MIME, required and multiple rules, including selection, replacement and individual removal while preserving other ports. A public fieldEditor is optional; its commit callback updates the personal M10 draft, checks its revision and invalidates the previous send plan. It does not submit an M02 work edit. See plugins/development-examples/video-generation/README.md for the local video protocol example and its verification limits.

版本与发布记录

@galcraft/plugins 共发布 2 个版本,首次发布于 2026/11/01;过去 12 个月发布了 2 个版本。

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

关于 @galcraft/plugins 的常见问题

@galcraft/plugins 是什么?

这个 galcraft-plugin development CLI支持Node.js 22.12.0及以上版本。为独立的插件项目使用最新的Node.js 24 LTS补丁;源代码开发和CI使用Node.js 24.21.0和pnpm 12.3.4。生成的节点服务和本机条目目标

如何安装 @galcraft/plugins?

在项目目录运行 npm install @galcraft/plugins,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 galcraft-plugin,可以用 npx galcraft-plugin 直接运行。

@galcraft/plugins 支持 TypeScript 吗?

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

@galcraft/plugins 支持 ESM 还是 CommonJS?

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

@galcraft/plugins 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@galcraft/plugins 可以商用吗?

@galcraft/plugins 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@galcraft/plugins 还在维护吗?

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