diff --git a/.sampo/changesets/roguish-iceseeker-marjatta.md b/.sampo/changesets/roguish-iceseeker-marjatta.md new file mode 100644 index 00000000..dc15a82b --- /dev/null +++ b/.sampo/changesets/roguish-iceseeker-marjatta.md @@ -0,0 +1,6 @@ +--- +npm/@mpgd/cli: patch (Changed) +--- + +Update generated Apps in Toss wrappers to @ait-co/devtools 0.1.139 and preserve its +official SDK mock when Vite prebundles the Kit adapter. diff --git a/apps/target-ait/package.json b/apps/target-ait/package.json index 4243fcd5..ba8a6ad9 100644 --- a/apps/target-ait/package.json +++ b/apps/target-ait/package.json @@ -23,7 +23,7 @@ "@mpgd/adapter-ait": "workspace:*" }, "devDependencies": { - "@ait-co/devtools": "^0.1.138", + "@ait-co/devtools": "^0.1.139", "@apps-in-toss/cli": "^2.10.6", "@ttsc/unplugin": "0.18.4", "@types/node": "^24.0.0", diff --git a/apps/target-ait/vite.config.ts b/apps/target-ait/vite.config.ts index 054f9db1..1e19d6c6 100644 --- a/apps/target-ait/vite.config.ts +++ b/apps/target-ait/vite.config.ts @@ -14,27 +14,44 @@ const aitDevtoolsTunnel = isTruthyEnv(process.env.AIT_TUNNEL) const aitAppName = process.env.MPGD_AIT_APP_NAME?.trim() || 'mpgd-kit'; const aitAdConfig = readAitAdConfig(process.env.MPGD_AD_PLACEMENTS_FILE); -export default defineConfig(({ command, isPreview }) => ({ - define: { - __MPGD_AIT_APP_NAME__: JSON.stringify(aitAppName), - __MPGD_AIT_AD_GROUP_IDS__: JSON.stringify(aitAdConfig.adGroupIds), - __MPGD_AIT_AD_PLACEMENT_TYPES__: JSON.stringify(aitAdConfig.adPlacementTypes), - }, - plugins: [ - ...(command === 'serve' && !isPreview && process.env.MPGD_AIT_DEVTOOLS !== '0' - ? [aitDevtools.vite({ mcp: true, tunnel: aitDevtoolsTunnel })] - : []), - ttsc({ - project: 'tsconfig.bundle.json', - plugins: false, - }), - ], - build: { - target: 'es2022', - outDir: 'dist', - emptyOutDir: true, - }, -})); +export default defineConfig(({ command, isPreview }) => { + const enableAitDevtools = command === 'serve' + && !isPreview + && process.env.MPGD_AIT_DEVTOOLS !== '0'; + + return { + define: { + __MPGD_AIT_APP_NAME__: JSON.stringify(aitAppName), + __MPGD_AIT_AD_GROUP_IDS__: JSON.stringify(aitAdConfig.adGroupIds), + __MPGD_AIT_AD_PLACEMENT_TYPES__: JSON.stringify(aitAdConfig.adPlacementTypes), + }, + // Vite prebundles the Kit host before plugin resolve hooks run. An explicit development + // alias keeps that optimized host while replacing its transitive native SDK import. + ...(enableAitDevtools + ? { + resolve: { + alias: { + '@apps-in-toss/web-framework': '@ait-co/devtools/mock', + }, + }, + } + : {}), + plugins: [ + ...(enableAitDevtools + ? [aitDevtools.vite({ mcp: true, tunnel: aitDevtoolsTunnel })] + : []), + ttsc({ + project: 'tsconfig.bundle.json', + plugins: false, + }), + ], + build: { + target: 'es2022', + outDir: 'dist', + emptyOutDir: true, + }, + }; +}); function readAitAdConfig(path: string | undefined): { readonly adGroupIds: Readonly>; diff --git a/packages/cli/templates/phaser-game/apps/target-ait/package.json b/packages/cli/templates/phaser-game/apps/target-ait/package.json index 5f76d129..c48ff31d 100644 --- a/packages/cli/templates/phaser-game/apps/target-ait/package.json +++ b/packages/cli/templates/phaser-game/apps/target-ait/package.json @@ -22,7 +22,7 @@ "@mpgd/adapter-ait": "__MPGD_DEPENDENCY_VERSION_ADAPTER_AIT__" }, "devDependencies": { - "@ait-co/devtools": "^0.1.138", + "@ait-co/devtools": "^0.1.139", "@apps-in-toss/cli": "^2.10.6", "@ttsc/unplugin": "0.18.4", "@types/node": "^24.0.0", diff --git a/packages/cli/templates/phaser-game/apps/target-ait/vite.config.ts b/packages/cli/templates/phaser-game/apps/target-ait/vite.config.ts index ca8b557a..b4a109e5 100644 --- a/packages/cli/templates/phaser-game/apps/target-ait/vite.config.ts +++ b/packages/cli/templates/phaser-game/apps/target-ait/vite.config.ts @@ -13,24 +13,41 @@ const aitDevtoolsTunnel = isTruthyEnv(process.env.AIT_TUNNEL) const aitAppName = process.env.MPGD_AIT_APP_NAME?.trim() || '__GAME_NAME__'; const aitAdConfig = readAitAdConfig(process.env.MPGD_AD_PLACEMENTS_FILE); -export default defineConfig(({ command, isPreview }) => ({ - define: { - __MPGD_AIT_APP_NAME__: JSON.stringify(aitAppName), - __MPGD_AIT_AD_GROUP_IDS__: JSON.stringify(aitAdConfig.adGroupIds), - __MPGD_AIT_AD_PLACEMENT_TYPES__: JSON.stringify(aitAdConfig.adPlacementTypes), - }, - plugins: [ - ...(command === 'serve' && !isPreview && process.env.MPGD_AIT_DEVTOOLS !== '0' - ? [aitDevtools.vite({ mcp: true, tunnel: aitDevtoolsTunnel })] - : []), - ttsc({ project: 'tsconfig.json', plugins: false }), - ], - build: { - target: 'es2022', - outDir: 'dist', - emptyOutDir: true, - }, -})); +export default defineConfig(({ command, isPreview }) => { + const enableAitDevtools = command === 'serve' + && !isPreview + && process.env.MPGD_AIT_DEVTOOLS !== '0'; + + return { + define: { + __MPGD_AIT_APP_NAME__: JSON.stringify(aitAppName), + __MPGD_AIT_AD_GROUP_IDS__: JSON.stringify(aitAdConfig.adGroupIds), + __MPGD_AIT_AD_PLACEMENT_TYPES__: JSON.stringify(aitAdConfig.adPlacementTypes), + }, + // Vite prebundles the Kit host before plugin resolve hooks run. An explicit development + // alias keeps that optimized host while replacing its transitive native SDK import. + ...(enableAitDevtools + ? { + resolve: { + alias: { + '@apps-in-toss/web-framework': '@ait-co/devtools/mock', + }, + }, + } + : {}), + plugins: [ + ...(enableAitDevtools + ? [aitDevtools.vite({ mcp: true, tunnel: aitDevtoolsTunnel })] + : []), + ttsc({ project: 'tsconfig.json', plugins: false }), + ], + build: { + target: 'es2022', + outDir: 'dist', + emptyOutDir: true, + }, + }; +}); function readAitAdConfig(path: string | undefined): { readonly adGroupIds: Readonly>; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 13618b8b..63f83b64 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -272,8 +272,8 @@ importers: version: link:../../adapters/ait devDependencies: '@ait-co/devtools': - specifier: ^0.1.138 - version: 0.1.138(ddacffd1360e345338f8069a3f016ad5) + specifier: ^0.1.139 + version: 0.1.139(ddacffd1360e345338f8069a3f016ad5) '@apps-in-toss/cli': specifier: ^2.10.6 version: 2.10.6(@babel/core@7.29.7)(@babel/preset-env@7.28.5(@babel/core@7.29.7))(@react-navigation/native@7.2.2(react-native@0.72.6(@babel/core@7.29.7)(@babel/preset-env@7.28.5(@babel/core@7.29.7))(react@18.2.0))(react@18.2.0))(@swc/helpers@0.5.23)(@types/node@24.13.2)(react-native-safe-area-context@5.6.2(react-native@0.72.6(@babel/core@7.29.7)(@babel/preset-env@7.28.5(@babel/core@7.29.7))(react@18.2.0))(react@18.2.0))(react-native-screens@4.23.0(react-native@0.72.6(@babel/core@7.29.7)(@babel/preset-env@7.28.5(@babel/core@7.29.7))(react@18.2.0))(react@18.2.0))(react-native@0.72.6(@babel/core@7.29.7)(@babel/preset-env@7.28.5(@babel/core@7.29.7))(react@18.2.0))(react@18.2.0)(typanion@3.14.0)(typescript@7.0.2) @@ -858,8 +858,8 @@ importers: packages: - '@ait-co/devtools@0.1.138': - resolution: {integrity: sha512-JQw8HmS+iY+gWwSffQBunpiL8BQijspKEq34KS4IP9dbiOscHL8/T1ArOTHRcVDeqQ3jdM7WuqCwbdOTQKRf+Q==} + '@ait-co/devtools@0.1.139': + resolution: {integrity: sha512-8+nkm/mJxXajkRjt/YJqHbMdVm8UkDV1NeTPaUR57Lx1w1Xu9BhguFX3cdzGpdyhRohMajoM59mz13FwaVF2wQ==} engines: {node: '>=24'} hasBin: true peerDependencies: @@ -9825,7 +9825,7 @@ packages: snapshots: - '@ait-co/devtools@0.1.138(ddacffd1360e345338f8069a3f016ad5)': + '@ait-co/devtools@0.1.139(ddacffd1360e345338f8069a3f016ad5)': dependencies: '@modelcontextprotocol/sdk': 1.29.0(zod@4.4.3) '@vitest/expect': 4.1.9 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index dff260e9..1d1a73c4 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -62,4 +62,4 @@ minimumReleaseAgeExclude: - '@devvit/web-view-scripts@0.13.8' - '@devvit/web@0.13.8' - devvit@0.13.8 - - '@ait-co/devtools@0.1.138' + - '@ait-co/devtools@0.1.139' diff --git a/tools/validate-starter-workflow.ts b/tools/validate-starter-workflow.ts index 10bb9c57..8cae2f9e 100644 --- a/tools/validate-starter-workflow.ts +++ b/tools/validate-starter-workflow.ts @@ -989,6 +989,7 @@ function validatePhaserTemplateAITWrapper(): void { "from '@ait-co/devtools/unplugin'", "from '@mpgd/adapter-ait/ad-config'", 'aitDevtools.vite({ mcp: true', + "'@apps-in-toss/web-framework': '@ait-co/devtools/mock'", '__MPGD_AIT_AD_GROUP_IDS__', '__MPGD_AIT_AD_PLACEMENT_TYPES__', ]) {