Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,28 @@
}
],
[
"expo-av",
"expo-notifications",
{
"microphonePermission": "Allow AppFromAI to record audio through enabled modules."
"icon": "./assets/icon.png",
"color": "#111827"
}
],
"expo-web-browser",
[
"expo-notifications",
"expo-audio",
{
"icon": "./assets/icon.png",
"color": "#111827"
"microphonePermission": "Allow AppFromAI to record audio through enabled modules."
}
],
"expo-web-browser"
"expo-asset",
[
"expo-image-picker",
{
"cameraPermission": "Allow AppFromAI to open the camera for photo modules.",
"photosPermission": "Allow AppFromAI to use photos selected by enabled modules.",
"microphonePermission": false
}
]
],
"extra": {
"router": {}
Expand Down
16 changes: 15 additions & 1 deletion app/module/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ export default function ModuleScreen() {
});
}, [mod, grantedIds, registry]);

const webGameAllowNetwork = useMemo(() => {
if (!mod) return false;
return (
isModuleNetworkFetchEnabled() &&
mod.manifest.permissions.includes('network') &&
grantedIds.includes('network')
);
}, [mod, grantedIds]);

// ── Regen handler ─────────────────────────────────────────────────────────
const onRegenConfirm = async () => {
if (!mod || !id) return;
Expand Down Expand Up @@ -258,7 +267,12 @@ export default function ModuleScreen() {
/>
) : motherApi ? (
<View style={[styles.body, isTablet && styles.bodyTablet]}>
<DynamicRenderer ui={mod.ui} code={mod.code} motherApi={motherApi} />
<DynamicRenderer
ui={mod.ui}
code={mod.code}
motherApi={motherApi}
webGameAllowNetwork={webGameAllowNetwork}
/>
</View>
) : null}

Expand Down
128 changes: 97 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"lint": "npm run typecheck && node scripts/lint-no-debug.js"
},
"dependencies": {
"@expo/vector-icons": "^15.1.1",
Expand All @@ -16,13 +17,15 @@
"axios": "^1.15.2",
"babel-preset-expo": "~54.0.10",
"expo": "~54.0.33",
"expo-av": "~16.0.8",
"expo-asset": "~12.0.13",
"expo-audio": "~1.1.1",
"expo-camera": "~17.0.10",
"expo-clipboard": "~8.0.8",
"expo-constants": "~18.0.13",
"expo-document-picker": "~14.0.8",
"expo-file-system": "~19.0.22",
"expo-haptics": "~15.0.8",
"expo-image-picker": "~17.0.11",
"expo-linking": "~8.0.11",
"expo-location": "~19.0.8",
"expo-notifications": "~0.32.16",
Expand Down
13 changes: 9 additions & 4 deletions src/ai/aiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,19 @@ Rispondi SOLO con un oggetto JSON valido. Nessun markdown, nessun testo extra.
La radice deve avere ESATTAMENTE queste chiavi: "manifest", "ui", "code".

Schema obbligatorio:
{"manifest":{"id":"id-minuscolo","name":"Nome","version":"1.0.0","runtime":"javascript","permissions":[],"entry":"logic.js","ui":"ui.json"},"ui":{"type":"screen","title":"Nome","components":[{"type":"gameView","id":"game","bind":"scene","width":320,"height":420,"tickMs":60,"tickAction":"onTick","onTapAction":"onTap"}]},"code":"module.exports={actions:{async onTick(api,input,state){return{scene:[]};},async onTap(api,input,state){return{};}}};" }
{"manifest":{"id":"id-minuscolo","name":"Nome","version":"1.0.0","runtime":"javascript","permissions":[],"entry":"logic.js","ui":"ui.json"},"ui":{"type":"screen","title":"Nome","gap":0,"theme":{"bg":"#000"},"components":[{"type":"webGame","id":"game","width":360,"height":600}]},"code":"GameKit.startPlatformer({gravityY:0.65,width:WIDTH,height:HEIGHT,controls:{speed:3.2,jumpPower:12},levels:[{name:'Livello 1',player:{id:'player',x:30,y:470,w:26,h:32},goal:{x:310,y:486,w:30,h:46},bodies:[{id:'floor',x:0,y:552,w:360,h:48,static:true},{id:'coin1',tag:'coin',sensor:true,static:true,solid:false,type:'circle',x:150,y:510,r:8,color:'#facc15'}]},{name:'Livello 2',player:{id:'player',x:30,y:470,w:26,h:32},goal:{x:315,y:390,w:28,h:52},bodies:[{id:'floor',x:0,y:552,w:360,h:48,static:true},{id:'p1',x:120,y:472,w:80,h:18,static:true},{id:'hazard',tag:'hazard',sensor:true,static:true,solid:false,x:230,y:536,w:44,h:16,color:'#ef4444'}]}]});" }

Regole critiche per gameView:
- onTick MAX 10 righe. Usa Math.min/Math.max per bounds, MAI if chains ripetuti.
Regole critiche per webGame:
- Il code è browser JavaScript, NON module.exports. Usa requestAnimationFrame.
- Per giochi platform/action usa GameKit.startPlatformer: include fisica, collisioni, livelli, HUD, transizioni, particelle, score e restart.
- Non usare mai link Markdown nel code: scrivi state.x non [state.x](http://state.x).
- Le action sono sorelle dentro actions separate da virgola.
- Il code è UNA stringa JSON (tutti i \\n e \\" escaped se necessario).

Regole critiche per timer/countdown:
- Nei moduli normali NON usare setInterval/setTimeout nel code.
- Aggiungi in UI { "type":"timer","id":"mainTimer","tickAction":"tick","intervalMs":1000,"activeBind":"running","autoStart":false }.
- Start/pausa/reset sono button action che impostano running e valori numerici; tick restituisce il patch di stato.

Inizio risposta precedente:
${previousContent.slice(0, 400)}

Expand Down
3 changes: 2 additions & 1 deletion src/ai/builtinGameTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ const FLAPPY_CODE =
`const lastX=pipes.length>0?pipes[pipes.length-1].x:0;` +
`if(lastX<W-150)pipes=[...pipes,{x:W,gap:100+Math.floor(Math.random()*220)}];` +
`const pts=parseInt(String(state.score??'0'),10)+pipes.filter(p=>p.x+2>=BX&&p.x<BX).length;` +
`const hit=ny<BR||ny>H-BR||pipes.some(p=>Math.abs(p.x-BX)<BR+20&&(ny<p.gap-GAP||ny>p.gap+GAP));` +
`const HR=9;const cr=(cx,cy,r,rx,ry,rw,rh)=>{const nx=Math.max(rx,Math.min(cx,rx+rw)),ny2=Math.max(ry,Math.min(cy,ry+rh)),dx=cx-nx,dy=cy-ny2;return dx*dx+dy*dy<r*r;};` +
`const hit=ny<HR||ny>H-BR||pipes.some(p=>cr(BX,ny,HR,p.x-20,0,40,Math.max(0,p.gap-GAP))||cr(BX,ny,HR,p.x-20,p.gap+GAP,40,H));` +
`const scene=[{type:'rect',x:0,y:0,w:W,h:H,color:'#70c5ce'}];` +
`pipes.forEach(p=>{` +
`scene.push({type:'rect',x:p.x-20,y:0,w:40,h:Math.max(0,p.gap-GAP),color:'#5d8a3c'});` +
Expand Down
Loading
Loading