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(export): the CDN root is the project's packaging setting, and export profiles override it
esengine6c250b4fcefc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d87da8969..bf24cc5c5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -19,6 +19,10 @@ published separately; it ships inside the editor.- **Android release signing.** A Shipping APK (and App Bundle) is signed with the release key the project names under Project Settings → Android → Signing — two PEM paths, the passphrase kept in this machine's keychain (the command line reads `ESTELLA_ANDROID_KEY_PASSPHRASE`); Development builds keep the development key. A Shipping build without one says it will be refused by Google Play.- **Export profiles.** A project can name several exports of one target in `packaging.profiles` — a test and a production WeChat build, each with its own AppID, CDN root and development or shipping configuration, writing only what differs from the project's settings. The Build dialog creates, edits and deletes them per target, marking each setting a profile overrides with a reset that hands it back to the project; `estella export --profile <name>` and the agent's `export_game` build the same one, and the size history records which profile a build used.+### Changed++- The CDN root remote asset groups and hot updates use is a packaging setting of the project (`packaging.remoteRoot`, the Package dialog's CDN root field), and export profiles override it — a production profile carries the real CDN while the project stays same-origin. `.esengine/asset-groups.json`'s `activeProfile` / `profiles` are still read for a project that sets no root of its own; hot-update-demo and the hot-update docs use the new shape.+### Fixed- The Profiler no longer reports a connected build's debug-channel cost as 0 ms when the device's clock is too coarse to measure it — a browser that is not cross-origin isolated steps by 0.1 ms. The device reports its clock's step, the row reads "< 0.100 ms", and `profile_frames` returns it as `channelClockMs`.diff --git a/desktop b/desktopindex a8aef6fd5..f900ac227 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit a8aef6fd514205089731b89fc55685832e9be7e9+Subproject commit f900ac22751a9823d20fedfd2428c97d9a0e8093diff --git a/docs/astro/src/content/docs/publishing/hot-update.mdx b/docs/astro/src/content/docs/publishing/hot-update.mdxindex e45d5b683..7b8c8d188 100644--- a/docs/astro/src/content/docs/publishing/hot-update.mdx+++ b/docs/astro/src/content/docs/publishing/hot-update.mdx@@ -88,14 +88,30 @@ fallback when a project has no `asset-groups.json`.)### Set the CDN root-Remote-group assets need a **root URL** to fetch from — your CDN. It's a **build-profile** setting, so `dev` and `prod` can point at different CDNs, and the-export bakes the active profile's root into the shipped game. Set it in the-**Package Project** dialog (**File → Build…**), under **Advanced**:+Remote-group assets need a **root URL** to fetch from — your CDN. It is a+packaging setting of the project (`packaging.remoteRoot` in `project.esproject`),+and an **export profile** can override it, so a test build and a production build+point at different CDNs. The export bakes the root it resolves into the shipped+game. Set it in the **Package Project** dialog (**File → Build…**), under+**Advanced**:-*The **CDN root** field writes the active profile's `remoteRoot` to `asset-groups.json`. Leave it empty to load remote assets same-origin (e.g. for local testing).*+*The **CDN root** field writes the project's `remoteRoot`, or the picked profile's when one is picked. Leave it empty to load remote assets same-origin (e.g. for local testing).*++```json+{+ "packaging": {+ "remoteRoot": "",+ "profiles": {+ "prod-web": { "platform": "web", "config": "shipping", "remoteRoot": "https://cdn.example.com/my-game" }+ }+ }+}+```++`estella export --profile prod-web` (or picking **prod-web** in the dialog) builds+with the production root; any other build uses the project's.### `.esengine/asset-groups.json`@@ -112,11 +128,6 @@ never disagree about where an asset ships):"atlases": {"ui": { "folder": "assets/art/ui" }},- "activeProfile": "dev",- "profiles": {- "dev": { "remoteRoot": "" },- "prod": { "remoteRoot": "https://cdn.example.com/my-game" }- }}```@@ -129,14 +140,13 @@ never disagree about where an asset ships):| `atlases` | `Record<name, {folder}>` | Folders whose textures pack into one atlas page. A **separate axis** from `groups`: which assets travel together and which share a texture page are different decisions, so an atlas may span two delivery groups and a group may hold two atlases. Absent ⇒ the `<name>.atlas/` folder convention still applies. || `atlases.<name>.folder` | `string` | Project-relative folder; every texture under it packs into this atlas. Longest matching prefix wins. || `groups.<name>.alwaysInclude` | `boolean` | Ship the group even when nothing in the build *reaches* it — for assets only your code names (a url, a path, rich-text markup). Off by default. See [Assets](/docs/assets/overview/#shipping-what-only-code-names). |-| `activeProfile` | `string` | Which profile the build uses (key into `profiles`). |-| `profiles.<name>.remoteRoot` | `string` | CDN root that this profile's remote-group assets are served from. Empty ⇒ same-origin. |+| `activeProfile`, `profiles` | — | **Older projects.** Where the CDN root was kept before `packaging.remoteRoot`: still read, and only while the project sets no root of its own. |## What the build shipsEvery Web / Desktop export always writes an **`asset-manifest.json`** (theaddressable manifest) next to the game — that's what a client diffs against for a-hot update. When the active profile has a CDN root, the export also bakes a+hot update. When the build has a CDN root, the export also bakes a`hotUpdate` block into `game.config.json`:```json@@ -378,8 +388,9 @@ disk-cache primitives differ per platform, and the runtime picks the right one.before you commit — prompt the player before a large download on mobile data.- **Handle `ok: false`.** A failed update rolls back cleanly; retry later ratherthan assuming success.-- **Use profiles.** Point `dev` at a test bucket (or empty for same-origin) and- `prod` at your real CDN, so a build ships the right root automatically.+- **Use export profiles.** Leave the project's root on a test bucket (or empty for+ same-origin) and give a production profile your real CDN, so each build ships+ the right root.- **Version by manifest URL.** A staged rollout / A-B channel is just a different`manifestUrl` — hand different clients different manifests off the same CDN.diff --git a/docs/astro/src/content/docs/zh-cn/publishing/hot-update.mdx b/docs/astro/src/content/docs/zh-cn/publishing/hot-update.mdxindex 1e5c4f6b3..fdb0f1e39 100644--- a/docs/astro/src/content/docs/zh-cn/publishing/hot-update.mdx+++ b/docs/astro/src/content/docs/zh-cn/publishing/hot-update.mdx@@ -64,11 +64,24 @@ Estella 的热更新是**内容寻址**、**原子**(要么全成、要么回### 设置 CDN 根地址-远端组资产需要一个**根 URL** 来拉取——你的 CDN。它是一个**构建 profile** 设置,因此 `dev` 与 `prod` 可以指向不同的 CDN,导出时会把活动 profile 的根地址烘进发布的游戏里。在**打包项目**对话框(**文件 → 构建…**)的**高级**里设置:+远端组资产需要一个**根 URL** 来拉取——你的 CDN。它是项目的打包设置(`project.esproject` 里的 `packaging.remoteRoot`),**导出配置档**可以覆盖它,于是测试构建和正式构建可以指向不同的 CDN。导出时会把最终确定的根地址烘进发布的游戏里。在**打包项目**对话框(**文件 → 构建…**)的**高级**里设置:-***CDN 地址** 字段会把活动 profile 的 `remoteRoot` 写入 `asset-groups.json`。留空则远端资产从游戏同源加载(例如本地测试时)。*+***CDN 地址** 字段写的是项目的 `remoteRoot`;选中了配置档时,写的是该配置档的。留空则远端资产从游戏同源加载(例如本地测试时)。*++```json+{+ "packaging": {+ "remoteRoot": "",+ "profiles": {+ "prod-web": { "platform": "web", "config": "shipping", "remoteRoot": "https://cdn.example.com/my-game" }+ }+ }+}+```++`estella export --profile prod-web`(或在对话框里选中 **prod-web**)用正式的根地址构建,其余构建用项目自己的。### `.esengine/asset-groups.json`@@ -83,11 +96,6 @@ Estella 的热更新是**内容寻址**、**原子**(要么全成、要么回"atlases": {"ui": { "folder": "assets/art/ui" }},- "activeProfile": "dev",- "profiles": {- "dev": { "remoteRoot": "" },- "prod": { "remoteRoot": "https://cdn.example.com/my-game" }- }}```@@ -100,12 +108,11 @@ Estella 的热更新是**内容寻址**、**原子**(要么全成、要么回| `atlases.<name>.folder` | `string` | 项目相对文件夹;其下每张纹理都打进这张图集。最长匹配前缀胜出。 || `groups.<name>.mode` | `'local' \| 'subpackage' \| 'remote'` | 交付模式。 || `groups.<name>.alwaysInclude` | `boolean` | 即使构建里没有任何东西*可达*到它,也照样发布这个组——用于只有你的代码点名的资产(url、路径、富文本标记)。默认关闭。见[资源](/docs/zh-cn/assets/overview/#只有代码点名的资产)。 |-| `activeProfile` | `string` | 构建使用哪个 profile(`profiles` 的键)。 |-| `profiles.<name>.remoteRoot` | `string` | 该 profile 的远端组资产的 CDN 根地址。留空 ⇒ 同源。 |+| `activeProfile`、`profiles` | — | **旧项目**。在 `packaging.remoteRoot` 出现之前,CDN 根地址存在这里:仍会读取,但仅限项目自己没设根地址时。 |## 构建产出了什么-每次 Web / 桌面导出都会在游戏旁写出一份 **`asset-manifest.json`**(可寻址清单)——那正是客户端做热更新 diff 的依据。当活动 profile 设有 CDN 根地址时,导出还会把一段 `hotUpdate` 烘进 `game.config.json`:+每次 Web / 桌面导出都会在游戏旁写出一份 **`asset-manifest.json`**(可寻址清单)——那正是客户端做热更新 diff 的依据。当这次构建有 CDN 根地址时,导出还会把一段 `hotUpdate` 烘进 `game.config.json`:```json{@@ -274,7 +281,7 @@ assets.releaseGroup('world2');- **给检查加锁**,藏在启动时的一次性开关或「检查更新」按钮后;不要每帧调用 `checkForUpdate`。- **展示体积。** `checkForUpdate` 在你提交前就给出 `totalBytes` 与文件数——在移动数据网络下大下载前提示玩家。- **处理 `ok: false`。** 失败的更新会干净回滚;稍后重试,而不是假定成功。-- **善用 profile。** 让 `dev` 指向测试桶(或留空走同源)、`prod` 指向真正的 CDN,这样构建就会自动发布正确的根地址。+- **善用导出配置档。** 项目自己的根地址指向测试桶(或留空走同源),给正式配置档配上真正的 CDN,这样每次构建都会带上正确的根地址。- **用清单 URL 做版本。** 灰度发布 / A-B 通道无非是不同的 `manifestUrl`——给不同客户端发同一 CDN 上不同的清单。## 参见diff --git a/examples/hot-update-demo/.esengine/asset-groups.json b/examples/hot-update-demo/.esengine/asset-groups.jsonindex 20869247c..48f8915d2 100644--- a/examples/hot-update-demo/.esengine/asset-groups.json+++ b/examples/hot-update-demo/.esengine/asset-groups.json@@ -9,14 +9,5 @@"folder": "assets/pack","mode": "subpackage"}- },- "activeProfile": "dev",- "profiles": {- "dev": {- "remoteRoot": ""- },- "prod": {- "remoteRoot": "https://cdn.example.com/hot-update-demo"- }}}diff --git a/examples/hot-update-demo/README.md b/examples/hot-update-demo/README.mdindex d41bf2c36..d2d90346a 100644--- a/examples/hot-update-demo/README.md+++ b/examples/hot-update-demo/README.md@@ -87,17 +87,29 @@ manifest.* Nothing is ever overwritten, so a cache can never go stale, andThe delivery config is `.esengine/asset-groups.json`, and the two groups takethe two modes their flows need: `cdn` is **remote** because a hot update has toreplace it after the game shipped, and `pack` is a **subpackage** because it-ships inside the package and is only fetched when asked for. Build profiles-(`dev` / `prod`) carry the CDN root per environment:+ships inside the package and is only fetched when asked for:```json{"groups": {"cdn": { "folder": "assets/cdn", "mode": "remote" },"pack": { "folder": "assets/pack", "mode": "subpackage" }- },- "activeProfile": "dev",- "profiles": { "dev": { "remoteRoot": "" }, "prod": { "remoteRoot": "https://cdn.example.com/hot-update-demo" } }+ }+}+```++The CDN root is a packaging setting in `project.esproject`: empty (same-origin)+for the project, and the real CDN in the two production export profiles,+`prod-web` and `prod-android` — build one with `estella export --profile prod-web`+or by picking it in the Package dialog:++```json+"packaging": {+ "remoteRoot": "",+ "profiles": {+ "prod-web": { "platform": "web", "config": "shipping", "remoteRoot": "https://cdn.example.com/hot-update-demo" },+ "prod-android": { "platform": "android", "config": "shipping", "remoteRoot": "https://cdn.example.com/hot-update-demo" }+ }}```diff --git a/examples/hot-update-demo/project.esproject b/examples/hot-update-demo/project.esprojectindex 511e929e7..650f6680b 100644--- a/examples/hot-update-demo/project.esproject+++ b/examples/hot-update-demo/project.esproject@@ -6,5 +6,20 @@"version": "0.1.0","defaultScene": "assets/scenes/main.esscene","designResolution": { "width": 800, "height": 600 },- "spineVersion": "none"+ "spineVersion": "none",+ "packaging": {+ "remoteRoot": "",+ "profiles": {+ "prod-web": {+ "platform": "web",+ "config": "shipping",+ "remoteRoot": "https://cdn.example.com/hot-update-demo"+ },+ "prod-android": {+ "platform": "android",+ "config": "shipping",+ "remoteRoot": "https://cdn.example.com/hot-update-demo"+ }+ }+ }}diff --git a/pipeline/src/export/projectExportOptions.ts b/pipeline/src/export/projectExportOptions.tsindex dfb27c9d0..bdf0f6850 100644--- a/pipeline/src/export/projectExportOptions.ts+++ b/pipeline/src/export/projectExportOptions.ts@@ -112,12 +112,14 @@ export async function projectExportOptions(? { playableAdProfile: (await loadPlayableProfile(root, plat?.playable?.network)) ?? undefined }: {}),sizeBudgetBytes: packaging?.sizeBudget?.[platform],+ // Unset leaves the hot-update config to fall back to asset-groups.json's+ // active profile, where projects kept their CDN root before this setting.+ ...(packaging?.remoteRoot !== undefined ? { hotUpdate: { remoteRoot: packaging.remoteRoot } } : {}),secretFiles: [quickGame?.releaseKey, platform === 'android' ? plat?.android?.releaseKey : undefined].flatMap((k) => (k ? [k.privateKey, k.certificate] : [])).filter((f) => f !== ''),...(profile ? {profile: profileName,...(profile.config ? { minify: profile.config === 'shipping' } : {}),- ...(profile.remoteRoot !== undefined ? { hotUpdate: { remoteRoot: profile.remoteRoot } } : {}),} : {}),};}diff --git a/pipeline/src/export/sizeHistory.ts b/pipeline/src/export/sizeHistory.tsindex 73bd3d59b..f706a1985 100644--- a/pipeline/src/export/sizeHistory.ts+++ b/pipeline/src/export/sizeHistory.ts@@ -70,6 +70,7 @@ export const PACKAGING_SIZE_ROLE: Readonly<Record<string, keyof SizeSettings | 'platforms: 'content',profiles: 'profile',profile: 'profile',+ remoteRoot: 'inert',};/** The settings this build ran with, out of everything the export was given. */diff --git a/pipeline/src/project/format.ts b/pipeline/src/project/format.tsindex 8f3f310aa..94bd0b17a 100644--- a/pipeline/src/project/format.ts+++ b/pipeline/src/project/format.ts@@ -413,11 +413,15 @@ export interface ProjectPackaging {/** The profile the Build dialog last packaged with; empty when it used the* project's own settings. */profile?: string;+ /** The CDN root remote asset groups and hot updates are served from; empty+ * means same-origin. Replaces `.esengine/asset-groups.json`'s active profile,+ * still read for a project that has not set this. */+ remoteRoot?: string;}/** The packaging settings a profile may set; the rest are the project's. */export const EXPORT_PROFILE_FIELDS = [- 'config', 'sourceMaps', 'assetCompression', 'compressWasm', 'engineSubpackage', 'excludeScenes',+ 'config', 'sourceMaps', 'assetCompression', 'compressWasm', 'engineSubpackage', 'excludeScenes', 'remoteRoot',] as const satisfies readonly (keyof ProjectPackaging)[];/**@@ -429,8 +433,6 @@ export interface ExportProfile extends Pick<ProjectPackaging, typeof EXPORT_PROFplatform: ExportPlatform;/** Only the profile's own target's slice is kept. */platforms?: ProjectPackaging['platforms'];- /** The CDN root remote asset groups and hot updates are served from. */- remoteRoot?: string;}/**@@ -942,6 +944,7 @@ export function parseManifest(raw: unknown): ProjectManifest {const profiles = parseExportProfiles(p.profiles);if (profiles) pkg.profiles = profiles;if (typeof p.profile === 'string' && p.profile !== '') pkg.profile = p.profile;+ if (typeof p.remoteRoot === 'string') pkg.remoteRoot = p.remoteRoot.trim().replace(/\/+$/, '');if (Object.keys(pkg).length > 0) manifest.packaging = pkg;}return manifest;@@ -964,7 +967,6 @@ function parseExportProfiles(raw: unknown): Record<string, ExportProfile> | unde}const slice = (parsed.platforms as Record<string, unknown> | undefined)?.[parsed.platform];if (slice) profile.platforms = { [parsed.platform]: slice } as ProjectPackaging['platforms'];- if (typeof fields.remoteRoot === 'string') profile.remoteRoot = fields.remoteRoot;profiles[name] = profile;}return Object.keys(profiles).length > 0 ? profiles : undefined;diff --git a/pipeline/tests/hot-update-config.test.ts b/pipeline/tests/hot-update-config.test.tsnew file mode 100644index 000000000..f4a657caa--- /dev/null+++ b/pipeline/tests/hot-update-config.test.ts@@ -0,0 +1,35 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file Which CDN root a package's hot-update config carries.+ */+import { describe, it, expect, beforeAll, afterAll } from 'vitest';+import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import path from 'node:path';+import { packagedHotUpdate } from '../src/export/hotUpdateConfig';++let legacy: string;+beforeAll(() => {+ legacy = mkdtempSync(path.join(tmpdir(), 'hot-update-'));+ mkdirSync(path.join(legacy, '.esengine'));+ writeFileSync(path.join(legacy, '.esengine', 'asset-groups.json'), JSON.stringify({+ version: '1.0', activeProfile: 'prod', profiles: { prod: { remoteRoot: 'https://old.example.com/game/' } },+ }));+});+afterAll(() => rmSync(legacy, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 }));++describe('the CDN root a package carries', () => {+ it('is the one the project or its profile names', async () => {+ expect(await packagedHotUpdate(legacy, { remoteRoot: 'https://cdn.example.com/game' }))+ .toEqual({ remoteRoot: 'https://cdn.example.com/game', persistUpdateKey: 'esengine:hotupdate' });+ });++ it('is none when the project says same-origin, even where an older profile named one', async () => {+ expect(await packagedHotUpdate(legacy, { remoteRoot: '' })).toBeUndefined();+ });++ it('falls back to the older asset-groups profile for a project that names none', async () => {+ expect((await packagedHotUpdate(legacy))?.remoteRoot).toBe('https://old.example.com/game');+ });+});diff --git a/pipeline/tests/project-export-options.test.ts b/pipeline/tests/project-export-options.test.tsindex c34c31a1e..02bd86d6a 100644--- a/pipeline/tests/project-export-options.test.ts+++ b/pipeline/tests/project-export-options.test.ts@@ -206,3 +206,24 @@ describe('an Android release key', () => {expect(() => (o.androidKey as () => unknown)()).toThrow(/Android release key could not be read \(nope\.pem/);});});++describe('the CDN root', () => {+ const cdn = (packaging: Record<string, unknown>) => parseManifest({ formatVersion: '1', name: 'p', packaging });++ it('is the project\'s, trimmed of a trailing slash, and a profile\'s where it sets one', async () => {+ const m = cdn({+ remoteRoot: 'https://cdn.example.com/game/',+ profiles: { local: { platform: 'web', remoteRoot: 'http://192.168.1.5:8080' } },+ });+ expect((await projectExportOptions(root, m, 'web')).hotUpdate).toEqual({ remoteRoot: 'https://cdn.example.com/game' });+ expect((await projectExportOptions(root, m, 'web', 'local')).hotUpdate).toEqual({ remoteRoot: 'http://192.168.1.5:8080' });+ });++ it('may be set empty, which serves remote groups from the game\'s own origin', async () => {+ expect((await projectExportOptions(root, cdn({ remoteRoot: '' }), 'web')).hotUpdate).toEqual({ remoteRoot: '' });+ });++ it('left unset, leaves the older asset-groups profile to answer', async () => {+ expect((await projectExportOptions(root, cdn({}), 'web')).hotUpdate).toBeUndefined();+ });+});diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 4b6ef0b9e..031c96786 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -1170,4 +1170,8 @@ export const NOTED = {{ note: 'The Profiler no longer reports a connected build\'s debug-channel cost as 0 ms when the device\'s clock is too coarse to measure it — a browser that is not cross-origin isolated steps by 0.1 ms. The device reports its clock\'s step, the row reads "< 0.100 ms", and `profile_frames` returns it as `channelClockMs`.' },'fix(profiler): a channel cost below the device clock reads as below it, not as 0':{ note: 'The Profiler no longer reports a connected build\'s debug-channel cost as 0 ms when the device\'s clock is too coarse to measure it — a browser that is not cross-origin isolated steps by 0.1 ms. The device reports its clock\'s step, the row reads "< 0.100 ms", and `profile_frames` returns it as `channelClockMs`.' },+ 'feat(export): the CDN root is the project\'s packaging setting, and export profiles override it':+ { note: 'The CDN root remote asset groups and hot updates use is a packaging setting of the project (`packaging.remoteRoot`, the Package dialog\'s CDN root field), and export profiles override it — a production profile carries the real CDN while the project stays same-origin. `.esengine/asset-groups.json`\'s `activeProfile` / `profiles` are still read for a project that sets no root of its own; hot-update-demo and the hot-update docs use the new shape.' },+ 'feat(build): the CDN root field writes the project\'s setting':+ { note: 'The CDN root remote asset groups and hot updates use is a packaging setting of the project (`packaging.remoteRoot`, the Package dialog\'s CDN root field), and export profiles override it — a production profile carries the real CDN while the project stays same-origin. `.esengine/asset-groups.json`\'s `activeProfile` / `profiles` are still read for a project that sets no root of its own; hot-update-demo and the hot-update docs use the new shape.' },};