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(templates): add WeChat gameplay and host-service starter

yhh362e77943b6e
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index aeff81919..3a79cbbef 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -50,6 +50,11 @@ jobs:
with:
name: wasm-web
path: build/wasm/web/
+ - name: Download this commit's WeChat runtime
+ uses: actions/download-artifact@v8
+ with:
+ name: wasm-wechat
+ path: build/wasm/wechat/
- name: Build the shipping SDK
run: pnpm --filter ./sdk build
- name: Install headless Chromium
@@ -70,6 +75,11 @@ jobs:
node pipeline/bin/estella.mjs export templates/playable-ad --profile "$playable_network" --wasm build/wasm/web --out "output/playable-template-ci-export-$playable_network" --json "output/playable-template-ci-export-$playable_network.json" || exit 1
node tools/verify-playable.mjs "output/playable-template-ci-export-$playable_network/index.html" --report "output/playable-template-ci-export-$playable_network.json" --scenario templates/playable-ad/playable-check.json --out "output/playable-template-ci-check-$playable_network" --store-url https://example.com/store || exit 1
done
+ - name: Check WeChat starter gameplay and host outcomes in a contract host
+ run: |
+ node pipeline/bin/estella.mjs export templates/wechat-minigame --profile wechat --wasm build/wasm/wechat --out output/wechat-starter-ci-production --json output/wechat-starter-ci-production.json
+ node tools/tests/export-wechat-starter-fixture.mjs --wasm build/wasm/wechat --out output/wechat-starter-ci-fixture
+ node tools/tests/wechat-starter.e2e.mjs --dir output/wechat-starter-ci-fixture --out output/wechat-starter-ci-check
- name: Check authored Poki gameplay and the standalone example in SDK mocks
run: |
node pipeline/bin/estella.mjs export examples/mobile-controls --profile poki --wasm build/wasm/web --out output/poki-training-ci-export --json output/poki-training-ci-export.json
@@ -131,6 +141,13 @@ jobs:
name: playable-template-local-mock-checks
path: output/playable-template-ci-*
retention-days: 3
+ - name: Upload WeChat starter contract-host observations
+ if: always()
+ uses: actions/upload-artifact@v7
+ with:
+ name: wechat-starter-contract-checks
+ path: output/wechat-starter-ci-*
+ retention-days: 3
# The engine binaries, and nothing else: every gate below waits on this job, so
# a step here that no downstream job reads is a delay on all of them.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c73b28a3e..3dfa6234d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,8 @@ published separately; it ships inside the editor.
### Added
+- **The WeChat Mini Game starter combines gameplay and host-service examples.** A CC0 fleet game includes honest login-code/server-exchange status, sharing without false completion rewards, opt-in configured rewarded video and device-local credit restoration. Unreadable or changed saves are preserved. Named Web/WeChat profiles, compressed engine subpackaging, licenses and a creation-to-submission guide are included; real accounts, server authentication and device/platform approval remain separate.
+
- **The Playable Ad starter includes a complete editable game.** New projects receive CC0 space art, three-ship selection, completion, replay and an explicit store button instead of a tap-anywhere redirect. Eight named network profiles, a configurable MRAID destination, licenses, a portrait/landscape headless scenario and a creation-to-submission guide ship together. Local mocks and size checks remain separate from official network approval and external publication exercises.
- **YouTube headless checks enforce the documented hosting policy.** Training runs under the official CSP response header as well as its exported policy. Unexpected violations fail the check; an intentionally blocked external request proves that enforcement and reporting work. The publishing guide links the independent official bundle analyzer. SDK Test Suite and device acceptance remain separate.
diff --git a/docs/astro/src/content/docs/publishing/wechat.mdx b/docs/astro/src/content/docs/publishing/wechat.mdx
index 9ee44e857..d33a9b05b 100644
--- a/docs/astro/src/content/docs/publishing/wechat.mdx
+++ b/docs/astro/src/content/docs/publishing/wechat.mdx
@@ -143,6 +143,16 @@ levels download on demand rather than bloating the initial package:
## See also
+The **WeChat Mini Game** starter in the launcher includes a CC0 fleet game,
+login-code/server-exchange hook, share request, configured rewarded video and
+device-local saved credits. Follow its copied `README.md` to create, customize,
+export and submit. Its named `wechat` profile enables compressed engine
+subpackaging; its `web` profile offers local gameplay with unavailable host
+buttons disabled. Set your own ad unit and server integration in `src/config.ts`.
+No AppSecret or sample account is shipped. Login codes are not authenticated
+identity, share requests do not prove completion, and saved credits are not cloud
+backup. Validate your real account, backend, ads and devices separately.
+
- [Assets](/docs/assets/overview/) — addressable groups and cooking map onto subpackages.
- [Building & Exporting](/docs/publishing/overview/) — the Package Project dialog.
- [Video](/docs/graphics/video/) — the MPEG-1 wasm decode path shipped for WeChat.
diff --git a/docs/astro/src/content/docs/zh-cn/publishing/wechat.mdx b/docs/astro/src/content/docs/zh-cn/publishing/wechat.mdx
index 8e2031c56..c03ddaf77 100644
--- a/docs/astro/src/content/docs/zh-cn/publishing/wechat.mdx
+++ b/docs/astro/src/content/docs/zh-cn/publishing/wechat.mdx
@@ -109,6 +109,14 @@ node build-tools/cli.js build -t wechat-glx
## 参见
+启动器的 **WeChat Mini Game** 模板包含 CC0 选船小关卡、登录码/服务器交换
+扩展点、分享请求、配置后启用的激励视频和设备本地积分。按复制后的
+`README.md` 完成创建、改造、导出与提交。`wechat` 导出档启用引擎分包与
+压缩 WASM;`web` 导出档可在本地游玩,并禁用不可用的宿主按钮。
+在 `src/config.ts` 配置自己的广告单元与服务器交换,不把 AppSecret 放进项目。
+取得登录码不等于认证,分享请求不证明完成,本地积分也不是云备份;
+真实账号、后端、广告和设备仍需分别验收。
+
- [资源](/docs/zh-cn/assets/overview/) —— 可寻址分组与 cook 映射到分包。
- [构建与导出](/docs/zh-cn/publishing/overview/) —— Package Project 对话框。
- [视频](/docs/zh-cn/graphics/video/) —— 为微信随包发布的 MPEG-1 wasm 解码路径。
diff --git a/templates/wechat-minigame/ASSET_LICENSES.md b/templates/wechat-minigame/ASSET_LICENSES.md
new file mode 100644
index 000000000..77ff78645
--- /dev/null
+++ b/templates/wechat-minigame/ASSET_LICENSES.md
@@ -0,0 +1,37 @@
+# Asset licenses
+
+`thumbnail.png` is a headless in-engine capture of this template using the CC0
+images below. It is not a photograph or separately downloaded artwork.
+
+`assets/textures/ship_K.png`, `star_tiny.png`, and `station_C.png` are unmodified default-resolution images from Kenney Simple Space 1.0.
+
+- Source: https://kenney.nl/assets/simple-space
+- License: https://creativecommons.org/publicdomain/zero/1.0/
+
+
+
+## Original license
+
+```text
+Simple Space
+
+ Created/distributed by Kenney (www.kenney.nl)
+ Creation date: 03-03-2021
+
+ ------------------------------
+
+ License: (Creative Commons Zero, CC0)
+ http://creativecommons.org/publicdomain/zero/1.0/
+
+ This content is free to use in personal, educational and commercial projects.
+
+ Support us by crediting Kenney or www.kenney.nl (this is not mandatory)
+
+ ------------------------------
+
+ Donate: http://support.kenney.nl
+ Patreon: http://patreon.com/kenney/
+
+ Follow on Twitter for updates:
+ http://twitter.com/KenneyNL
+```
diff --git a/templates/wechat-minigame/README.md b/templates/wechat-minigame/README.md
new file mode 100644
index 000000000..4671b145f
--- /dev/null
+++ b/templates/wechat-minigame/README.md
@@ -0,0 +1,53 @@
+# WeChat Mini Game starter
+
+Select the three ships, replay the round, request login, share a card or opt in
+to a rewarded video. CC0 artwork and its original license are included in
+[ASSET_LICENSES.md](ASSET_LICENSES.md). The scene and scripts are editable.
+
+Choose **WeChat Mini Game** in the launcher's Templates gallery to copy this
+project. `src/config.ts` contains your rewarded-video ad unit and share title.
+The ad unit is deliberately empty until you configure your own; its button is
+disabled. Web preview also disables unavailable login, share and ad capabilities.
+
+`Identity.login()` yields a short-lived code. Implement `exchangeLoginCode` in
+`src/config.ts` to send it to your own HTTPS server. Return true only after that
+server authenticates the session. Keep the AppSecret on the server. The default
+implementation reports that a code was received and server integration is still
+required; it never claims the player is signed in or saves/logs their code.
+
+Share requests do not report whether the player actually shared. The template
+shows that uncertainty and never grants share rewards. Only a completed rewarded
+video grants a credit. Credits save on this device and restore on reload;
+unreadable or externally changed saves are preserved, and failed writes leave
+earned progress in session. This is not cloud backup or cross-account progress.
+
+From the engine repository, replace the project path with your new project:
+
+Install/build the matching runtime first. A source checkout builds the WeChat
+runtime with `node build-tools/cli.js build -t wechat` and the Web runtime with
+`node build-tools/cli.js build -t web`; an ES-module Web glue file cannot be used
+as a WeChat engine. The packaged editor offers the corresponding runtime in
+Package Project. Use `--wasm /path/to/matching-runtime` for an explicit CLI runtime.
+
+```sh
+node pipeline/bin/estella.mjs export /path/to/project --profile wechat --out output/my-wechat --json output/my-wechat.json
+node pipeline/bin/estella.mjs export /path/to/project --profile web --out output/my-web --json output/my-web.json
+```
+
+The WeChat profile puts the engine in a startup subpackage and compresses WASM
+to `.wasm.br`. Use WeChat base library 2.14.0 or newer for compressed WASM and
+set the minimum version in your console. The exported size report separates
+initial and subpackage bytes. Review its budget verdicts before publishing.
+Use your real AppID and valid ad unit in WeChat DevTools and campaign settings;
+no account credentials or unrelated sample identifiers are shipped.
+
+Keep the Canvas, Score and Ship 1/2/3 scene names or update their script lookup.
+The responsive Canvas is square, while packaging requests portrait orientation.
+Re-skin in the scene and replace the CC0 artwork with licensed assets as needed.
+
+Before release, verify login with your server, valid-domain configuration,
+share UI, completed/cancelled/failed rewarded videos, local save reload, subpackage
+failure, startup progress and device orientation in DevTools and on real phones.
+Local contract hosts and unit tests cannot certify WeChat's actual base library,
+ad inventory, server authentication or device acceptance. Independent external
+developer publication exercises remain a separate roadmap acceptance step.
diff --git a/templates/wechat-minigame/assets/scenes/main.esscene b/templates/wechat-minigame/assets/scenes/main.esscene
index 299802906..1b2a33871 100644
--- a/templates/wechat-minigame/assets/scenes/main.esscene
+++ b/templates/wechat-minigame/assets/scenes/main.esscene
@@ -7,6 +7,7 @@
"name": "Camera",
"parent": null,
"children": [],
+ "visible": true,
"components": [
{
"type": "Transform",
@@ -22,21 +23,50 @@
"type": "Camera",
"data": {
"projectionType": 1,
- "orthoSize": 667.0,
+ "orthoSize": 300,
"isActive": true,
"priority": 0
}
}
- ],
- "visible": true
+ ]
},
{
"id": 1,
"name": "Canvas",
"parent": null,
"children": [
- 2
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12,
+ 13,
+ 14,
+ 15,
+ 16,
+ 17,
+ 18,
+ 19,
+ 20,
+ 21,
+ 22,
+ 23,
+ 24,
+ 25,
+ 26,
+ 27,
+ 28,
+ 29,
+ 30,
+ 31
],
+ "visible": true,
"components": [
{
"type": "Transform",
@@ -46,33 +76,24 @@
"type": "Canvas",
"data": {
"designResolution": {
- "x": 750,
- "y": 1334
+ "x": 600,
+ "y": 600
},
- "scaleMode": 2,
- "backgroundColor": {
- "r": 0.07,
- "g": 0.08,
- "b": 0.11,
- "a": 1
- }
+ "scaleMode": 2
}
},
{
"type": "UINode",
"data": {}
}
- ],
- "visible": true
+ ]
},
{
"id": 2,
- "name": "Center",
+ "name": "Space backdrop",
"parent": 1,
- "children": [
- 3,
- 4
- ],
+ "children": [],
+ "visible": true,
"components": [
{
"type": "Transform",
@@ -82,52 +103,183 @@
"type": "UINode",
"data": {
"position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 0
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 0
+ },
"width": {
- "value": 80,
- "unit": 1
+ "unit": 1,
+ "value": 100
},
"height": {
- "value": 200,
- "unit": 0
+ "unit": 1,
+ "value": 100
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": 0
},
+ "marginTop": {
+ "unit": 0,
+ "value": 0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 1,
+ "color": {
+ "r": 0.045,
+ "g": 0.065,
+ "b": 0.11,
+ "a": 1
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 3,
+ "name": "Star 00",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
"insetLeft": {
- "value": 50,
- "unit": 1
+ "unit": 1,
+ "value": 5
},
"insetTop": {
- "value": 50,
- "unit": 1
+ "unit": 1,
+ "value": 5
+ },
+ "width": {
+ "unit": 0,
+ "value": 5
+ },
+ "height": {
+ "unit": 0,
+ "value": 5
},
"marginLeft": {
- "value": -40,
- "unit": 1
+ "unit": 0,
+ "value": -2.5
},
"marginTop": {
- "value": -100,
- "unit": 0
+ "unit": 0,
+ "value": -2.5
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
}
}
+ }
+ ]
+ },
+ {
+ "id": 4,
+ "name": "Star 01",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 42
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 28
+ },
+ "width": {
+ "unit": 0,
+ "value": 6
+ },
+ "height": {
+ "unit": 0,
+ "value": 6
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "pointerEvents": 1
+ }
},
{
- "type": "FlexContainer",
+ "type": "UIVisual",
"data": {
- "direction": 1,
- "justifyContent": 1,
- "alignItems": 1,
- "gap": {
- "x": 0,
- "y": 18
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
}
}
}
- ],
- "visible": true
+ ]
},
{
- "id": 3,
- "name": "Title",
- "parent": 2,
+ "id": 5,
+ "name": "Star 02",
+ "parent": 1,
"children": [],
+ "visible": true,
"components": [
{
"type": "Transform",
@@ -136,36 +288,128 @@
{
"type": "UINode",
"data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 79
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 51
+ },
+ "width": {
+ "unit": 0,
+ "value": 7
+ },
"height": {
- "value": 48,
- "unit": 0
+ "unit": 0,
+ "value": 7
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -3.5
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -3.5
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
}
}
+ }
+ ]
+ },
+ {
+ "id": 6,
+ "name": "Star 03",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
},
{
- "type": "Text",
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 26
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 74
+ },
+ "width": {
+ "unit": 0,
+ "value": 8
+ },
+ "height": {
+ "unit": 0,
+ "value": 8
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -4.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -4.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
"data": {
- "content": "WeChat Mini Game",
- "fontSize": 40,
- "bold": true,
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
"color": {
- "r": 1,
- "g": 1,
- "b": 1,
- "a": 1
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
},
- "align": 1,
- "verticalAlign": 1
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
}
}
- ],
- "visible": true
+ ]
},
{
- "id": 4,
- "name": "Hint",
- "parent": 2,
+ "id": 7,
+ "name": "Star 04",
+ "parent": 1,
"children": [],
+ "visible": true,
"components": [
{
"type": "Transform",
@@ -174,29 +418,1587 @@
{
"type": "UINode",
"data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 63
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 7
+ },
+ "width": {
+ "unit": 0,
+ "value": 5
+ },
"height": {
- "value": 28,
- "unit": 0
+ "unit": 0,
+ "value": 5
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -2.5
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -2.5
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
}
}
+ }
+ ]
+ },
+ {
+ "id": 8,
+ "name": "Star 05",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
},
{
- "type": "Text",
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 10
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 30
+ },
+ "width": {
+ "unit": 0,
+ "value": 6
+ },
+ "height": {
+ "unit": 0,
+ "value": 6
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
"data": {
- "content": "Portrait, 750×1334, packaged for the host.",
- "fontSize": 22,
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
"color": {
- "r": 0.65,
+ "r": 0.55,
"g": 0.7,
- "b": 0.78,
- "a": 1
+ "b": 0.9,
+ "a": 0.6
},
- "align": 1,
- "verticalAlign": 1
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
}
}
- ],
- "visible": true
+ ]
+ },
+ {
+ "id": 9,
+ "name": "Star 06",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 47
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 53
+ },
+ "width": {
+ "unit": 0,
+ "value": 7
+ },
+ "height": {
+ "unit": 0,
+ "value": 7
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -3.5
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -3.5
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 10,
+ "name": "Star 07",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 84
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 76
+ },
+ "width": {
+ "unit": 0,
+ "value": 8
+ },
+ "height": {
+ "unit": 0,
+ "value": 8
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -4.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -4.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 11,
+ "name": "Star 08",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 31
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 9
+ },
+ "width": {
+ "unit": 0,
+ "value": 5
+ },
+ "height": {
+ "unit": 0,
+ "value": 5
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -2.5
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -2.5
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 12,
+ "name": "Star 09",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 68
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 32
+ },
+ "width": {
+ "unit": 0,
+ "value": 6
+ },
+ "height": {
+ "unit": 0,
+ "value": 6
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 13,
+ "name": "Star 10",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 15
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 55
+ },
+ "width": {
+ "unit": 0,
+ "value": 7
+ },
+ "height": {
+ "unit": 0,
+ "value": 7
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -3.5
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -3.5
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 14,
+ "name": "Star 11",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 52
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 78
+ },
+ "width": {
+ "unit": 0,
+ "value": 8
+ },
+ "height": {
+ "unit": 0,
+ "value": 8
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -4.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -4.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 15,
+ "name": "Star 12",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 89
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 11
+ },
+ "width": {
+ "unit": 0,
+ "value": 5
+ },
+ "height": {
+ "unit": 0,
+ "value": 5
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -2.5
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -2.5
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 16,
+ "name": "Star 13",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 36
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 34
+ },
+ "width": {
+ "unit": 0,
+ "value": 6
+ },
+ "height": {
+ "unit": 0,
+ "value": 6
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 17,
+ "name": "Star 14",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 73
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 57
+ },
+ "width": {
+ "unit": 0,
+ "value": 7
+ },
+ "height": {
+ "unit": 0,
+ "value": 7
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -3.5
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -3.5
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 18,
+ "name": "Star 15",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 20
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 80
+ },
+ "width": {
+ "unit": 0,
+ "value": 8
+ },
+ "height": {
+ "unit": 0,
+ "value": 8
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -4.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -4.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 19,
+ "name": "Star 16",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 57
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 13
+ },
+ "width": {
+ "unit": 0,
+ "value": 5
+ },
+ "height": {
+ "unit": 0,
+ "value": 5
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -2.5
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -2.5
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 20,
+ "name": "Star 17",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 94
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 36
+ },
+ "width": {
+ "unit": 0,
+ "value": 6
+ },
+ "height": {
+ "unit": 0,
+ "value": 6
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 21,
+ "name": "Star 18",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 41
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 59
+ },
+ "width": {
+ "unit": 0,
+ "value": 7
+ },
+ "height": {
+ "unit": 0,
+ "value": 7
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -3.5
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -3.5
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 22,
+ "name": "Star 19",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 78
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 82
+ },
+ "width": {
+ "unit": 0,
+ "value": 8
+ },
+ "height": {
+ "unit": 0,
+ "value": 8
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -4.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -4.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 23,
+ "name": "Star 20",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 25
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 15
+ },
+ "width": {
+ "unit": 0,
+ "value": 5
+ },
+ "height": {
+ "unit": 0,
+ "value": 5
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -2.5
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -2.5
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 24,
+ "name": "Star 21",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 62
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 38
+ },
+ "width": {
+ "unit": 0,
+ "value": 6
+ },
+ "height": {
+ "unit": 0,
+ "value": 6
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -3.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:037162af-6f6f-4aa8-998a-e8998df36333",
+ "color": {
+ "r": 0.55,
+ "g": 0.7,
+ "b": 0.9,
+ "a": 0.6
+ },
+ "uvOffset": {
+ "x": 0.375,
+ "y": 0.375
+ },
+ "uvScale": {
+ "x": 0.25,
+ "y": 0.25
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 25,
+ "name": "Title",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 50
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 14
+ },
+ "width": {
+ "unit": 0,
+ "value": 560
+ },
+ "height": {
+ "unit": 0,
+ "value": 60
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -280.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -30.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "Text",
+ "data": {
+ "content": "BUILD YOUR SPACE FLEET",
+ "fontSize": 32,
+ "align": 1,
+ "verticalAlign": 1,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 26,
+ "name": "Instructions",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 50
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 26
+ },
+ "width": {
+ "unit": 0,
+ "value": 560
+ },
+ "height": {
+ "unit": 0,
+ "value": 40
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -280.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -20.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "Text",
+ "data": {
+ "content": "Tap all three ships to prepare your fleet.",
+ "fontSize": 24,
+ "align": 1,
+ "verticalAlign": 1,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 27,
+ "name": "Ship 1",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 20
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 45
+ },
+ "width": {
+ "unit": 0,
+ "value": 120
+ },
+ "height": {
+ "unit": 0,
+ "value": 120
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -60.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -60.0
+ }
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:b6845253-c02d-4181-87c9-553cdc015943",
+ "color": {
+ "r": 0.3,
+ "g": 0.85,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "Interactable",
+ "data": {
+ "enabled": true,
+ "blockRaycast": true,
+ "raycastTarget": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 28,
+ "name": "Ship 2",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 50
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 45
+ },
+ "width": {
+ "unit": 0,
+ "value": 120
+ },
+ "height": {
+ "unit": 0,
+ "value": 120
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -60.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -60.0
+ }
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:b6845253-c02d-4181-87c9-553cdc015943",
+ "color": {
+ "r": 0.8,
+ "g": 0.5,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "Interactable",
+ "data": {
+ "enabled": true,
+ "blockRaycast": true,
+ "raycastTarget": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 29,
+ "name": "Ship 3",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 80
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 45
+ },
+ "width": {
+ "unit": 0,
+ "value": 120
+ },
+ "height": {
+ "unit": 0,
+ "value": 120
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -60.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -60.0
+ }
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:b6845253-c02d-4181-87c9-553cdc015943",
+ "color": {
+ "r": 1,
+ "g": 0.7,
+ "b": 0.25,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "Interactable",
+ "data": {
+ "enabled": true,
+ "blockRaycast": true,
+ "raycastTarget": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 30,
+ "name": "Score",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 50
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 62
+ },
+ "width": {
+ "unit": 0,
+ "value": 560
+ },
+ "height": {
+ "unit": 0,
+ "value": 44
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -280.0
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -22.0
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "Text",
+ "data": {
+ "content": "0 / 3 SHIPS READY",
+ "fontSize": 24,
+ "align": 1,
+ "verticalAlign": 1,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 31,
+ "name": "Station",
+ "parent": 1,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": {
+ "unit": 1,
+ "value": 50
+ },
+ "insetTop": {
+ "unit": 1,
+ "value": 69
+ },
+ "width": {
+ "unit": 0,
+ "value": 50
+ },
+ "height": {
+ "unit": 0,
+ "value": 50
+ },
+ "marginLeft": {
+ "unit": 0,
+ "value": -25
+ },
+ "marginTop": {
+ "unit": 0,
+ "value": -25
+ },
+ "pointerEvents": 1
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 2,
+ "texture": "@uuid:8b952ff9-dbbc-4aa0-8ce0-d4290801d633",
+ "color": {
+ "r": 0.6,
+ "g": 0.75,
+ "b": 1,
+ "a": 1
+ }
+ }
+ }
+ ]
}
]
}
diff --git a/templates/wechat-minigame/assets/scenes/main.esscene.meta b/templates/wechat-minigame/assets/scenes/main.esscene.meta
index 2ba514059..84622559f 100644
--- a/templates/wechat-minigame/assets/scenes/main.esscene.meta
+++ b/templates/wechat-minigame/assets/scenes/main.esscene.meta
@@ -1,8 +1,6 @@
{
- "uuid": "9d9b6178-75e7-4ae5-8cc4-1c435f7056e3",
+ "uuid": "eb2cb33e-2677-4097-a1cc-d6c58216c781",
"version": "2.0",
"type": "scene",
- "importer": {
- "autoMigrate": true
- }
+ "importer": {}
}
diff --git a/templates/wechat-minigame/assets/textures/ship_K.png b/templates/wechat-minigame/assets/textures/ship_K.png
new file mode 100644
index 000000000..761a6cc4f
Binary files /dev/null and b/templates/wechat-minigame/assets/textures/ship_K.png differ
diff --git a/templates/wechat-minigame/assets/textures/ship_K.png.meta b/templates/wechat-minigame/assets/textures/ship_K.png.meta
new file mode 100644
index 000000000..bc38f1938
--- /dev/null
+++ b/templates/wechat-minigame/assets/textures/ship_K.png.meta
@@ -0,0 +1,17 @@
+{
+ "uuid": "b6845253-c02d-4181-87c9-553cdc015943",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {
+ "maxSize": 2048,
+ "filterMode": "linear",
+ "wrapMode": "clamp",
+ "premultiplyAlpha": false,
+ "sliceBorder": {
+ "left": 0,
+ "right": 0,
+ "top": 0,
+ "bottom": 0
+ }
+ }
+}
diff --git a/templates/wechat-minigame/assets/textures/star_tiny.png b/templates/wechat-minigame/assets/textures/star_tiny.png
new file mode 100644
index 000000000..c0647535b
Binary files /dev/null and b/templates/wechat-minigame/assets/textures/star_tiny.png differ
diff --git a/templates/wechat-minigame/assets/textures/star_tiny.png.meta b/templates/wechat-minigame/assets/textures/star_tiny.png.meta
new file mode 100644
index 000000000..6b5f8e988
--- /dev/null
+++ b/templates/wechat-minigame/assets/textures/star_tiny.png.meta
@@ -0,0 +1,17 @@
+{
+ "uuid": "037162af-6f6f-4aa8-998a-e8998df36333",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {
+ "maxSize": 2048,
+ "filterMode": "linear",
+ "wrapMode": "clamp",
+ "premultiplyAlpha": false,
+ "sliceBorder": {
+ "left": 0,
+ "right": 0,
+ "top": 0,
+ "bottom": 0
+ }
+ }
+}
diff --git a/templates/wechat-minigame/assets/textures/station_C.png b/templates/wechat-minigame/assets/textures/station_C.png
new file mode 100644
index 000000000..9c7b31ace
Binary files /dev/null and b/templates/wechat-minigame/assets/textures/station_C.png differ
diff --git a/templates/wechat-minigame/assets/textures/station_C.png.meta b/templates/wechat-minigame/assets/textures/station_C.png.meta
new file mode 100644
index 000000000..e87537432
--- /dev/null
+++ b/templates/wechat-minigame/assets/textures/station_C.png.meta
@@ -0,0 +1,17 @@
+{
+ "uuid": "8b952ff9-dbbc-4aa0-8ce0-d4290801d633",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {
+ "maxSize": 2048,
+ "filterMode": "linear",
+ "wrapMode": "clamp",
+ "premultiplyAlpha": false,
+ "sliceBorder": {
+ "left": 0,
+ "right": 0,
+ "top": 0,
+ "bottom": 0
+ }
+ }
+}
diff --git a/templates/wechat-minigame/project.esproject b/templates/wechat-minigame/project.esproject
index b05a034f2..cee435626 100644
--- a/templates/wechat-minigame/project.esproject
+++ b/templates/wechat-minigame/project.esproject
@@ -1,13 +1,17 @@
{
"formatVersion": "1",
"name": "WeChat Mini Game",
- "description": "A portrait project sized and configured for the WeChat host — Build ▸ Package targets the mini-game platform.",
+ "description": "CC0 fleet game with login-code exchange, honest share status, opt-in rewarded video and device-local saved credits.",
"tag": "Starter",
"version": "1.0.0",
"defaultScene": "assets/scenes/main.esscene",
"designResolution": {
- "width": 750,
- "height": 1334
+ "width": 600,
+ "height": 600
},
- "spineVersion": "none"
+ "spineVersion": "none",
+ "packaging": {
+ "orientation": "portrait", "compressWasm": true, "engineSubpackage": true,
+ "profiles": { "wechat": { "platform": "wechat" }, "web": { "platform": "web" } }
+ }
}
diff --git a/templates/wechat-minigame/src/config.ts b/templates/wechat-minigame/src/config.ts
new file mode 100644
index 000000000..b44b2a3cc
--- /dev/null
+++ b/templates/wechat-minigame/src/config.ts
@@ -0,0 +1,5 @@
+/** Your own WeChat rewarded-video unit. Empty disables the button. */
+export const REWARDED_AD_UNIT_ID = '';
+export const SHARE_TITLE = 'Assemble your space fleet!';
+/** Exchange on your server. Never ship an AppSecret, log codes or treat a code as identity. */
+export async function exchangeLoginCode(_code: string): Promise<boolean> { return false; }
diff --git a/templates/wechat-minigame/src/main.ts b/templates/wechat-minigame/src/main.ts
index 4718ff2e8..069b3a124 100644
--- a/templates/wechat-minigame/src/main.ts
+++ b/templates/wechat-minigame/src/main.ts
@@ -1,16 +1,46 @@
-import { addStartupSystem, defineSystem, GetWorld } from 'esengine';
-
-/**
- * A mini-game host starts the game inside its own shell: no window to size, no
- * URL to read, and a launch payload instead of a query string. Nothing here
- * needs it yet — this is where it lands when it does.
- */
-const bootSystem = defineSystem(
- [GetWorld()],
- () => {
- console.log('[wechat] booted — Build > Package builds the mini-game bundle.');
- },
- { name: 'BootSystem' },
-);
-
-addStartupSystem(bootSystem);
+import { addStartupSystem, defineSystem, Res, GetWorld, UIEvents, UIEventType, UIVisual,
+ Interactable, Text, Name, createButton, px, percent, Ads, Identity, Storage,
+ platformCanShare, platformShare } from 'esengine';
+import { REWARDED_AD_UNIT_ID, SHARE_TITLE, exchangeLoginCode } from './config';
+import { StarterState } from './starterState';
+const SAVE_KEY = 'wechat-starter.credits.v1';
+addStartupSystem(defineSystem([Res(UIEvents), Res(Ads), Res(Identity), GetWorld()], (events, ads, identity, world) => {
+ const canvas = world.findEntityByName('Canvas'), score = world.findEntityByName('Score');
+ if (canvas === null || score === null) return;
+ const state = new StarterState({ login: async () => (await identity.login()).code, exchange: exchangeLoginCode,
+ share: () => platformShare({ title: SHARE_TITLE }), reward: () => ads.showRewarded(REWARDED_AD_UNIT_ID),
+ getSave: () => Storage.getString(SAVE_KEY), setSave: value => Storage.setString(SAVE_KEY, value) });
+ const ships = ['Ship 1', 'Ship 2', 'Ship 3'].map(name => world.findEntityByName(name)).filter((id): id is number => id !== null);
+ const colors = ships.map(id => ({ ...world.get(id, UIVisual).color })), selected = new Set<number>();
+ const buttons: Array<{ id: number; available(): boolean }> = [];
+ const refresh = () => {
+ if (!world.valid(score)) return;
+ world.insert(score, Text, { ...world.get(score, Text), fontSize: 16,
+ content: `${selected.size}/3 SHIPS | CREDITS ${state.credits}\n${state.message}` });
+ for (const button of buttons) if (world.valid(button.id)) world.insert(button.id, Interactable,
+ { ...world.get(button.id, Interactable), enabled: !state.busy && button.available() });
+ };
+ for (const id of ships) events.on(id, UIEventType.Click, () => {
+ if (state.busy || selected.has(id)) return; selected.add(id);
+ world.insert(id, Interactable, { ...world.get(id, Interactable), enabled: false });
+ world.insert(id, UIVisual, { ...world.get(id, UIVisual), color: { ...colors[ships.indexOf(id)], a: 0.3 } });
+ state.message = selected.size === 3 ? 'Fleet ready! Replay to assemble again.' : 'Select the remaining ships.'; refresh();
+ });
+ const action = (name: string, left: number, available: () => boolean, run: () => void | Promise<void>) => {
+ const button = createButton({ world, events, parent: canvas, userGesture: true,
+ node: { position: 1, insetLeft: percent(left), insetTop: percent(77), width: percent(28), height: px(48) },
+ text: { content: name.toUpperCase() + (available() ? '' : ' OFF'), fontSize: 18 },
+ onClick: () => { if (state.busy || !available()) return; const pending = run(); refresh(); void Promise.resolve(pending).finally(refresh); } });
+ world.insert(button.entity, Name, { value: name }); buttons.push({ id: button.entity, available });
+ };
+ action('Login', 5, () => identity.available, () => state.login());
+ action('Share', 36, platformCanShare, () => state.share());
+ action('Reward', 67, () => ads.available && REWARDED_AD_UNIT_ID.trim().length > 0, () => state.reward());
+ const replay = createButton({ world, events, parent: canvas,
+ node: { position: 1, insetLeft: percent(30), insetBottom: px(12), width: percent(40), height: px(38) },
+ text: { content: 'PLAY AGAIN', fontSize: 20 }, onClick: () => {
+ if (state.busy) return; selected.clear(); state.message = 'Select three ships to assemble your fleet.';
+ ships.forEach((id, i) => { world.insert(id, Interactable, { ...world.get(id, Interactable), enabled: true }); world.insert(id, UIVisual, { ...world.get(id, UIVisual), color: colors[i] }); }); refresh();
+ } });
+ world.insert(replay.entity, Name, { value: 'Replay' }); refresh();
+}, { name: 'WeChatStarterSetup' }));
diff --git a/templates/wechat-minigame/src/starterState.ts b/templates/wechat-minigame/src/starterState.ts
new file mode 100644
index 000000000..b96fb8188
--- /dev/null
+++ b/templates/wechat-minigame/src/starterState.ts
@@ -0,0 +1,46 @@
+export interface StarterServices {
+ login(): Promise<string>; exchange(code: string): Promise<boolean>;
+ share(): boolean; reward(): Promise<{ completed: boolean }>;
+ getSave(): string | undefined; setSave(value: string): void;
+}
+/** Account identity, share completion and cloud saving cannot be inferred from host requests. */
+export class StarterState {
+ credits = 0; message = 'Select three ships to assemble your fleet.'; busy = false;
+ private writable = false; private snapshot: string | undefined;
+ constructor(private readonly services: StarterServices) {
+ try {
+ const raw = services.getSave(), value = raw === undefined ? { version: 1, credits: 0 } : JSON.parse(raw);
+ if (!value || value.version !== 1 || !Number.isSafeInteger(value.credits) || value.credits < 0
+ || Object.keys(value).some(key => key !== 'version' && key !== 'credits')) throw Error('Invalid save');
+ this.credits = value.credits; this.snapshot = raw; this.writable = true;
+ } catch { this.message = 'Save unreadable; existing progress preserved.'; }
+ }
+ async login(): Promise<void> {
+ if (this.busy) return; this.busy = true; this.message = 'Requesting login...';
+ try {
+ const code = await this.services.login(); if (!code) throw Error('Missing code');
+ this.message = (await this.services.exchange(code)) === true ? 'Your server authenticated the session.' : 'Login code received; connect your server to authenticate.';
+ } catch { this.message = 'Login or server exchange failed. Try again.'; }
+ finally { this.busy = false; }
+ }
+ share(): void {
+ if (this.busy) return;
+ try { this.message = this.services.share() ? 'Share requested; completion cannot be confirmed.' : 'Sharing is unavailable here.'; }
+ catch { this.message = 'Share request failed.'; }
+ }
+ async reward(): Promise<void> {
+ if (this.busy) return; this.busy = true; this.message = 'Waiting for the rewarded video...';
+ try {
+ if ((await this.services.reward()).completed !== true) { this.message = 'Video incomplete; no credit granted.'; return; }
+ if (!Number.isSafeInteger(this.credits + 1)) throw Error('Credit limit');
+ this.credits++; this.message = 'Credit earned for this session.';
+ if (!this.writable) return;
+ try {
+ if (this.services.getSave() !== this.snapshot) { this.writable = false; this.message = 'Saved progress changed; reload before saving.'; return; }
+ const raw = JSON.stringify({ version: 1, credits: this.credits });
+ this.services.setSave(raw); this.snapshot = raw; this.message = 'Credit saved on this device.';
+ } catch { this.message = 'Credit earned; device save failed.'; }
+ } catch { this.message = 'Rewarded video failed; no credit granted.'; }
+ finally { this.busy = false; }
+ }
+}
diff --git a/templates/wechat-minigame/thumbnail.png b/templates/wechat-minigame/thumbnail.png
new file mode 100644
index 000000000..7aa728bcc
Binary files /dev/null and b/templates/wechat-minigame/thumbnail.png differ
diff --git a/templates/wechat-minigame/thumbnail.png.meta b/templates/wechat-minigame/thumbnail.png.meta
new file mode 100644
index 000000000..aaa981b82
--- /dev/null
+++ b/templates/wechat-minigame/thumbnail.png.meta
@@ -0,0 +1,17 @@
+{
+ "uuid": "05fc9020-4f42-4ddb-864e-13c5560407d5",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {
+ "maxSize": 2048,
+ "filterMode": "linear",
+ "wrapMode": "clamp",
+ "premultiplyAlpha": false,
+ "sliceBorder": {
+ "left": 0,
+ "right": 0,
+ "top": 0,
+ "bottom": 0
+ }
+ }
+}
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 6ec916676..a1377cb4d 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(templates): add WeChat gameplay and host-service starter':
+ { note: 'The WeChat Mini Game starter combines gameplay and host-service examples.' },
'feat(templates): ship a complete playable ad starter':
{ note: 'The Playable Ad starter includes a complete editable game.' },
'test(launcher): preserve complete playable starter on creation':
diff --git a/tools/tests/export-wechat-starter-fixture.mjs b/tools/tests/export-wechat-starter-fixture.mjs
new file mode 100644
index 000000000..966d5e415
--- /dev/null
+++ b/tools/tests/export-wechat-starter-fixture.mjs
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+import fs from 'node:fs/promises';import path from 'node:path';import {fileURLToPath} from 'node:url';import {runTool} from '../lib/runTool.mjs';
+const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'../..'),args=process.argv.slice(2),flag=name=>args[args.indexOf(name)+1];
+if(!args.includes('--wasm')||!args.includes('--out'))throw Error('Expected --wasm and --out');
+const temp=await fs.mkdtemp(path.join(root,'output','wechat-fixture-'));
+try{
+ await fs.cp(path.join(root,'templates/wechat-minigame'),temp,{recursive:true,filter:src=>!path.relative(path.join(root,'templates/wechat-minigame'),src).split(path.sep).some(part=>['.esengine','node_modules','dist'].includes(part))});
+ const config=path.join(temp,'src/config.ts');await fs.writeFile(config,(await fs.readFile(config,'utf8')).replace("REWARDED_AD_UNIT_ID = ''","REWARDED_AD_UNIT_ID = 'local-mock-reward-unit'"));
+ const main=path.join(temp,'src/main.ts'),source=await fs.readFile(main,'utf8'),marker="world.insert(replay.entity, Name, { value: 'Replay' }); refresh();";
+ if(!source.includes(marker))throw Error('Starter fixture hook changed');
+ await fs.writeFile(main,source.replace(marker,marker+"\n(globalThis as any).__wxStarterProbe = () => ({ credits: state.credits, message: state.message, busy: state.busy, selected: selected.size });"));
+ const result=runTool(process.execPath,[path.join(root,'pipeline/bin/estella.mjs'),'export',temp,'--profile','wechat','--wasm',path.resolve(flag('--wasm')),'--out',path.resolve(flag('--out')),'--json',path.resolve(flag('--out'))+'.json'],{cwd:root,stdio:'inherit'});
+ if(result.status!==0)throw Error('Fixture export failed');
+}finally{if(!temp.startsWith(path.join(root,'output')+path.sep))throw Error('Unexpected cleanup target');await fs.rm(temp,{recursive:true,force:true,maxRetries:10,retryDelay:50});}
diff --git a/tools/tests/wechat-starter.e2e.mjs b/tools/tests/wechat-starter.e2e.mjs
new file mode 100644
index 000000000..e3abe892f
--- /dev/null
+++ b/tools/tests/wechat-starter.e2e.mjs
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+import fs from 'node:fs';import path from 'node:path';import http from 'node:http';import crypto from 'node:crypto';import assert from 'node:assert/strict';import {chromium} from 'playwright';import {HOST_PAGE} from '../launchers/minigameHost.mjs';
+const args=process.argv.slice(2),flag=name=>args[args.indexOf(name)+1];if(!args.includes('--dir'))throw Error('Expected --dir');
+const root=fs.realpathSync(flag('--dir')),out=path.resolve(args.includes('--out')?flag('--out'):'output/wechat-starter-check');fs.mkdirSync(out,{recursive:true});
+const sha=file=>crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');
+const files=(under='')=>fs.readdirSync(path.join(root,under),{withFileTypes:true}).flatMap(e=>{const name=under?`${under}/${e.name}`:e.name;return e.isDirectory()?files(name):[name];});
+const report={status:'failed',headless:true,mode:'local-contract-host',identities:Object.fromEntries(files().map(file=>[file,sha(path.join(root,file))])),verifierSha256:sha(new URL(import.meta.url)),errors:[],unexpectedRequests:[]};
+let html=HOST_PAGE('game.js');const marker=" try {\n log('booting";
+if(!html.includes(marker))throw Error('Contract host hook changed');
+html=html.replace(marker,` globalThis.__calls={login:0,share:0,reward:0};
+ wx.login=o=>{__calls.login++;queueMicrotask(()=>o.success({code:'local-mock-code'}))};
+ wx.shareAppMessage=()=>{__calls.share++};
+ wx.createRewardedVideoAd=()=>{const close=new Set();return{load:()=>Promise.resolve(),show:()=>{
+ __calls.reward++;if(globalThis.__failReward>0){globalThis.__failReward--;return Promise.reject(new Error('no fill'))}
+ globalThis.__finishReward=ended=>{for(const cb of [...close])cb({isEnded:ended})};return Promise.resolve()},
+ onClose:cb=>close.add(cb),offClose:cb=>close.delete(cb),destroy:()=>close.clear()}};
+`+marker);
+report.hostSha256=crypto.createHash('sha256').update(html).digest('hex');
+const mime={'.js':'text/javascript','.json':'application/json','.png':'image/png','.wasm':'application/wasm'};
+const server=http.createServer((req,res)=>{try{const name=decodeURIComponent(new URL(req.url,'http://localhost').pathname).slice(1);if(!name){res.setHeader('Content-Type','text/html');res.end(html);return;}
+ const file=fs.realpathSync(path.resolve(root,name));if(!file.startsWith(root+path.sep)||!fs.statSync(file).isFile())throw Error('Outside export');
+ res.setHeader('Content-Type',mime[path.extname(file)]??'application/octet-stream');if(file.endsWith('.br'))res.setHeader('Content-Encoding','br');res.end(fs.readFileSync(file));}catch{res.writeHead(404);res.end();}});
+await new Promise(resolve=>server.listen(0,'127.0.0.1',resolve));const origin=`http://127.0.0.1:${server.address().port}`;
+const browser=await chromium.launch({headless:true,args:['--enable-unsafe-swiftshader','--use-angle=swiftshader','--mute-audio']});
+try {
+ const context=await browser.newContext({viewport:{width:360,height:640},hasTouch:true}),page=await context.newPage();
+ page.on('pageerror',error=>report.errors.push(String(error)));page.on('console',message=>{if(message.type()==='error')report.errors.push(message.text());});
+ await context.route('**/*',route=>{if(route.request().url().startsWith(origin+'/'))return route.continue();report.unexpectedRequests.push(route.request().url());return route.abort();});
+ await page.goto(origin+'/');await page.waitForFunction(()=>globalThis.__wxStarterProbe&&globalThis.__estellaLoading===null,{},{timeout:30000});
+ const state=()=>page.evaluate(()=>__wxStarterProbe());const tap=async(x,y)=>{await page.touchscreen.tap(360*x,640*y);};
+ for(const x of [.2,.5,.8])await tap(x,.45);await page.waitForFunction(()=>__wxStarterProbe().selected===3);
+ await tap(.5,.96);await page.waitForFunction(()=>__wxStarterProbe().selected===0);
+ await tap(.19,.81);await page.waitForFunction(()=>__wxStarterProbe().message.includes('connect your server'));assert.equal(await page.evaluate(()=>__calls.login),1);
+ await tap(.5,.81);await page.waitForFunction(()=>__wxStarterProbe().message.includes('cannot be confirmed'));assert.equal((await state()).credits,0);
+ const watch=async ended=>{await tap(.81,.81);await page.waitForFunction(()=>__wxStarterProbe().busy&&typeof __finishReward==='function');await page.evaluate(value=>__finishReward(value),ended);await page.waitForFunction(()=>!__wxStarterProbe().busy);};
+ await watch(false);assert.equal((await state()).credits,0);await watch(true);assert.equal((await state()).credits,1);
+ await page.evaluate(()=>{globalThis.__failReward=2});await tap(.81,.81);await page.waitForFunction(()=>__wxStarterProbe().message.includes('video failed'));assert.equal((await state()).credits,1);
+ await page.reload();await page.waitForFunction(()=>globalThis.__wxStarterProbe&&globalThis.__estellaLoading===null);assert.equal((await state()).credits,1);
+ report.restored=await state();const file='restored.png';await page.screenshot({path:path.join(out,file)});report.screenshot={file,sha256:sha(path.join(out,file))};
+ assert.deepEqual(report.errors,[]);assert.deepEqual(report.unexpectedRequests,[]);report.status='checks-passed';await context.close();
+}finally{fs.writeFileSync(path.join(out,'runtime-check.json'),JSON.stringify(report,null,2));await browser.close();await new Promise(resolve=>server.close(resolve));}
+console.log('WeChat starter: real touch gameplay/login/share/reward cancel/complete/failure/reload passed in headless contract host');
diff --git a/tools/tests/wechat-starter.test.ts b/tools/tests/wechat-starter.test.ts
new file mode 100644
index 000000000..f865fdc42
--- /dev/null
+++ b/tools/tests/wechat-starter.test.ts
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+import { it, expect, vi } from 'vitest';
+import { StarterState } from '../../templates/wechat-minigame/src/starterState';
+function fixture(raw?: string) {
+ let saved = raw;
+ const services = { login: vi.fn(async () => 'short-lived-code'), exchange: vi.fn(async (_code: string) => false),
+ share: vi.fn(() => true), reward: vi.fn(async () => ({ completed: true })),
+ getSave: vi.fn(() => saved), setSave: vi.fn((value: string) => { saved = value; }) };
+ return { services, state: new StarterState(services), external(value: string) { saved = value; } };
+}
+it('requires server exchange before claiming authenticated identity and never saves login codes', async () => {
+ const f = fixture(); await f.state.login(); expect(f.state.message).toContain('connect your server');
+ expect(f.services.exchange).toHaveBeenCalledWith('short-lived-code'); expect(f.services.setSave).not.toHaveBeenCalled();
+ f.services.exchange.mockResolvedValueOnce(true); await f.state.login(); expect(f.state.message).toContain('server authenticated');
+});
+it('handles missing/failed login codes and releases the busy state', async () => {
+ const f = fixture(); f.services.login.mockResolvedValueOnce(''); await f.state.login();
+ expect(f.services.exchange).not.toHaveBeenCalled(); expect(f.state.busy).toBe(false);
+ f.services.login.mockRejectedValueOnce(new Error('offline')); await f.state.login(); expect(f.state.message).toContain('failed');
+});
+it('does not mistake a truthy server payload for confirmed authentication', async () => {
+ const f = fixture(); f.services.exchange.mockResolvedValueOnce('false' as unknown as boolean);
+ await f.state.login(); expect(f.state.message).toContain('connect your server');
+});
+it('share requests never claim completion or grant credits', () => {
+ const f = fixture(); f.state.share(); expect(f.state.message).toContain('cannot be confirmed'); expect(f.state.credits).toBe(0);
+ expect(f.services.setSave).not.toHaveBeenCalled(); f.services.share.mockReturnValueOnce(false); f.state.share(); expect(f.state.message).toContain('unavailable');
+});
+it('grants and restores completed-video credits but does not grant cancelled or failed videos', async () => {
+ const f = fixture(); f.services.reward.mockResolvedValueOnce({ completed: false }); await f.state.reward(); expect(f.state.credits).toBe(0);
+ f.services.reward.mockRejectedValueOnce(new Error('no fill')); await f.state.reward(); expect(f.services.setSave).not.toHaveBeenCalled();
+ await f.state.reward(); expect(f.state.credits).toBe(1); expect(f.state.message).toContain('this device');
+ expect(new StarterState(f.services).credits).toBe(1);
+});
+it('preserves unreadable and externally changed progress', async () => {
+ for (const raw of ['not-json', '{"version":1,"credits":9,"futureField":true}']) {
+ const broken = fixture(raw); await broken.state.reward(); expect(broken.state.credits).toBe(1); expect(broken.services.setSave).not.toHaveBeenCalled();
+ }
+ const changed = fixture(); changed.external('{"version":1,"credits":9}'); await changed.state.reward();
+ expect(changed.services.setSave).not.toHaveBeenCalled(); expect(changed.state.message).toContain('changed');
+});
+it('keeps an earned credit in session when the device cannot save', async () => {
+ const f = fixture(); f.services.setSave.mockImplementationOnce(() => { throw Error('quota'); }); await f.state.reward();
+ expect(f.state.credits).toBe(1); expect(f.state.message).toContain('save failed'); expect(f.state.busy).toBe(false);
+});
+it('does not overlap host operations or award credits while login is pending', async () => {
+ const f = fixture(); let resolve!: (value: string) => void;
+ f.services.login.mockReturnValueOnce(new Promise(r => { resolve = r; })); const pending = f.state.login();
+ await f.state.reward(); await f.state.login(); f.state.share(); expect(f.services.reward).not.toHaveBeenCalled(); expect(f.services.share).not.toHaveBeenCalled();
+ expect(f.services.login).toHaveBeenCalledOnce(); resolve('code'); await pending; expect(f.state.busy).toBe(false);
+});