Skip to content

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.

feat(playable): package TikTok and overseas Pangle creatives

yhh0e88f1a17dcb
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 505940c1a..c9b9eb0d8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,8 @@ published separately; it ships inside the editor.
### Added
+- **TikTok and overseas Pangle package the same playable project.** Network profiles include root orientation config, load the official host SDK before game scripts, and dispatch store gestures through the host. ZIP limits stay below 5MB; metadata paths and duplicate filenames are checked before archiving. The Playable Ad example includes named exports for all three new networks.
+
- **Playable exports handle Mintegral start, completion and retry.** The network profile embeds resources in `index.html` and emits `index.zip`; the runtime waits for host start, pauses gameplay and audio on close, and preserves game-owned pause state. `playableGameEnd()` and `playableRetry()` report gameplay outcomes separately from installation. A responsive CC0 space fleet example demonstrates the complete flow.
### Fixed
diff --git a/docs/astro/src/content/docs/publishing/overview.mdx b/docs/astro/src/content/docs/publishing/overview.mdx
index f156ddbc5..cafa5a85e 100644
--- a/docs/astro/src/content/docs/publishing/overview.mdx
+++ b/docs/astro/src/content/docs/publishing/overview.mdx
@@ -114,6 +114,7 @@ selected it is a no-op, so the same scene still runs in the editor and on the we
| **Unity Ads** | 5MB | `mraid.open()` | Expects the playable to wait for MRAID's `viewableChange` before starting. |
| **AppLovin** | 5MB | `mraid.open()` | Requires every resource embedded — which a single-file playable already is. |
| **Mintegral** | 5MB | `window.install()` | Exports embedded `index.html` and matching `index.zip`. Waits for host start; game close pauses gameplay and audio. |
+| **TikTok / overseas Pangle** | ZIP <5MB | `window.openAppStore()` | Includes root `config.json`, each network’s orientation field, and the mandatory official SDK before game scripts. Ads Manager preview acceptance remains required. |
Limits move, so each one is reported against the network it came from: an oversized
export names the cap it used and where that number is published, rather than a bare
diff --git a/docs/astro/src/content/docs/zh-cn/publishing/overview.mdx b/docs/astro/src/content/docs/zh-cn/publishing/overview.mdx
index 9dd9d1f58..3fd95c13a 100644
--- a/docs/astro/src/content/docs/zh-cn/publishing/overview.mdx
+++ b/docs/astro/src/content/docs/zh-cn/publishing/overview.mdx
@@ -99,6 +99,7 @@ playableCta();
| **Unity Ads** | 5MB | `mraid.open()` | 要求试玩包等到 MRAID 的 `viewableChange` 之后再开始。 |
| **AppLovin** | 5MB | `mraid.open()` | 要求所有资源内嵌——单文件试玩本来就是。 |
| **Mintegral** | 5MB | `window.install()` | 导出资源内嵌的 `index.html` 和同名 `index.zip`。等待宿主开始,关闭时暂停游戏和音频。 |
+| **TikTok / 海外 Pangle** | ZIP <5MB | `window.openAppStore()` | 根目录包含 `config.json`,方向字段按平台区分;游戏脚本前注入官方 SDK。仍需广告管理平台预览验收,国内穿山甲另行适配。 |
上限会变,所以每条警告都指名它用的是哪一家的上限、以及这个数字出自哪里,而不是丢一个
让你盲信的数字。
diff --git a/examples/playable-ad/README.md b/examples/playable-ad/README.md
index 77a88b619..f34ce9617 100644
--- a/examples/playable-ad/README.md
+++ b/examples/playable-ad/README.md
@@ -17,3 +17,15 @@ An offline mock verifies wiring, not ad-network approval.
See [asset licenses](ASSET_LICENSES.md) and the
[official Mintegral test guide](https://www.playturbo.com/review/doc).
+
+Named export profiles `mintegral`, `tiktok`, and `pangle` package the same scene.
+For example: `node pipeline/bin/estella.mjs export examples/playable-ad --profile tiktok`.
+TikTok and overseas Pangle include a root `config.json` declaring both orientations,
+with each network's documented field casing. They load the mandatory official host
+SDK before game scripts and use `window.openAppStore()` through `playableCta()`.
+Both use the live lowercase CDN SDK URL documented by Pangle; TikTok's mixed-case
+URL returned 404 during verification. The profiles are not domestic Douyin or
+domestic Pangle exports. Validate uploads in the appropriate Ads Manager preview.
+
+Specifications: [TikTok](https://ads.tiktok.com/resources/help/article/playable-ads?lang=en),
+[overseas Pangle](https://ads.tiktok.com/resources/help/article/how-to-create-tiktok-pangle-playable-ads).
diff --git a/examples/playable-ad/project.esproject b/examples/playable-ad/project.esproject
index bc11af972..39f6188f1 100644
--- a/examples/playable-ad/project.esproject
+++ b/examples/playable-ad/project.esproject
@@ -15,6 +15,32 @@
"playable": {
"network": "mintegral"
}
+ },
+ "profiles": {
+ "mintegral": {
+ "platforms": {
+ "playable": {
+ "network": "mintegral"
+ }
+ },
+ "platform": "playable"
+ },
+ "tiktok": {
+ "platforms": {
+ "playable": {
+ "network": "tiktok"
+ }
+ },
+ "platform": "playable"
+ },
+ "pangle": {
+ "platforms": {
+ "playable": {
+ "network": "pangle"
+ }
+ },
+ "platform": "playable"
+ }
}
}
}
diff --git a/pipeline/src/export/exportPlayable.ts b/pipeline/src/export/exportPlayable.ts
index d6cd0a469..46b51c2df 100644
--- a/pipeline/src/export/exportPlayable.ts
+++ b/pipeline/src/export/exportPlayable.ts
@@ -118,7 +118,7 @@ function indexHtml(
title: string,
globals: string,
loader: string,
- network: { head: string; bridge: string },
+ network: { head: string; body: string; bridge: string },
): string {
return `<!doctype html>
<html lang="en">
@@ -133,7 +133,7 @@ function indexHtml(
</style>
</head>
<body>
- <canvas id="canvas"></canvas>${network.bridge ? `\n <script>${inlineSafe(network.bridge)}</script>` : ''}
+ <canvas id="canvas"></canvas>${network.body ? `\n ${network.body}` : ''}${network.bridge ? `\n <script>${inlineSafe(network.bridge)}</script>` : ''}
<script>${inlineSafe(globals)}</script>
<script>${inlineSafe(loader)}</script>
</body>
@@ -408,7 +408,19 @@ export async function exportPlayable(opts: {
if (!isPlayableZipFileName(zipName)) errors.push('Playable ZIP filename must be a portable name ending in .zip, without directories.');
else {
zipFile = path.join(absOut, zipName);
- await writeFile(zipFile, makeZip([{ name: 'index.html', data: await readFile(outFile) }]));
+ const extraFiles = adProfile.emitZipFiles?.({ title, orientation }) ?? [];
+ const names = new Set(['index.html']);
+ const files = [{ name: 'index.html', data: await readFile(outFile) }];
+ for (const file of extraFiles) {
+ const name = typeof file?.name === 'string' ? file.name.toLowerCase() : '';
+ if (!name || !/^[a-z0-9_]+\.[a-z0-9]+$/.test(name) || /^(con|prn|aux|nul|com[1-9]|lpt[1-9])\./.test(name) || names.has(name) || typeof file.content !== 'string') {
+ errors.push('Playable ZIP extra files need unique portable root filenames and text content.');
+ continue;
+ }
+ names.add(name);
+ files.push({ name: file.name, data: Buffer.from(file.content, 'utf8') });
+ }
+ await writeFile(zipFile, makeZip(files));
// The archive is the file being sent, so it is the one the limit applies to.
bytes = (await stat(zipFile)).size;
}
diff --git a/pipeline/src/export/platformCatalog.ts b/pipeline/src/export/platformCatalog.ts
index f06205560..f45c82044 100644
--- a/pipeline/src/export/platformCatalog.ts
+++ b/pipeline/src/export/platformCatalog.ts
@@ -512,6 +512,11 @@ async function importPlatformModule(
if (candidate.zipFileName !== undefined && !isPlayableZipFileName(candidate.zipFileName)) {
return { error: '`zipFileName` must be a portable alphanumeric/underscore ZIP filename' };
}
+ for (const hook of ['emitHead', 'emitBody', 'emitBridge', 'emitZipFiles'] as const) {
+ if (candidate[hook] !== undefined && typeof candidate[hook] !== 'function') {
+ return { error: `playable profile hook ${hook} must be a function` };
+ }
+ }
return { mod: candidate };
}
if (typeof candidate.emitConfigFiles !== 'function') return { error: 'profile has no `emitConfigFiles(ctx)`' };
@@ -634,6 +639,8 @@ export async function loadPlayableProfile(root: string | null, id: string | unde
zipFileName: mod.zipFileName,
deliveryNote: mod.deliveryNote,
emitHead: mod.emitHead,
+ emitBody: mod.emitBody,
+ emitZipFiles: mod.emitZipFiles,
emitBridge: mod.emitBridge,
};
}
diff --git a/pipeline/src/export/playableAdProfile.ts b/pipeline/src/export/playableAdProfile.ts
index 377b55cc2..c6b88f5d4 100644
--- a/pipeline/src/export/playableAdProfile.ts
+++ b/pipeline/src/export/playableAdProfile.ts
@@ -57,6 +57,10 @@ export interface PlayableAdProfile {
readonly deliveryNote?: string;
/** Markup for `<head>`: an orientation meta tag, the network's own SDK script. */
emitHead?(ctx: PlayableAdContext): string;
+ /** Host SDK markup placed in body before all game scripts. */
+ emitBody?(ctx: PlayableAdContext): string;
+ /** Additional root files included in a ZIP, such as network config.json. */
+ emitZipFiles?(ctx: PlayableAdContext): { name: string; content: string }[];
/**
* An inline script installing `globalThis.__ESTELLA_PLAYABLE__`, whose `cta()`
* calls this network's click-through API. The game side of that seam is the
@@ -184,6 +188,32 @@ onActive:function(fn){listeners.push(fn);fn(active);return function(){listeners=
})();`,
};
+/** @see https://ads.tiktok.com/resources/help/article/playable-ads?lang=en */
+export const tiktokPlayableProfile: PlayableAdProfile = {
+ id: 'tiktok', label: 'TikTok', maxBytes: 5 * 1024 * 1024 - 1,
+ limitNote: 'TikTok requires a ZIP less than 5MB (official September 2026 specification)',
+ delivery: 'zip',
+ deliveryNote: 'Test the upload in TikTok Ads Manager; store redirects are disabled during preview. Only the mandatory host SDK is external.',
+ // The mixed-case TikTok documentation URL returns 404; the compatible Pangle URL is live.
+ emitBody: () => '<script src="https://sf16-muse-va.ibytedtos.com/obj/union-fe-nc-i18n/playable/sdk/playable-sdk.js"></script>',
+ emitZipFiles: () => [{ name: 'config.json', content: JSON.stringify({ Playable_orientation: 0 }) }],
+ emitBridge: () => `(function(){
+ window.__ESTELLA_PLAYABLE__={
+ cta:function(){if(typeof window.openAppStore==="function")window.openAppStore();},
+ onActive:function(fn){function changed(){fn(!document.hidden);}document.addEventListener("visibilitychange",changed);changed();return function(){document.removeEventListener("visibilitychange",changed);};}
+ };
+ })();`,
+};
+
+/** @see https://ads.tiktok.com/resources/help/article/how-to-create-tiktok-pangle-playable-ads */
+export const panglePlayableProfile: PlayableAdProfile = {
+ ...tiktokPlayableProfile,
+ id: 'pangle', label: 'TikTok Ad Network (Pangle, overseas)',
+ limitNote: 'TikTok Ad Network requires a ZIP less than 5MB (official September 2026 specification)',
+ emitBody: () => '<script src="https://sf16-muse-va.ibytedtos.com/obj/union-fe-nc-i18n/playable/sdk/playable-sdk.js"></script>',
+ emitZipFiles: () => [{ name: 'config.json', content: JSON.stringify({ playable_orientation: 0 }) }],
+};
+
/** The networks the editor ships, by id. A network absent here is not unsupported:
* a project defines its own with the same contract (`kind: 'playable'`). */
export const BUILTIN_PLAYABLE_PROFILES: readonly PlayableAdProfile[] = [
@@ -194,6 +224,8 @@ export const BUILTIN_PLAYABLE_PROFILES: readonly PlayableAdProfile[] = [
unityPlayableProfile,
applovinPlayableProfile,
mintegralPlayableProfile,
+ tiktokPlayableProfile,
+ panglePlayableProfile,
];
export function builtinPlayableProfile(id: string | undefined): PlayableAdProfile | null {
@@ -204,9 +236,10 @@ export function builtinPlayableProfile(id: string | undefined): PlayableAdProfil
export function playableAdInjection(
profile: PlayableAdProfile,
ctx: PlayableAdContext,
-): { head: string; bridge: string } {
+): { head: string; body: string; bridge: string } {
return {
head: profile.emitHead?.(ctx) ?? '',
+ body: profile.emitBody?.(ctx) ?? '',
bridge: profile.emitBridge?.(ctx) ?? '',
};
}
diff --git a/pipeline/tests/export-playable.test.ts b/pipeline/tests/export-playable.test.ts
index 80f1cd892..ce5641af6 100644
--- a/pipeline/tests/export-playable.test.ts
+++ b/pipeline/tests/export-playable.test.ts
@@ -9,7 +9,7 @@
*/
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { runtimeConfigOf } from '../src/project/runtimeConfig';
-import { BUILTIN_PLAYABLE_PROFILES } from '../src/export/playableAdProfile';
+import { BUILTIN_PLAYABLE_PROFILES, tiktokPlayableProfile, panglePlayableProfile } from '../src/export/playableAdProfile';
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
@@ -264,6 +264,37 @@ describe('exportGame (playable)', () => {
expect(res.size?.deliverableBytes).toBe(sized.bytes);
}, 60_000);
+ it.each([tiktokPlayableProfile, panglePlayableProfile])('ships $id config and its literal SDK before game scripts', async (profile) => {
+ const o = path.join(root, 'network-' + profile.id);
+ const res = await exportGame({
+ root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, packagesDir: OFFICIAL_PACKAGES,
+ scriptsEntry: 'src/main.ts', sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'),
+ outDir: o, platform: 'playable', playableAdProfile: profile,
+ });
+ expect(res.ok).toBe(true);
+ const html = readFileSync(path.join(o, 'index.html'), 'utf8');
+ const sdk = profile.emitBody!({ title: 'T', orientation: 'portrait' });
+ expect(html.indexOf(sdk)).toBeGreaterThan(html.indexOf('<body>'));
+ expect(html.indexOf(sdk)).toBeLessThan(html.indexOf('window.__ESTELLA_PLAYABLE__'));
+ expect(html).not.toContain('mraid');
+ const files = execFileSync('unzip', ['-Z1', res.zipFile!], { encoding: 'utf8' }).trim().split('\n');
+ expect(files).toEqual(['index.html', 'config.json']);
+ const config = JSON.parse(execFileSync('unzip', ['-p', res.zipFile!, 'config.json'], { encoding: 'utf8' }));
+ expect(config).toEqual(profile.id === 'tiktok' ? { Playable_orientation: 0 } : { playable_orientation: 0 });
+ expect(res.size?.verdicts.find(v => v.budget.scope === 'deliverable')?.budget.maxBytes).toBe(5 * 1024 * 1024 - 1);
+ }, 60_000);
+
+ it.each(['../config.json', 'INDEX.html', 'CON.json'])('rejects unsafe or colliding ZIP metadata: %s', async name => {
+ const res = await exportGame({
+ root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, packagesDir: OFFICIAL_PACKAGES,
+ scriptsEntry: 'src/main.ts', sdkDistDir: path.join(root, '_sdk'), wasmDir: path.join(root, '_wasm'),
+ outDir: path.join(root, 'bad-extra'), platform: 'playable',
+ playableAdProfile: { ...tiktokPlayableProfile, emitZipFiles: () => [{ name, content: '{}' }] },
+ });
+ expect(res.ok).toBe(false);
+ expect(res.errors.join('\n')).toMatch(/unique portable root filenames/);
+ }, 60_000);
+
it('rejects an oversized HTML even when a ZIP is the uploaded file', async () => {
const res = await exportGame({
root, entryScene: 'scenes/main.esscene', hostsDir: HOSTS, packagesDir: OFFICIAL_PACKAGES,
@@ -517,7 +548,7 @@ describe('playable ad profiles', () => {
const quoted = /(\d+(?:\.\d+)?)\s*MB/i.exec(p.limitNote);
expect(quoted, `${p.id}: limitNote must quote the cap it enforces — "${p.limitNote}"`).not.toBeNull();
expect(p.maxBytes, `${p.id} enforces ${p.maxBytes}B, its note says ${quoted?.[1]}MB`)
- .toBe(Number(quoted?.[1]) * 1024 * 1024);
+ .toBe(Number(quoted?.[1]) * 1024 * 1024 - (p.limitNote.includes('less than') ? 1 : 0));
}
});
});
diff --git a/pipeline/tests/platform-catalog.test.ts b/pipeline/tests/platform-catalog.test.ts
index 6c1163e01..211d86db2 100644
--- a/pipeline/tests/platform-catalog.test.ts
+++ b/pipeline/tests/platform-catalog.test.ts
@@ -363,7 +363,7 @@ describe('playable ad networks', () => {
};`);
const rows = await listPlayableNetworks(root);
expect(rows.filter((r) => r.source === 'builtin').map((r) => r.id))
- .toEqual(['generic', 'meta', 'google', 'mraid', 'unity', 'applovin', 'mintegral']);
+ .toEqual(['generic', 'meta', 'google', 'mraid', 'unity', 'applovin', 'mintegral', 'tiktok', 'pangle']);
// A project network names the file that defines it, so the dialog can point at it
// (and at the error, when one fails to load). Built-ins have no file.
expect(rows.find((r) => r.id === 'acme-ads')).toMatchObject({
@@ -438,6 +438,14 @@ describe('playable ad networks', () => {
expect(row!.error).toMatch(/zipFileName/);
});
+ it('reports malformed host hooks before attempting export', async () => {
+ writePlatform('bad-hook.mjs', `export default {
+ id: 'bad-hook', kind: 'playable', label: 'Bad Hook', maxBytes: 100, limitNote: 'x', emitZipFiles: 'config.json'
+ };`);
+ const row = (await listPlayableNetworks(root)).find(r => r.id === 'bad-hook');
+ expect(row!.error).toMatch(/emitZipFiles.*function/);
+ });
+
it('rejects a playable profile missing the facts the warning needs', async () => {
writePlatform('bad.mjs', "export default { id: 'bad', kind: 'playable', label: 'Bad' };");
const row = (await listPlayableNetworks(root)).find((r) => r.id === 'bad');
diff --git a/pipeline/tests/playable-tiktok.test.ts b/pipeline/tests/playable-tiktok.test.ts
new file mode 100644
index 000000000..15eba73e3
--- /dev/null
+++ b/pipeline/tests/playable-tiktok.test.ts
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+import { describe, it, expect, vi } from 'vitest';
+import { tiktokPlayableProfile } from '../src/export/playableAdProfile';
+
+describe('TikTok bridge', () => {
+ it('uses late host installation and releases page visibility handlers', () => {
+ const window: any = {}, callbacks = new Set<() => void>();
+ const document = { hidden: false,
+ addEventListener: (_: string, fn: () => void) => callbacks.add(fn),
+ removeEventListener: (_: string, fn: () => void) => callbacks.delete(fn) };
+ new Function('window', 'document', tiktokPlayableProfile.emitBridge!({ title: 'T', orientation: 'portrait' }))(window, document);
+ expect(() => window.__ESTELLA_PLAYABLE__.cta()).not.toThrow();
+ window.openAppStore = vi.fn(); window.__ESTELLA_PLAYABLE__.cta();
+ expect(window.openAppStore).toHaveBeenCalledOnce();
+ const active = vi.fn(), release = window.__ESTELLA_PLAYABLE__.onActive(active);
+ expect(active).toHaveBeenLastCalledWith(true);
+ document.hidden = true; callbacks.forEach(fn => fn()); expect(active).toHaveBeenLastCalledWith(false);
+ document.hidden = false; callbacks.forEach(fn => fn()); expect(active).toHaveBeenLastCalledWith(true);
+ release(); expect(callbacks.size).toBe(0);
+ });
+});
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 1bf31381b..d28b3b330 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -28,6 +28,8 @@ export const NOTES_FLOOR = 'v0.65.0';
* the reader recognises anyway.
*/
export const NOTED = {
+ 'feat(playable): package TikTok and overseas Pangle creatives':
+ { note: 'TikTok and overseas Pangle package the same playable project.' },
'fix(ui): keep pointer carets outside surrogate pairs':
{ note: 'Pointer carets keep supplementary characters intact.' },
'fix(ui): deliver native text input events within the UI frame':