A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): scaffold a project platform from the dialog, instead of describing the files
yhh702a6c9eac92
diff --git a/desktop/electron/main.ts b/desktop/electron/main.tsindex 8e6ffbd5f..0e74b5e03 100644--- a/desktop/electron/main.ts+++ b/desktop/electron/main.ts@@ -39,7 +39,7 @@ import { ensureProjectShaderTwins } from './shaderTwins';import { installCrashCapture, logsDir } from './resilience';import { mcpMode, startMcpEndpoint } from './mcpEndpoint';import { checkForUpdate } from './updateCheck';-import { listPlatforms, loadProjectPlatform, type PlatformRuntimeDirs } from './platformCatalog';+import { listPlatforms, loadProjectPlatform, createProjectPlatform, type PlatformRuntimeDirs } from './platformCatalog';import { resolveLayout, resolveScripts, resolveOrientation, resolveScreenFit, type ExportPlatform } from '../src/project/format';import type { WorkspaceState } from '../src/project/format';@@ -774,6 +774,17 @@ ipcMain.handle('project:cookAssets', async (_e, outDir?: string) => {// runs, and can list the platforms the project defines for itself.ipcMain.handle('project:listPlatforms', async () => listPlatforms(projectRoot, platformRuntimeDirs()));+// Scaffold a project platform — both halves, already joined. The editor writes+// them because the SHAPE of a vendor (two files linked by runtimeProfile) is the+// part that is hard to know before you have seen one.+ipcMain.handle('project:createPlatform', async (_e, id: string, label: string) => {+ const root = requireRoot();+ const manifest = await readManifest(root);+ // The runtime half is game code, so it belongs beside the project's scripts.+ const scriptsDir = path.dirname(resolveScripts(manifest).main ?? 'src/main.ts');+ return createProjectPlatform(root, id, label, scriptsDir);+});+// Export a runnable web build (play == ship): cook + game host + wasm + index.html.ipcMain.handle('project:exportGame',diff --git a/desktop/electron/platformCatalog.ts b/desktop/electron/platformCatalog.tsindex d99e81b33..71f1c20ac 100644--- a/desktop/electron/platformCatalog.ts+++ b/desktop/electron/platformCatalog.ts@@ -22,7 +22,7 @@* merged over MINIGAME_PROFILE_DEFAULTS, not a fork of anything.*/import { existsSync } from 'node:fs';-import { readdir } from 'node:fs/promises';+import { readdir, mkdir, writeFile } from 'node:fs/promises';import path from 'node:path';import { pathToFileURL } from 'node:url';import { defaultMiniGameEntry } from './miniGameExportProfile';@@ -169,6 +169,151 @@ function platformDir(root: string): string {return path.join(root, PROJECT_PLATFORM_DIR);}+// =============================================================================+// Scaffolding+// =============================================================================++/** Where the generated runtime half goes, relative to the project root. */+const runtimeHalfPath = (scriptsDir: string, id: string): string =>+ path.join(scriptsDir, 'platforms', `${id}.runtime.ts`);++/** The packaging half — data plus the one emitter a vendor must write. */+function packagingTemplate(id: string, label: string, runtimeRel: string): string {+ return `// Packaging profile for "${label}" — how Estella builds the package.+//+// This is one half of a platform. The other half (${runtimeRel}) describes the+// HOST at runtime, and is where you replace a capability: your own video+// decoder, audio backend, socket or wasm loader.+//+// Everything not set here defaults to a standard mini-game host, so this file+// only carries what is genuinely yours.+export default {+ id: '${id}',+ label: '${label}',+ blurb: '${label} package.',+ defaultOut: 'dist-${id}',++ // Joins the two halves: the generated entry installs this profile before boot.+ runtimeProfile: '${runtimeRel.split(path.sep).join('/')}',++ // TODO: emit the config files your host's packer expects. The context carries+ // the vendor-neutral facts the pipeline computed.+ emitConfigFiles(ctx) {+ return [+ {+ file: 'game.json',+ content: JSON.stringify(+ {+ appName: ctx.title,+ orientation: ctx.orientation,+ // Lazy asset groups become the host's subpackage roots.+ ...(ctx.subPackages.length > 0 ? { subPackages: ctx.subPackages } : {}),+ },+ null,+ 2,+ ) + '\\n',+ },+ ];+ },++ // Uncomment if your host needs its own engine build; the default is the+ // editor's web runtime.+ // wasmDir: 'build/wasm/${id}',+};+`;+}++/** The runtime half — the host global, plus anything this vendor replaces. */+function runtimeTemplate(id: string, label: string): string {+ return `// Runtime profile for "${label}" — what the host is, at run time.+//+// Three facts are all that is required. Everything a mini-game host shares —+// filesystem, fetch, canvas, image decode, touch/key input, storage,+// subpackages, audio, sockets, video — comes from the global below.+import type { MiniGameProfile } from 'esengine/minigame';++// TODO: point this at your host's global API object (the wx-shaped one).+declare const HOST_GLOBAL: unknown;++const profile: MiniGameProfile = {+ id: '${id}',+ hostLabel: '${label}',++ // Read through a getter: the host global only exists at run time, so importing+ // this file in a bundler or a test must not touch it.+ get global() {+ if (typeof HOST_GLOBAL === 'undefined') {+ throw new Error('[${id}] set \`global\` in this file to your host API object');+ }+ return HOST_GLOBAL as MiniGameProfile['global'];+ },++ // ---------------------------------------------------------------------------+ // Optional overrides. Write one ONLY where your host genuinely differs, or+ // where you want a different implementation than the engine's.+ // ---------------------------------------------------------------------------++ // Your host does not use the standard \`WebAssembly\` (WeChat, for one, routes+ // through WXWebAssembly and takes a package path rather than bytes):+ // instantiateWasm(pathOrBuffer, imports) { … },++ // Your own video decoding, instead of the engine's wasm MPEG-1 decoder:+ // createVideoBackend(ctx) { return new MySoftwareDecoder(ctx); },++ // Your own audio or socket transport, instead of the family defaults built on+ // the host global:+ // createAudioBackend() { return new MyAudioBackend(); },+ // createSocket(options) { return new MySocket(options); },+};++export default profile;+`;+}++export interface CreatePlatformResult {+ ok: boolean;+ error?: string;+ /** Project-relative paths of the two files written. */+ packagingFile?: string;+ runtimeFile?: string;+}++/**+ * Scaffold a project platform: both halves, already joined.+ *+ * The editor writes them rather than asking the developer to create files by+ * hand — the shape of a vendor (two files, linked by `runtimeProfile`) is+ * exactly the thing that is hard to know before you have seen one.+ */+export async function createProjectPlatform(+ root: string,+ id: string,+ label: string,+ scriptsDir: string,+): Promise<CreatePlatformResult> {+ const bad = idProblem(id);+ if (bad) return { ok: false, error: bad };+ if (!label.trim()) return { ok: false, error: 'platform needs a label' };++ const packagingRel = path.join(PROJECT_PLATFORM_DIR, `${id}.mjs`);+ const runtimeRel = runtimeHalfPath(scriptsDir, id);+ const packagingAbs = path.join(root, packagingRel);+ const runtimeAbs = path.join(root, runtimeRel);++ if (existsSync(packagingAbs)) return { ok: false, error: `${packagingRel} already exists` };++ try {+ await mkdir(path.dirname(packagingAbs), { recursive: true });+ await mkdir(path.dirname(runtimeAbs), { recursive: true });+ await writeFile(packagingAbs, packagingTemplate(id, label, runtimeRel), 'utf8');+ // Never clobber a runtime half the developer already wrote.+ if (!existsSync(runtimeAbs)) await writeFile(runtimeAbs, runtimeTemplate(id, label), 'utf8');+ return { ok: true, packagingFile: posix(packagingRel), runtimeFile: posix(runtimeRel) };+ } catch (err) {+ return { ok: false, error: err instanceof Error ? err.message : String(err) };+ }+}+/** Ids that would collide with a built-in, or that are unsafe as a directory name. */function idProblem(id: unknown): string | null {if (typeof id !== 'string' || id.length === 0) return 'profile has no string `id`';diff --git a/desktop/electron/preload.ts b/desktop/electron/preload.tsindex c0f31b7c0..26d746946 100644--- a/desktop/electron/preload.ts+++ b/desktop/electron/preload.ts@@ -7,7 +7,7 @@ import type { ExtractSchemasResult } from './extractSchemas';import type { ScanAssetsResult, AssetIndex, IncrementalScanResult } from './assetDb';import type { CookResult } from './cookAssets';import type { ExportGameResult } from './exportGame';-import type { PlatformStatus } from './platformCatalog';+import type { PlatformStatus, CreatePlatformResult } from './platformCatalog';import type { PlayRealmResult } from './buildPlayRealm';import type { LatestRelease } from './updateCheck';@@ -97,6 +97,10 @@ const api = {/** The platforms this project can package for — built-ins plus any the project* defines in `.esengine/platforms/` — each with its engine runtime probed. */listPlatforms: (): Promise<PlatformStatus[]> => ipcRenderer.invoke('project:listPlatforms'),+ /** Scaffold a project platform: the packaging profile + the runtime profile it+ * points at, both written and already joined. */+ createPlatform: (id: string, label: string): Promise<CreatePlatformResult> =>+ ipcRenderer.invoke('project:createPlatform', id, label),/** Export a runnable web build (play==ship) → self-contained `outDir` (default dist-game/). */exportGame: (opts?: { outDir?: string; minify?: boolean; sourcemap?: boolean; platform?: ExportPlatform; compressTextures?: boolean; compressAudio?: boolean; atlasTextures?: boolean }): Promise<ExportGameResult> =>ipcRenderer.invoke('project:exportGame', opts),diff --git a/desktop/src/components/BuildDialog.tsx b/desktop/src/components/BuildDialog.tsxindex 3f7807b59..548e46517 100644--- a/desktop/src/components/BuildDialog.tsx+++ b/desktop/src/components/BuildDialog.tsx@@ -26,7 +26,7 @@import { useState, useEffect, useSyncExternalStore, type ReactNode } from 'react';import {Loader2, FolderOpen, CheckCircle2, AlertCircle, Boxes, Info, Copy, ExternalLink, Play,- Globe, Monitor, MessageSquare, ChevronRight, Smartphone, Package, TriangleAlert,+ Globe, Monitor, MessageSquare, ChevronRight, Smartphone, Package, TriangleAlert, Plus,} from 'lucide-react';import type { ExportPlatform } from '@/project/format';import { Modal } from '@/components/Modal';@@ -179,6 +179,12 @@ export function BuildDialog() {const [assetCompression, setAssetCompression] = useState<AssetCompression>(saved.assetCompression ?? 'auto');const [advOpen, setAdvOpen] = useState(false);const [copiedFix, setCopiedFix] = useState(false);+ // The scaffolding pane: a pseudo-selection, so the nav keeps working while it shows.+ const [creating, setCreating] = useState(false);+ const [newId, setNewId] = useState('my-platform');+ const [newLabel, setNewLabel] = useState('My Platform');+ const [createErr, setCreateErr] = useState<string | null>(null);+ const [created, setCreated] = useState<{ id: string; packaging: string; runtime: string } | null>(null);const [phase, setPhase] = useState<Phase>('idle');const [result, setResult] = useState<Result | null>(null);const [log, setLog] = useState<string[]>([]);@@ -253,6 +259,46 @@ export function BuildDialog() {setOutDir(saved.outDir?.[p.id] ?? p.defaultOut);};+ const startCreate = () => {+ setCreating(true);+ setCreated(null);+ setCreateErr(null);+ };++ const createPlatform = async () => {+ setCreateErr(null);+ const res = await window.estella.project?.createPlatform?.(newId.trim(), newLabel.trim());+ if (!res?.ok) {+ setCreateErr(res?.error ?? t('build.packageFailed'));+ return;+ }+ const id = newId.trim();+ setCreated({ id, packaging: res.packagingFile!, runtime: res.runtimeFile! });+ // Re-read the catalog so the new platform joins the nav, then select it.+ const rows = (await window.estella.project?.listPlatforms?.()) ?? [];+ const row = rows.find((r) => r.id === id);+ if (row) {+ setPlatforms((prev) => [+ ...prev.filter((p) => p.id !== row.id),+ {+ id: row.id, label: row.label ?? row.id, ready: row.ready, category: 'custom', custom: true,+ loadError: row.error, icon: <Package size={17} />, blurb: row.blurb ?? t('build.customHint'),+ defaultOut: row.defaultOut ?? `dist-${row.id}`, sourceMaps: false,+ prereq: prereqText(row), fixCommand: row.prereq?.command,+ next: (o) => t('build.next.custom', { out: o }),+ },+ ]);+ // Land ON the new platform rather than leaving the form up: the footer and+ // the Package button both act on the selection, and a form that is not a+ // selection would have them acting on the previous one.+ setCreating(false);+ setPlatform(row.id);+ setOutDir(row.defaultOut ?? `dist-${row.id}`);+ setPhase('idle');+ setResult(null);+ }+ };+const copyFix = (cmd: string) => {void navigator.clipboard?.writeText(cmd);setCopiedFix(true);@@ -352,16 +398,30 @@ export function BuildDialog() {if (items.length === 0 && cat !== 'custom') return null;return (<div key={cat} className="build__nav-group">- <div className="build__nav-sec">{CATEGORY_LABEL[cat]}</div>+ <div className="build__nav-sec">+ <span>{CATEGORY_LABEL[cat]}</span>+ {cat === 'custom' && (+ <button+ type="button"+ className="build__nav-add"+ title={t('build.newPlatform')}+ aria-label={t('build.newPlatform')}+ disabled={running || !project}+ onClick={startCreate}+ >+ <Plus size={13} />+ </button>+ )}+ </div>{items.map((p) => (<buttonkey={p.id}type="button"- className={`build__nav-item${platform === p.id ? ' active' : ''}`}- aria-current={platform === p.id}+ className={`build__nav-item${!creating && platform === p.id ? ' active' : ''}`}+ aria-current={!creating && platform === p.id}disabled={running}title={p.label}- onClick={() => pickPlatform(p)}+ onClick={() => { setCreating(false); pickPlatform(p); }}><span className="build__nav-icon">{p.icon}</span><span className="build__nav-label">{p.label}</span>@@ -381,11 +441,57 @@ export function BuildDialog() {</nav><div className="build__content">+ {creating ? (+ <>+ <div className="build__head">+ <span className="build__head-title">{t('build.newPlatformTitle')}</span>+ <span className="build__blurb">{t('build.newPlatformBlurb')}</span>+ </div>+ <Group title={t('build.newPlatform')}>+ <div className="build__row">+ <span className="build__label" title={t('build.platformIdTip')}>{t('build.platformId')}</span>+ <input value={newId} spellCheck={false} onChange={(e) => setNewId(e.target.value)} />+ </div>+ <div className="build__row">+ <span className="build__label">{t('build.platformLabel')}</span>+ <input value={newLabel} spellCheck={false} onChange={(e) => setNewLabel(e.target.value)} />+ </div>+ <div className="build__row">+ <span className="build__label" />+ <Button variant="primary" onClick={() => void createPlatform()}>+ <Plus size={13} /> {t('build.create')}+ </Button>+ </div>+ </Group>+ {createErr && (+ <div className="build__prereq is-error">+ <AlertCircle size={13} /> <span className="selectable">{createErr}</span>+ </div>+ )}+ </>+ ) : (+ <><div className="build__head"><span className="build__head-title">{def.label}</span><span className="build__blurb">{def.blurb}</span></div>+ {created?.id === def.id && (+ <div className="build__prereq">+ <CheckCircle2 size={13} />+ <div className="build__prereq-body">+ <span className="selectable">+ {t('build.created', { packaging: created.packaging, runtime: created.runtime })}+ </span>+ <div className="build__fix">+ <Button onClick={() => void window.estella.shell?.showItem?.(created.packaging)}>+ <FolderOpen size={12} /> {t('build.revealFiles')}+ </Button>+ </div>+ </div>+ </div>+ )}+{def.loadError && (<div className="build__prereq is-error"><AlertCircle size={13} />@@ -586,6 +692,8 @@ export function BuildDialog() {)}</div>)}+ </>+ )}</div></div></Modal>diff --git a/desktop/src/i18n/messages/project.ts b/desktop/src/i18n/messages/project.tsindex 504e1dba3..b05cd286c 100644--- a/desktop/src/i18n/messages/project.ts+++ b/desktop/src/i18n/messages/project.ts@@ -40,6 +40,24 @@ export const projectMessages = defineMessages({en: 'Package written to {out} — open it in your platform\'s devtools.',zh: '包已输出到 {out} —— 用该平台的开发者工具打开。',},+ 'build.newPlatform': { en: 'New platform', zh: '新建平台' },+ 'build.newPlatformTitle': { en: 'New project platform', zh: '新建项目平台' },+ 'build.newPlatformBlurb': {+ en: 'Estella writes both halves of the vendor — the packaging profile and the runtime profile it points at — already joined. Edit them to describe your host.',+ zh: 'Estella 会把平台的两半都写好——打包配置,以及它指向的运行时配置——并且已经连接好。之后你只需编辑它们来描述你的宿主。',+ },+ 'build.platformId': { en: 'Id', zh: '标识' },+ 'build.platformIdTip': {+ en: 'Lowercase letters, digits and dashes. Also the per-texture Import Settings key for this platform.',+ zh: '小写字母、数字和短横线。它同时是该平台的逐纹理导入设置键。',+ },+ 'build.platformLabel': { en: 'Name', zh: '名称' },+ 'build.create': { en: 'Create', zh: '创建' },+ 'build.created': {+ en: 'Created {packaging} and {runtime}. Edit them to describe your host, then package.',+ zh: '已创建 {packaging} 与 {runtime}。编辑它们来描述你的宿主,然后就可以打包。',+ },+ 'build.revealFiles': { en: 'Show files', zh: '显示文件' },'build.noCustomPlatforms': {en: 'Drop a profile in .esengine/platforms/<id>.mjs to add your own target.',zh: '在 .esengine/platforms/<id>.mjs 放一个配置文件即可添加自己的目标。',diff --git a/desktop/src/theme/menus.css b/desktop/src/theme/menus.cssindex 1a19c55bb..75a8a9632 100644--- a/desktop/src/theme/menus.css+++ b/desktop/src/theme/menus.css@@ -221,6 +221,9 @@}.build__nav-group + .build__nav-group { margin-top: 2px; }.build__nav-sec {+ display: flex;+ align-items: center;+ gap: 4px;font-size: var(--fs-2xs);text-transform: uppercase;letter-spacing: 0.6px;@@ -228,6 +231,23 @@font-weight: 700;padding: 10px 8px 4px;}+.build__nav-sec > span { flex: 1; min-width: 0; }+/* Scaffolding action: quiet until the group is hovered, so it does not compete+ with the platform rows for attention. */+.build__nav-add {+ display: grid;+ place-items: center;+ width: 18px;+ height: 18px;+ margin: -2px -2px -2px 0;+ border-radius: var(--r-xs);+ color: var(--text-mute);+ opacity: 0;+ transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast);+}+.build__nav-group:hover .build__nav-add, .build__nav-add:focus-visible { opacity: 1; }+.build__nav-add:hover:not(:disabled) { color: var(--text); background: var(--srf-4); }+.build__nav-add:disabled { opacity: 0; }.build__nav-item {width: 100%;display: flex;diff --git a/desktop/tests/platform-catalog.test.ts b/desktop/tests/platform-catalog.test.tsindex b39c3475f..381f03bb4 100644--- a/desktop/tests/platform-catalog.test.ts+++ b/desktop/tests/platform-catalog.test.ts@@ -10,10 +10,10 @@// 2. A project can add a platform the editor never heard of, and a broken one// must not take the dialog down with it.import { describe, it, expect, beforeEach, afterEach } from 'vitest';-import { mkdtempSync, rmSync, mkdirSync, writeFileSync } from 'node:fs';+import { mkdtempSync, rmSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs';import { tmpdir } from 'node:os';import path from 'node:path';-import { listPlatforms, loadProjectPlatform, PROJECT_PLATFORM_DIR } from '../electron/platformCatalog';+import { listPlatforms, loadProjectPlatform, createProjectPlatform, PROJECT_PLATFORM_DIR } from '../electron/platformCatalog';let root: string;let webDir: string;@@ -145,6 +145,60 @@ describe('listPlatforms — platforms the project defines', () => {});});+describe('createProjectPlatform — scaffolding', () => {+ it('writes both halves, already joined, and the result is discoverable', async () => {+ const res = await createProjectPlatform(root, 'acme-play', 'ACME Play', 'src');+ expect(res.ok).toBe(true);+ expect(res.packagingFile).toBe('.esengine/platforms/acme-play.mjs');+ expect(res.runtimeFile).toBe('src/platforms/acme-play.runtime.ts');+ // Reported with forward slashes, like every other path the dialog shows.+ expect(res.packagingFile).not.toContain('\\');++ const packaging = readFileSync(path.join(root, res.packagingFile!), 'utf8');+ const runtime = readFileSync(path.join(root, res.runtimeFile!), 'utf8');+ // THE JOIN: the packaging half names the runtime half.+ expect(packaging).toContain(`runtimeProfile: 'src/platforms/acme-play.runtime.ts'`);+ expect(runtime).toContain(`id: 'acme-play'`);+ expect(runtime).toContain(`hostLabel: 'ACME Play'`);+ // The overrides a vendor might want are present as guidance, commented out.+ expect(runtime).toContain('createVideoBackend');+ expect(runtime).toContain('instantiateWasm');++ // What was scaffolded is immediately a real platform.+ writeFileSync(path.join(webDir, 'esengine.js'), '//');+ const rows = await listPlatforms(root, dirs());+ const acme = rows.find((r) => r.id === 'acme-play');+ expect(acme?.source).toBe('project');+ expect(acme?.label).toBe('ACME Play');+ expect(acme?.error).toBeUndefined();+ expect(acme?.ready).toBe(true);++ // And it loads into a complete export profile.+ const loaded = await loadProjectPlatform(root, 'acme-play', dirs());+ expect(loaded!.profile.runtimeProfileModule).toBe(path.join(root, 'src', 'platforms', 'acme-play.runtime.ts'));+ expect(loaded!.defaultOut).toBe('dist-acme-play');+ expect(loaded!.profile.emitConfigFiles({ title: 'T', appid: '', orientation: 'portrait', subPackages: [], includeSuffixes: [] })[0].file)+ .toBe('game.json');+ });++ it('refuses an id that shadows a built-in or is malformed', async () => {+ expect((await createProjectPlatform(root, 'wechat', 'Fake', 'src')).error).toContain('built-in');+ expect((await createProjectPlatform(root, 'Bad Id', 'X', 'src')).error).toContain('lowercase');+ expect((await createProjectPlatform(root, 'ok-id', ' ', 'src')).error).toContain('label');+ });++ it('never clobbers an existing platform, or a runtime half already written', async () => {+ await createProjectPlatform(root, 'acme', 'ACME', 'src');+ const runtimeAbs = path.join(root, 'src', 'platforms', 'acme.runtime.ts');+ writeFileSync(runtimeAbs, 'export default { mine: true };');++ const again = await createProjectPlatform(root, 'acme', 'ACME', 'src');+ expect(again.ok).toBe(false);+ expect(again.error).toContain('already exists');+ expect(readFileSync(runtimeAbs, 'utf8')).toBe('export default { mine: true };');+ });+});+describe('loadProjectPlatform — the profile handed to exportMiniGame', () => {it('merges over the family defaults, so a minimal profile is complete', async () => {writePlatform('acme.mjs', `export default {diff --git a/docs/astro/src/content/docs/guides/minigame-platforms.mdx b/docs/astro/src/content/docs/guides/minigame-platforms.mdxindex d1786d486..2058b0a63 100644--- a/docs/astro/src/content/docs/guides/minigame-platforms.mdx+++ b/docs/astro/src/content/docs/guides/minigame-platforms.mdx@@ -188,8 +188,13 @@ function with WeChat's staged wasm name filled in, and nothing else.## Packaging-Drop a profile in `.esengine/platforms/<id>.mjs` and your platform appears in-**Package Project** under *Project*, beside the built-in targets:+In **Package Project**, hover the *Project* group in the platform list and hit+**+**. Give it an id and a name, and the editor writes both halves of the vendor+— already joined — then selects the new platform so you can package it as soon as+you have described your host.++The files it writes are ordinary project files; nothing is registered anywhere+else. This is the packaging half:```js// .esengine/platforms/acme-play.mjs@@ -220,7 +225,7 @@ side-module scan, bundling, runtime copy — is the same pipeline WeChat uses.### A vendor has two halves-The file above is the **packaging** half. The **runtime** half is the+The file above is the **packaging** half (scaffolded for you by **+**). The **runtime** half is the`MiniGameProfile` from the first part of this guide — the host global, and anycapability you replace. Point at it with `runtimeProfile` and the generated entryinstalls it before booting:diff --git a/docs/astro/src/content/docs/zh-cn/guides/minigame-platforms.mdx b/docs/astro/src/content/docs/zh-cn/guides/minigame-platforms.mdxindex fab8ed0da..fcd5e29da 100644--- a/docs/astro/src/content/docs/zh-cn/guides/minigame-platforms.mdx+++ b/docs/astro/src/content/docs/zh-cn/guides/minigame-platforms.mdx@@ -175,8 +175,11 @@ manifest,然后跑起 app——和微信走的是同一条序列。`initWeChat## 打包-在项目里放一个 `.esengine/platforms/<id>.mjs`,你的平台就会出现在**打包项目**-对话框的「项目自定义」分组里,与内置目标并列:+在**打包项目**对话框里,把鼠标移到平台列表的「项目自定义」分组上,点 **+**。+填一个标识和名称,编辑器就会把平台的两半都写好——并且已经连接好——然后选中这个+新平台;只要你描述完自己的宿主,就能直接打包。++它写出来的就是普通的项目文件,不会在别处注册什么。下面是打包那一半:```js// .esengine/platforms/acme-play.mjs@@ -206,7 +209,7 @@ manifest、场景变换、side-module 扫描、打包、运行时拷贝——与### 一个平台有两半-上面这个文件是**打包**那一半。**运行时**那一半就是本指南开头的 `MiniGameProfile`+上面这个文件是**打包**那一半(点 **+** 会帮你生成)。**运行时**那一半就是本指南开头的 `MiniGameProfile`——宿主全局对象,以及你替换掉的任何能力。用 `runtimeProfile` 指过去,生成的入口就会在启动前把它装上: