@tora-editor/tora 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -58
- package/assets/free-audio/arcade-pop/audio/loss.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/reward.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/win.wav +0 -0
- package/assets/free-audio/arcade-pop/source/INFO.txt +11 -11
- package/assets/kenney-food-starter/License.txt +28 -0
- package/assets/kenney-food-starter/burger.glb +0 -0
- package/assets/kenney-food-starter/frying-pan.glb +0 -0
- package/assets/kenney-food-starter/plan.json +61 -0
- package/assets/kenney-food-starter/plate.glb +0 -0
- package/assets/kenney-food-starter/pot.glb +0 -0
- package/assets/kenney-harvest/audio/victory.wav +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_NES/jingles_NES03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_PIZZA/jingles_PIZZA03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/license.txt +14 -0
- package/bin/tora.mjs +322 -28
- package/crates/packer/trusted/native-3d-meta.json +4 -3
- package/crates/packer/trusted/native-3d.js +181 -181
- package/crates/packer/trusted/native-meta.json +3 -3
- package/crates/packer/trusted/native.js +5 -5
- package/crates/packer/trusted/release-manifest.json +17 -17
- package/crates/packer/trusted/review-runtime-meta.json +4 -3
- package/crates/packer/trusted/review-runtime.js +182 -182
- package/docs/MIGRATION_0_3.md +39 -0
- package/docs/NATIVE_AGENT_TOOLS.md +12 -363
- package/docs/TORA_AGENT_SETUP.md +24 -95
- package/docs/TORA_CREATION_API.md +63 -348
- package/docs/reference/CORE_AUTHORING.md +10 -3
- package/docs/reference/PLAYABLE_STARTERS.md +20 -0
- package/docs/reference/packs/3d.md +11 -3
- package/network-rules/mintegral-appgrowth-single-html.json +10 -10
- package/package.json +6 -6
- package/packages/creative-project/project-v21.schema.json +372 -9
- package/scripts/lean/editor/entry.js +11 -6
- package/scripts/lean/editor/project-launcher.js +116 -0
- package/scripts/lean/editor/quick-edit-panel.js +479 -0
- package/scripts/lean/editor/review-editor.css +256 -68
- package/scripts/lean/editor/review-editor.js +1834 -1086
- package/scripts/lean/editor-state.mjs +6 -0
- package/scripts/lean/editor.mjs +6 -3
- package/scripts/lean/matrix.mjs +5 -0
- package/scripts/lean/native/agent-tools.mjs +39 -62
- package/scripts/lean/native/api.mjs +161 -136
- package/scripts/lean/native/asset-catalog.mjs +7 -6
- package/scripts/lean/native/asset-lineage.mjs +54 -0
- package/scripts/lean/native/asset-prep.mjs +173 -40
- package/scripts/lean/native/assets.mjs +107 -11
- package/scripts/lean/native/audio-assets.mjs +30 -0
- package/scripts/lean/native/browser-pool.mjs +34 -0
- package/scripts/lean/native/build-cache.mjs +38 -7
- package/scripts/lean/native/cc0-inputs.mjs +24 -0
- package/scripts/lean/native/cc0-staging.mjs +28 -8
- package/scripts/lean/native/compiler.mjs +9 -3
- package/scripts/lean/native/contracts.mjs +16 -11
- package/scripts/lean/native/creative-qa.mjs +365 -128
- package/scripts/lean/native/demos.mjs +53 -18
- package/scripts/lean/native/document.mjs +50 -12
- package/scripts/lean/native/export-budget.mjs +75 -0
- package/scripts/lean/native/local-bundle.mjs +7 -3
- package/scripts/lean/native/mcp-server.mjs +42 -74
- package/scripts/lean/native/media-validate.mjs +124 -0
- package/scripts/lean/native/modules/harvest-restore.mjs +3 -284
- package/scripts/lean/native/modules/sort-puzzle.mjs +51 -0
- package/scripts/lean/native/modules/star-salvage.mjs +3 -368
- package/scripts/lean/native/native-bin.mjs +3 -3
- package/scripts/lean/native/outcome-playthrough.mjs +97 -0
- package/scripts/lean/native/project-bundle.mjs +6 -5
- package/scripts/lean/native/project-index.mjs +0 -2
- package/scripts/lean/native/qa-adapters.mjs +10 -0
- package/scripts/lean/native/quick-edit.mjs +328 -0
- package/scripts/lean/native/remote-cc0-fetcher.mjs +403 -197
- package/scripts/lean/native/review.mjs +205 -571
- package/scripts/lean/native/schema-vocabulary.mjs +10 -0
- package/scripts/lean/native/schema.mjs +7 -5
- package/scripts/lean/native/scope.mjs +45 -0
- package/scripts/lean/native/service.mjs +378 -79
- package/scripts/lean/native/starters.mjs +563 -0
- package/scripts/lean/native/variant-adapters.mjs +8 -0
- package/scripts/lean/native/variants-core.mjs +186 -0
- package/scripts/lean/native/variants.mjs +63 -0
- package/scripts/lean/native/win-cues.mjs +96 -0
- package/skills/tora-playables/SKILL.md +1 -1
- package/scripts/lean/editor/review-intake.js +0 -837
- package/scripts/lean/model-client.mjs +0 -119
- package/scripts/lean/native/author-expansion-proofs.mjs +0 -240
- package/scripts/lean/native/author-games.mjs +0 -160
- package/scripts/lean/native/author-harvest.mjs +0 -74
- package/scripts/lean/native/author-primitive-proofs.mjs +0 -874
- package/scripts/lean/native/author-salvage.mjs +0 -71
- package/scripts/lean/native/chat-compose.mjs +0 -287
- package/scripts/lean/native/check-harvest-outcome-audio.mjs +0 -191
- package/scripts/lean/native/check-salvage.mjs +0 -197
- package/scripts/lean/native/compatibility.mjs +0 -34
- package/scripts/lean/native/concept.mjs +0 -633
- package/scripts/lean/native/draw-stroke.mjs +0 -26
- package/scripts/lean/native/erase-mask.mjs +0 -18
- package/scripts/lean/native/harvest-recipe.mjs +0 -21
- package/scripts/lean/native/instance-steering.mjs +0 -24
- package/scripts/lean/native/intake-creator-agent.mjs +0 -98
- package/scripts/lean/native/intake-creator-tools.mjs +0 -165
- package/scripts/lean/native/interaction-gestures.mjs +0 -45
- package/scripts/lean/native/match-board.mjs +0 -138
- package/scripts/lean/native/modules/index.mjs +0 -54
- package/scripts/lean/native/modules/tap-collect.mjs +0 -54
- package/scripts/lean/native/path-network.mjs +0 -132
- package/scripts/lean/native/physics-2d.mjs +0 -154
- package/scripts/lean/native/physics-3d.mjs +0 -259
- package/scripts/lean/native/prepare-audio-collections.mjs +0 -112
- package/scripts/lean/native/prepare-game-audio.mjs +0 -372
- package/scripts/lean/native/prepare-golf-3d-assets.py +0 -177
- package/scripts/lean/native/prepare-golf-assets.py +0 -211
- package/scripts/lean/native/prepare-harvest-audio.mjs +0 -83
- package/scripts/lean/native/prepare-harvest-images.mjs +0 -31
- package/scripts/lean/native/prepare-primitive-images.py +0 -25
- package/scripts/lean/native/prepare-space-salvage-images.mjs +0 -89
- package/scripts/lean/native/prepare-traffic-assets.py +0 -329
- package/scripts/lean/native/presentation.mjs +0 -335
- package/scripts/lean/native/review-agent-tools.mjs +0 -561
- package/scripts/lean/native/review-connection.mjs +0 -303
- package/scripts/lean/native/review-fields.mjs +0 -24
- package/scripts/lean/native/review-intake.mjs +0 -385
- package/scripts/lean/native/review-intents.mjs +0 -217
- package/scripts/lean/native/review-provider.mjs +0 -580
- package/scripts/lean/native/review-receipts.mjs +0 -76
- package/scripts/lean/native/review-resolver.mjs +0 -429
- package/scripts/lean/native/review-targets.mjs +0 -35
- package/scripts/lean/native/runtime.mjs +0 -1623
- package/scripts/lean/native/salvage-recipe.mjs +0 -20
- package/scripts/lean/native/stage-3d.mjs +0 -818
- package/scripts/lean/native/verify.mjs +0 -4
- package/scripts/lean/scene-document.mjs +0 -48
|
@@ -7,8 +7,10 @@ import {Buffer} from 'node:buffer';
|
|
|
7
7
|
import {setTimeout} from 'node:timers';
|
|
8
8
|
import process from 'node:process';
|
|
9
9
|
import {loadCatalog} from './catalog-cache.mjs';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import {qaAdapterForProject} from './qa-adapters.mjs';
|
|
11
|
+
import {builtInPlaythrough} from './outcome-playthrough.mjs';
|
|
12
|
+
import {isAudioMime,validateGlbHeader} from './media-validate.mjs';
|
|
13
|
+
import {glbBudgetInfo} from './export-budget.mjs';
|
|
12
14
|
import {getNetworkTarget} from './network-targets.mjs';
|
|
13
15
|
import {IS_SOURCE_CHECKOUT} from '../runtime-paths.mjs';
|
|
14
16
|
|
|
@@ -24,7 +26,7 @@ export const DEFAULT_VIEWPORTS=Object.freeze([
|
|
|
24
26
|
|
|
25
27
|
const stateOrder=['opening','after-first-input','end-card','timeout'];
|
|
26
28
|
const pixelGlyphs=new Set([...'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?.:,+-/\' ']);
|
|
27
|
-
const layoutBlockers=new Set(['stage-overflow','parent-clip-crop','text-overflow','text-illegible','touch-target-small','interactive-overlap','sdk-safe-area-collision','panel-off-center','panel-edge-cramped','backdrop-incomplete','panel-content-overlap','duplicate-visible-copy','header-off-center']);
|
|
29
|
+
const layoutBlockers=new Set(['stage-overflow','parent-clip-crop','text-overflow','text-clipped','rtl-alignment','text-illegible','touch-target-small','interactive-overlap','sdk-safe-area-collision','panel-off-center','panel-edge-cramped','backdrop-incomplete','panel-content-overlap','duplicate-visible-copy','header-off-center','anchor-3d-target-offscreen','anchor-3d-misaligned','anchor-3d-occluded']);
|
|
28
30
|
const roleWords={
|
|
29
31
|
win:['win','won','winner','success','successful','victory','victorious','complete','completed','completion','goal','payoff'],
|
|
30
32
|
loss:['loss','lose','lost','failure','failed','fail','gameover','timeout','deadline'],
|
|
@@ -46,15 +48,16 @@ const canonical=value=>{
|
|
|
46
48
|
return value;
|
|
47
49
|
};
|
|
48
50
|
const hash=value=>'sha256:'+createHash('sha256').update(value).digest('hex');
|
|
49
|
-
const [qaSourceBytes,mraidHostBytes,vendorHostBytes]=await Promise.all([
|
|
51
|
+
const [qaSourceBytes,playthroughBytes,mraidHostBytes,vendorHostBytes]=await Promise.all([
|
|
50
52
|
readFile(new URL(import.meta.url)),
|
|
53
|
+
readFile(new URL('./outcome-playthrough.mjs',import.meta.url)),
|
|
51
54
|
readFile(new URL(IS_SOURCE_CHECKOUT?'../../../packages/test-harness/src/mraid-host.ts':'../../../crates/packer/trusted/mraid-host.iife.js',import.meta.url)),
|
|
52
55
|
readFile(new URL(IS_SOURCE_CHECKOUT?'../../../packages/test-harness/src/vendor-hosts.ts':'../../../crates/packer/trusted/vendor-hosts.iife.js',import.meta.url)),
|
|
53
56
|
]);
|
|
54
|
-
export const CREATIVE_QA_CHECKER_VERSION='tora-creative-qa-1:'+hash(Buffer.concat([qaSourceBytes,mraidHostBytes,vendorHostBytes]));
|
|
57
|
+
export const CREATIVE_QA_CHECKER_VERSION='tora-creative-qa-1:'+hash(Buffer.concat([qaSourceBytes,playthroughBytes,mraidHostBytes,vendorHostBytes]));
|
|
55
58
|
const DEFAULT_MOTION_OFFSETS_MS=Object.freeze([0,80,180,320,500,750,1050,1350]);
|
|
56
59
|
const DEFAULT_ENDCARD_OFFSETS_MS=Object.freeze([0,150,350,650]);
|
|
57
|
-
const MOTION_BEHAVIOR_KINDS=new Set(['emitter','animation','motion','physics-body','physics-3d','camera-follow','path-agent','oscillate','oscillate-3d']);
|
|
60
|
+
const MOTION_BEHAVIOR_KINDS=new Set(['emitter','animation','animate-3d','motion','physics-body','physics-3d','camera-follow','path-agent','oscillate','oscillate-3d']);
|
|
58
61
|
let cachedBrowserVersionPromise=null;
|
|
59
62
|
export function getPlaywrightBrowserVersion(){
|
|
60
63
|
if(!cachedBrowserVersionPromise){
|
|
@@ -82,7 +85,7 @@ async function readVerifiedHostBundle(filename){
|
|
|
82
85
|
if(typeof expected!=='string'||hash(script)!==expected)throw Error('E_NATIVE_HOST_CORRUPT');
|
|
83
86
|
return script;
|
|
84
87
|
}
|
|
85
|
-
async function getHostInit(networkTarget){
|
|
88
|
+
export async function getHostInit(networkTarget){
|
|
86
89
|
const key=`${networkTarget.hostKind}:${networkTarget.mraidVersion??''}`;
|
|
87
90
|
if(hostInitCache.has(key))return hostInitCache.get(key);
|
|
88
91
|
let script;
|
|
@@ -444,6 +447,57 @@ export async function runStaticPreflight(projectOrOptions,suppliedOptions={}){
|
|
|
444
447
|
blockers.push(issue('blocker','end-card-hero-low-res',component.id,'Replace the upscaled low-resolution end-card image with crisp high-resolution artwork (>= 50% of rendered size).',{detail:`End-card image ${component.id} upscales ${dims.width}x${dims.height}px artwork to ${renderW}x${renderH}px (${Math.max(scaleX,scaleY).toFixed(1)}x).`,metrics:{componentId:component.id,assetId,intrinsicWidth:dims.width,intrinsicHeight:dims.height,renderWidth:renderW,renderHeight:renderH}}));
|
|
445
448
|
}
|
|
446
449
|
}
|
|
450
|
+
// Inspect embedded 3D GLB assets, subNode bindings, and scene 3D budgets
|
|
451
|
+
const glbAssets=assets.filter(asset=>asset.mime==='model/gltf-binary');
|
|
452
|
+
const glbInfoById=new Map();
|
|
453
|
+
let totalGlbDecodedTextureBytes=0;
|
|
454
|
+
for(const asset of [...glbAssets].sort((a,b)=>a.id.localeCompare(b.id))){
|
|
455
|
+
const rawBytes=await bytesFor(asset,project);
|
|
456
|
+
if(!rawBytes)continue;
|
|
457
|
+
try{
|
|
458
|
+
const buf=Buffer.isBuffer(rawBytes)?rawBytes:Buffer.from(rawBytes);
|
|
459
|
+
validateGlbHeader(buf,'E_MODEL_CORRUPT');
|
|
460
|
+
const info=glbBudgetInfo(buf);
|
|
461
|
+
glbInfoById.set(asset.id,info);
|
|
462
|
+
totalGlbDecodedTextureBytes+=info.decodedTextureBytes;
|
|
463
|
+
}catch(error){
|
|
464
|
+
blockers.push(issue('blocker','model-glb-invalid',null,'Re-prepare or re-upload the 3D asset as a valid canonical glTF 2.0 binary (.glb).',{detail:`${asset.id}: ${error.message}`,metrics:{assetId:asset.id}}));
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
const scene3dStats=new Map();
|
|
468
|
+
for(const component of components){
|
|
469
|
+
if(component.contract!=='native.mesh3d.v1')continue;
|
|
470
|
+
const sourceSlot=component.assetSlots?.find(slot=>slot.slotId==='source');
|
|
471
|
+
const info=sourceSlot?glbInfoById.get(sourceSlot.assetId):undefined;
|
|
472
|
+
if(!info)continue;
|
|
473
|
+
const requestedSubNode=component.parameters?.subNode;
|
|
474
|
+
if(typeof requestedSubNode==='string'&&requestedSubNode.length>0&&!info.subNodes.includes(requestedSubNode)){
|
|
475
|
+
blockers.push(issue('blocker','model-subnode-missing',component.id,'Update subNode to match a preserved named node in the GLB asset or remove subNode to render the whole model.',{detail:`Component ${component.id} requests subNode "${requestedSubNode}", which is not present in ${sourceSlot.assetId} (${info.subNodes.join(', ')||'no named nodes'}).`,metrics:{componentId:component.id,assetId:sourceSlot.assetId,subNode:requestedSubNode,availableSubNodes:info.subNodes}}));
|
|
476
|
+
}
|
|
477
|
+
for(const animBeh of (project.gameplay??[]).filter(b=>b.kind==='animate-3d'&&b.componentId===component.id)){
|
|
478
|
+
const clip=animBeh.parameters?.clipName;
|
|
479
|
+
if(typeof clip==='string'&&clip.length>0&&!(info.animations??[]).includes(clip)){
|
|
480
|
+
blockers.push(issue('blocker','model-animation-missing',component.id,'Update animate-3d clipName to match an animation clip in the GLB asset or leave clipName empty for the default clip.',{detail:`Component ${component.id} requests animation clip "${clip}", which is not present in ${sourceSlot.assetId} (${(info.animations??[]).join(', ')||'no clips'}).`,metrics:{componentId:component.id,assetId:sourceSlot.assetId,clipName:clip,availableClips:info.animations??[]}}));
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if(!component.prototype&&component.parameters?.visible!==false){
|
|
484
|
+
const st=scene3dStats.get(component.sceneId)??{triangles:0,drawCalls:0};
|
|
485
|
+
st.triangles+=info.triangles;
|
|
486
|
+
st.drawCalls+=info.drawCalls;
|
|
487
|
+
scene3dStats.set(component.sceneId,st);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
for(const [sceneId,st] of scene3dStats.entries()){
|
|
491
|
+
if(st.triangles>25000){
|
|
492
|
+
warnings.push(issue('warning','scene3d-high-triangles',null,'Reduce 3D scene triangle count below 25,000 for smooth mobile WebView performance.',{detail:`Scene ${sceneId} references ~${st.triangles} triangles across GLB meshes.`,metrics:{sceneId,triangles:st.triangles}}));
|
|
493
|
+
}
|
|
494
|
+
if(st.drawCalls>40){
|
|
495
|
+
warnings.push(issue('warning','scene3d-high-drawcalls',null,'Reduce 3D scene draw calls below 40 by merging materials or reducing separate GLB instances.',{detail:`Scene ${sceneId} issues ~${st.drawCalls} GLB draw calls.`,metrics:{sceneId,drawCalls:st.drawCalls}}));
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
if(totalGlbDecodedTextureBytes>16*1024*1024){
|
|
499
|
+
warnings.push(issue('warning','scene3d-high-vram',null,'Lower maxTextureSide on 3D models to keep decoded GLB texture VRAM under 16 MiB.',{detail:`Decoded GLB textures require ${(totalGlbDecodedTextureBytes/(1024*1024)).toFixed(1)} MiB across ${glbInfoById.size} model(s).`,metrics:{decodedTextureBytes:totalGlbDecodedTextureBytes}}));
|
|
500
|
+
}
|
|
447
501
|
const wavAssets=assets.filter(asset=>isAudioMime(asset.mime)),assetRoutes=new Map();
|
|
448
502
|
for(const route of routes)if(route.valid){
|
|
449
503
|
if(!assetRoutes.has(route.asset.id))assetRoutes.set(route.asset.id,[]);
|
|
@@ -474,7 +528,7 @@ export async function runStaticPreflight(projectOrOptions,suppliedOptions={}){
|
|
|
474
528
|
blockers.push(issue('blocker','audio-analysis-failed',routeRows[0].componentId,'Replace malformed or unsupported audio bytes with a bounded WAV or MP3 accepted by the asset pipeline.',{detail:`${asset.id}: ${error.message}`,metrics:{assetId:asset.id,code:error.code??null}}));
|
|
475
529
|
}
|
|
476
530
|
}
|
|
477
|
-
return formatCreativeQaReport({scope:'static',blockers,warnings,checks:{audioBindings:audio.length,wavAssets:wavAssets.length,wavAnalysis:analyzerStatus,pixelTextComponents:pixelComponents.length,catalogMetadata:Boolean(catalog)}});
|
|
531
|
+
return formatCreativeQaReport({scope:'static',blockers,warnings,checks:{audioBindings:audio.length,wavAssets:wavAssets.length,wavAnalysis:analyzerStatus,glbAssets:glbAssets.length,pixelTextComponents:pixelComponents.length,catalogMetadata:Boolean(catalog)}});
|
|
478
532
|
}
|
|
479
533
|
export const staticPreflight=runStaticPreflight;
|
|
480
534
|
export const preflight=runStaticPreflight;
|
|
@@ -491,6 +545,45 @@ function meaningfulState(state){
|
|
|
491
545
|
}
|
|
492
546
|
function stateChanged(before,after){return JSON.stringify(canonical(meaningfulState(before)))!==JSON.stringify(canonical(meaningfulState(after)));}
|
|
493
547
|
|
|
548
|
+
function endingScenes(project){
|
|
549
|
+
const cards=(project?.scenes??[]).filter(scene=>scene.role==='end-card');
|
|
550
|
+
const isTimeout=scene=>normalizeRole(scene.id)==='loss'||normalizeRole(scene.label)==='loss';
|
|
551
|
+
return {win:cards.filter(scene=>!isTimeout(scene)).map(scene=>scene.id),timeout:cards.filter(isTimeout).map(scene=>scene.id)};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
function captureBrowserStore(){
|
|
555
|
+
globalThis.__toraQaStoreCalls=[];
|
|
556
|
+
globalThis.open=url=>{globalThis.__toraQaStoreCalls.push(String(url));return null;};
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
async function storeCalls(page,hostKind){
|
|
560
|
+
const entries={
|
|
561
|
+
mraid:['__mraidTest','open'],dapi:['__ironsourceTest','openStoreUrl'],meta:['__metaTest','onCTAClick'],
|
|
562
|
+
'google-exitapi':['__googleTest','exit'],mintegral:['__mintegralTest','install'],tiktok:['__tiktokTest','openAppStore'],
|
|
563
|
+
};
|
|
564
|
+
return page.evaluate(entry=>{
|
|
565
|
+
if(!entry)return globalThis.__toraQaStoreCalls??[];
|
|
566
|
+
const snapshot=globalThis[entry[0]]?.snapshot?.();
|
|
567
|
+
return (Array.isArray(snapshot)?snapshot:snapshot?.calls??[]).filter(call=>call.name===entry[1]);
|
|
568
|
+
},entries[hostKind]??null);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
async function storeTarget(page,current){
|
|
572
|
+
const ids=(current.events??[]).filter(event=>event.kind==='click'&¤t.eventBindings.some(
|
|
573
|
+
binding=>binding.eventId===event.id&&binding.actions.some(action=>action.kind==='store'),
|
|
574
|
+
)).map(event=>event.componentId);
|
|
575
|
+
return page.evaluate(ids=>{
|
|
576
|
+
const canvas=globalThis.document.querySelector('canvas');
|
|
577
|
+
const audit=globalThis.toraRuntime?.auditSceneLayout?.({ids,interactiveIds:ids});
|
|
578
|
+
const target=audit?.interactive?.find(row=>ids.includes(row.id));
|
|
579
|
+
if(!canvas||!target)return null;
|
|
580
|
+
const {bounds}=target,{width,height,scale}=audit.viewport,rect=canvas.getBoundingClientRect();
|
|
581
|
+
const x=rect.left+(rect.width-width*scale)/2+(bounds.left+bounds.right)/2*scale;
|
|
582
|
+
const y=rect.top+(rect.height-height*scale)/2+(bounds.top+bounds.bottom)/2*scale;
|
|
583
|
+
return x>=rect.left&&x<rect.right&&y>=rect.top&&y<rect.bottom?{componentId:target.id,x,y}:null;
|
|
584
|
+
},ids);
|
|
585
|
+
}
|
|
586
|
+
|
|
494
587
|
async function openPlaywrightSession({html,htmlPath,project,primaryComponentId,network,browser:sharedBrowser}){
|
|
495
588
|
const {chromium}=await import('playwright');
|
|
496
589
|
const browser=sharedBrowser??await chromium.launch({headless:true});
|
|
@@ -506,15 +599,71 @@ async function openPlaywrightSession({html,htmlPath,project,primaryComponentId,n
|
|
|
506
599
|
const scriptUrl=networkTarget.hostKind==='google-exitapi'?'https://tpc.googlesyndication.com/pagead/gadgets/html5/api/exitapi.js':'https://sf16-muse-va.ibytedtos.com/obj/union-fe-nc-i18n/Playable/sdk/Playable-sdk.js';
|
|
507
600
|
await context.route(scriptUrl,route=>route.fulfill({status:200,contentType:'application/javascript',body:'/* declared vendor host supplied by the QA mock */'}));
|
|
508
601
|
}
|
|
602
|
+
const mockBrowserStore=!networkTarget||networkTarget.hostKind==='browser';
|
|
603
|
+
if(mockBrowserStore)await page.addInitScript(captureBrowserStore);
|
|
509
604
|
const url=htmlPath?pathToFileURL(resolve(htmlPath)).href:undefined;
|
|
605
|
+
const settleFrame=async targetPage=>{
|
|
606
|
+
await targetPage.waitForFunction(()=>(globalThis.toraRuntime?.state?.()?.model3d?.texturesPending??0)===0,undefined,{timeout:5000}).catch(()=>{});
|
|
607
|
+
await targetPage.evaluate(async()=>{await globalThis.document.fonts?.ready;await new Promise(resolveFrame=>globalThis.requestAnimationFrame(()=>globalThis.requestAnimationFrame(resolveFrame)));});
|
|
608
|
+
};
|
|
609
|
+
const readProject=async targetPage=>project??await targetPage.evaluate(()=>{
|
|
610
|
+
const embedded=globalThis.document.getElementById('project');
|
|
611
|
+
return embedded?JSON.parse(embedded.textContent):null;
|
|
612
|
+
});
|
|
613
|
+
const playEnding=async(targetPage,session)=>{
|
|
614
|
+
const current=await readProject(targetPage);
|
|
615
|
+
if(!current)return {available:false,required:false};
|
|
616
|
+
const {win,timeout}=endingScenes(current),descriptor=qaAdapterForProject(current);
|
|
617
|
+
if(descriptor?.qa?.playToEndCard)return {...await descriptor.qa.playToEndCard(targetPage,current),required:true};
|
|
618
|
+
if(!win.length)return {available:false,required:false};
|
|
619
|
+
const play=builtInPlaythrough(current);
|
|
620
|
+
if(play)return {available:await play(targetPage),required:true,mode:'real-play'};
|
|
621
|
+
const readScene=()=>targetPage.evaluate(()=>globalThis.toraRuntime?.state?.()?.scene);
|
|
622
|
+
for(let attempt=0;attempt<24;attempt++){
|
|
623
|
+
const scene=await readScene();
|
|
624
|
+
if(win.includes(scene))return {available:true,required:true,mode:'real-play'};
|
|
625
|
+
if(timeout.includes(scene))break;
|
|
626
|
+
const target=await session.getPrimaryTarget(targetPage,true);
|
|
627
|
+
if(!target)break;
|
|
628
|
+
await session.prepareClick(target,targetPage);
|
|
629
|
+
await session.click(target,targetPage);
|
|
630
|
+
await targetPage.waitForTimeout(180);
|
|
631
|
+
}
|
|
632
|
+
const winBindings=current.eventBindings.filter(binding=>binding.actions.some(
|
|
633
|
+
action=>action.kind==='changeScene'&&win.includes(action.sceneId),
|
|
634
|
+
));
|
|
635
|
+
const actionDelay=Math.max(0,...winBindings.flatMap(binding=>binding.actions.map(action=>action.delaySeconds??0)));
|
|
636
|
+
const arrival=current.events.some(event=>event.kind==='pathArrive'&&winBindings.some(binding=>binding.eventId===event.id));
|
|
637
|
+
await targetPage.waitForFunction(ids=>ids.includes(globalThis.toraRuntime?.state?.()?.scene),win,
|
|
638
|
+
{timeout:Math.max(arrival?6500:1500,actionDelay*1200+300)}).catch(()=>{});
|
|
639
|
+
return win.includes(await readScene())?{available:true,required:true,mode:'real-play'}:{available:false,required:true};
|
|
640
|
+
};
|
|
641
|
+
const verifyStore=async targetPage=>{
|
|
642
|
+
const current=await readProject(targetPage);
|
|
643
|
+
const before=await storeCalls(targetPage,networkTarget?.hostKind);
|
|
644
|
+
if(before.length)return {ok:false,reason:'early-store-open'};
|
|
645
|
+
const until=Date.now()+1400;
|
|
646
|
+
let target;
|
|
647
|
+
do{
|
|
648
|
+
target=await storeTarget(targetPage,current);
|
|
649
|
+
if(target)break;
|
|
650
|
+
await targetPage.waitForTimeout(50);
|
|
651
|
+
}while(Date.now()<until);
|
|
652
|
+
if(!target)return {ok:false,reason:'store-cta-missing'};
|
|
653
|
+
await targetPage.mouse.click(target.x,target.y);
|
|
654
|
+
const after=await storeCalls(targetPage,networkTarget?.hostKind);
|
|
655
|
+
const actualUrl=typeof after[0]==='string'?after[0]:after[0]?.args?.[0];
|
|
656
|
+
const ok=after.length===1&&(actualUrl===undefined||actualUrl===current.base.storeUrl);
|
|
657
|
+
return {ok,componentId:target.componentId,...(!ok?{reason:'store-cta-did-not-open'}:{})};
|
|
658
|
+
};
|
|
510
659
|
let closed=false;
|
|
511
660
|
return {
|
|
512
661
|
async setViewport(viewport){await page.setViewportSize(viewport);},
|
|
513
662
|
async load(){
|
|
514
663
|
await page.evaluate(()=>globalThis.toraRuntime?.destroy?.()).catch(()=>{});
|
|
515
|
-
if(url)await page.goto(url,{waitUntil:'load'});else{if(hostInit)await page.evaluate(hostInit);await page.setContent(html,{waitUntil:'load'});}
|
|
664
|
+
if(url)await page.goto(url,{waitUntil:'load'});else{await page.goto('about:blank');if(hostInit)await page.evaluate(hostInit);await page.setContent(html,{waitUntil:'load'});}
|
|
516
665
|
await page.waitForFunction(()=>globalThis.toraRuntime);
|
|
517
|
-
await page
|
|
666
|
+
await settleFrame(page);
|
|
518
667
|
},
|
|
519
668
|
async screenshot(){return page.screenshot({type:'png'});},
|
|
520
669
|
async auditLayout(args){
|
|
@@ -524,8 +673,31 @@ async function openPlaywrightSession({html,htmlPath,project,primaryComponentId,n
|
|
|
524
673
|
},args);
|
|
525
674
|
},
|
|
526
675
|
async getState(){return page.evaluate(()=>globalThis.toraRuntime?.state?.()??null);},
|
|
527
|
-
async
|
|
528
|
-
|
|
676
|
+
async armResponseMeasurement(){
|
|
677
|
+
await page.evaluate(()=>{
|
|
678
|
+
globalThis.__toraQaInputResponse=undefined;
|
|
679
|
+
globalThis.document.addEventListener('pointerdown',event=>{
|
|
680
|
+
const snapshot=()=>{
|
|
681
|
+
const state=globalThis.toraRuntime?.state?.();
|
|
682
|
+
if(!state)return null;
|
|
683
|
+
const observable={...state};
|
|
684
|
+
delete observable.time;
|
|
685
|
+
delete observable.input;
|
|
686
|
+
return JSON.stringify(observable);
|
|
687
|
+
};
|
|
688
|
+
const before=snapshot(),started=event.timeStamp;
|
|
689
|
+
const poll=()=>{
|
|
690
|
+
const elapsed=globalThis.performance.now()-started;
|
|
691
|
+
if(before!==snapshot())globalThis.__toraQaInputResponse=elapsed;
|
|
692
|
+
else if(elapsed<260)globalThis.requestAnimationFrame(poll);
|
|
693
|
+
};
|
|
694
|
+
globalThis.requestAnimationFrame(poll);
|
|
695
|
+
},{capture:true,once:true});
|
|
696
|
+
});
|
|
697
|
+
},
|
|
698
|
+
async readResponseMeasurement(){return page.evaluate(()=>globalThis.__toraQaInputResponse);},
|
|
699
|
+
async getPrimaryTarget(targetPage=page,activeScene=false){
|
|
700
|
+
return targetPage.evaluate(({authored,preferred,activeScene})=>{
|
|
529
701
|
const embedded=globalThis.document.getElementById('project');
|
|
530
702
|
const current=authored??(embedded?JSON.parse(embedded.textContent):undefined);
|
|
531
703
|
const canvas=globalThis.document.querySelector('canvas');
|
|
@@ -534,12 +706,43 @@ async function openPlaywrightSession({html,htmlPath,project,primaryComponentId,n
|
|
|
534
706
|
const bindings=new Map(current.eventBindings.map(binding=>[binding.eventId,binding]));
|
|
535
707
|
const multiply=(a,b)=>[a[0]*b[0]+a[2]*b[1],a[1]*b[0]+a[3]*b[1],a[0]*b[2]+a[2]*b[3],a[1]*b[2]+a[3]*b[3],a[0]*b[4]+a[2]*b[5]+a[4],a[1]*b[4]+a[3]*b[5]+a[5]];
|
|
536
708
|
const clickEvents=current.events.filter(event=>event.kind==='click'&&byId.has(event.componentId));
|
|
709
|
+
const liveState=globalThis.toraRuntime?.state?.()??null;
|
|
710
|
+
const liveAudit=globalThis.toraRuntime?.auditSceneLayout?.()??null;
|
|
711
|
+
const anchor3dByComp=new Map((current.gameplay??[]).filter(behavior=>behavior.kind==='ui-anchor-3d').map(behavior=>[behavior.componentId,behavior.parameters]));
|
|
712
|
+
const liveAnchorByComp=new Map((liveAudit?.anchors3d??[]).map(row=>[row.id,row]));
|
|
713
|
+
const liveInteractiveById=new Map((liveAudit?.interactive??[]).map(row=>[row.id,row]));
|
|
714
|
+
const scene=(activeScene?liveState?.scene:undefined)??current.base.startScene;
|
|
715
|
+
const parameters=component=>({...component.parameters,...liveState?.components?.[component.id]?.parameters});
|
|
716
|
+
const nodeChainVisible=startNode=>{
|
|
717
|
+
for(let node=startNode;node;node=byId.get(node.parentId)){
|
|
718
|
+
const params=parameters(node);
|
|
719
|
+
if(params.visible===false||params.opacity===0)return false;
|
|
720
|
+
}
|
|
721
|
+
return true;
|
|
722
|
+
};
|
|
537
723
|
const eligible=event=>{
|
|
538
724
|
const component=byId.get(event.componentId);
|
|
539
|
-
|
|
725
|
+
if(component.sceneId!==scene||component.prototype||parameters(component).enabled===false)return false;
|
|
726
|
+
for(let node=component;node;node=byId.get(node.parentId)){
|
|
727
|
+
const params=parameters(node);
|
|
728
|
+
if(params.visible===false||params.opacity===0)return false;
|
|
729
|
+
const anchorCfg=anchor3dByComp.get(node.id);
|
|
730
|
+
if(anchorCfg){
|
|
731
|
+
if(anchorCfg.syncVisibility!==false){
|
|
732
|
+
const targetNode=byId.get(anchorCfg.targetId);
|
|
733
|
+
if(!targetNode||!nodeChainVisible(targetNode))return false;
|
|
734
|
+
}
|
|
735
|
+
const liveAnchor=liveAnchorByComp.get(node.id);
|
|
736
|
+
if(liveAnchor&&!liveAnchor.visible)return false;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return true;
|
|
540
740
|
};
|
|
541
741
|
let candidates=clickEvents.filter(event=>!preferred||event.componentId===preferred).filter(eligible).filter(event=>{
|
|
542
742
|
const component=byId.get(event.componentId);
|
|
743
|
+
if(activeScene&¤t.eventBindings.filter(binding=>binding.eventId===event.id).every(
|
|
744
|
+
binding=>binding.actions.every(action=>action.kind==='store'||action.kind==='restart'),
|
|
745
|
+
))return false;
|
|
543
746
|
return component.contract!=='native.group.v1'||component.parameters?.width>0&&component.parameters?.height>0;
|
|
544
747
|
});
|
|
545
748
|
if(!candidates.length&&!preferred)candidates=current.gameplay.filter(behavior=>behavior.kind==='match-tile'&&byId.has(behavior.componentId)).map(behavior=>({id:behavior.id+'.primary',componentId:behavior.componentId})).filter(eligible);
|
|
@@ -547,7 +750,7 @@ async function openPlaywrightSession({html,htmlPath,project,primaryComponentId,n
|
|
|
547
750
|
if(!candidates.length&&!preferred)candidates=current.gameplay.filter(behavior=>behavior.kind==='aim-launch-3d'&&byId.has(behavior.componentId)).map(behavior=>({id:behavior.id,kind:'aim-launch-3d',componentId:behavior.componentId})).filter(eligible);
|
|
548
751
|
const liveInstances=globalThis.toraRuntime?.state?.()?.instances??[];
|
|
549
752
|
if(!candidates.length&&!preferred)candidates=current.gameplay.filter(behavior=>behavior.kind==='drag'&&byId.has(behavior.componentId)).map(behavior=>({id:behavior.id,kind:'drag',componentId:behavior.componentId,parameters:behavior.parameters})).filter(eligible);
|
|
550
|
-
if(!candidates.length&&!preferred)candidates=current.gameplay.filter(behavior=>behavior.kind==='drag'&&byId.has(behavior.componentId)).map(behavior=>({id:behavior.id,kind:'drag',componentId:behavior.componentId,parameters:behavior.parameters,fromInstance:true})).filter(entry=>{const c=byId.get(entry.componentId);return c.sceneId===
|
|
753
|
+
if(!candidates.length&&!preferred)candidates=current.gameplay.filter(behavior=>behavior.kind==='drag'&&byId.has(behavior.componentId)).map(behavior=>({id:behavior.id,kind:'drag',componentId:behavior.componentId,parameters:behavior.parameters,fromInstance:true})).filter(entry=>{const c=byId.get(entry.componentId);return c.sceneId===scene&&c.prototype&&c.parameters?.visible!==false&&liveInstances.some(instance=>instance.prototypeId===c.id);});
|
|
551
754
|
if(!candidates.length&&!preferred)candidates=current.gameplay.filter(behavior=>behavior.kind==='swipe-input'&&byId.has(behavior.componentId)).map(behavior=>({id:behavior.id,kind:'swipe',componentId:behavior.componentId})).filter(eligible);
|
|
552
755
|
if(!candidates.length&&!preferred)candidates=current.gameplay.filter(behavior=>behavior.kind==='virtual-joystick'&&byId.has(behavior.componentId)).map(behavior=>({id:behavior.id,kind:'joystick',componentId:behavior.componentId})).filter(eligible);
|
|
553
756
|
if(!candidates.length&&!preferred)candidates=current.gameplay.filter(behavior=>behavior.kind==='hold-charge'&&byId.has(behavior.componentId)).map(behavior=>({id:behavior.id,kind:'hold',componentId:behavior.componentId})).filter(eligible);
|
|
@@ -571,15 +774,22 @@ async function openPlaywrightSession({html,htmlPath,project,primaryComponentId,n
|
|
|
571
774
|
return {componentId:component.id,interaction:'aim-launch',x:rect.left+offsetX+pt.x*scale,y:rect.top+offsetY+pt.y*scale};
|
|
572
775
|
}
|
|
573
776
|
const local=target=>{
|
|
574
|
-
const authoredTransform=target.transform??[1,0,0,1,0,0],layout=responsive.get(target.id);
|
|
777
|
+
const authoredTransform=liveState?.components?.[target.id]?.transform??target.transform??[1,0,0,1,0,0],layout=responsive.get(target.id);
|
|
575
778
|
if(!layout||!landscape)return authoredTransform;
|
|
576
779
|
const result=[...authoredTransform];result[4]+=layout.x-authoredTransform[4];result[5]+=layout.y-authoredTransform[5];result[0]*=layout.scaleX;result[1]*=layout.scaleX;result[2]*=layout.scaleY;result[3]*=layout.scaleY;return result;
|
|
577
780
|
};
|
|
578
781
|
const world=target=>target.parentId?multiply(world(byId.get(target.parentId)),local(target)):local(target);
|
|
579
|
-
const matrix=world(component),width
|
|
782
|
+
const matrix=world(component),{width,height}=parameters(component);
|
|
580
783
|
const screen=pt=>({x:rect.left+offsetX+pt.x*scale,y:rect.top+offsetY+pt.y*scale});
|
|
581
784
|
const liveMatches=candidates[0]?.fromInstance?liveInstances.filter(instance=>instance.prototypeId===component.id):[];
|
|
582
|
-
const
|
|
785
|
+
const liveRow=!liveMatches.length?liveInteractiveById.get(component.id):undefined;
|
|
786
|
+
const liveAnchorBounds=!liveMatches.length?liveAnchorByComp.get(component.id)?.overlayBounds:undefined;
|
|
787
|
+
const liveBounds=liveRow?.bounds??liveAnchorBounds;
|
|
788
|
+
const center=liveMatches.length
|
|
789
|
+
?{x:liveMatches[0].x+width/2,y:liveMatches[0].y+height/2}
|
|
790
|
+
:liveBounds
|
|
791
|
+
?{x:(liveBounds.left+liveBounds.right)/2,y:(liveBounds.top+liveBounds.bottom)/2}
|
|
792
|
+
:{x:matrix[0]*width/2+matrix[2]*height/2+matrix[4],y:matrix[1]*width/2+matrix[3]*height/2+matrix[5]};
|
|
583
793
|
const start=screen(center),kind=candidates[0]?.kind;
|
|
584
794
|
if(kind==='drag'){
|
|
585
795
|
if(liveMatches.length>1&¤t.gameplay.some(behavior=>behavior.kind==='drop-zone'&&behavior.componentId===component.id)){
|
|
@@ -605,108 +815,80 @@ async function openPlaywrightSession({html,htmlPath,project,primaryComponentId,n
|
|
|
605
815
|
return {componentId:component.id,interaction:kind,x:from.x,y:from.y,endX:to.x,endY:to.y};
|
|
606
816
|
}
|
|
607
817
|
return {componentId:component.id,interaction:kind==='aim-launch'?'aim-launch':'click',...start};
|
|
608
|
-
},{authored:project??null,preferred:primaryComponentId??null});
|
|
818
|
+
},{authored:project??null,preferred:activeScene?null:primaryComponentId??null,activeScene});
|
|
609
819
|
},
|
|
610
|
-
async prepareClick(target){if(target.interaction==='aim-launch')await
|
|
611
|
-
async click(target){
|
|
612
|
-
if(target.interaction==='aim-launch'){await
|
|
613
|
-
else if(target.interaction==='drag-drop'){await
|
|
614
|
-
else if(target.interaction==='swipe'){await
|
|
615
|
-
else if(target.interaction==='hold'){await
|
|
616
|
-
else if(target.interaction==='draw'||target.interaction==='erase'){await
|
|
617
|
-
else await
|
|
618
|
-
},
|
|
619
|
-
async enterEndCard(){
|
|
620
|
-
const current=project??await page.evaluate(()=>{const el=globalThis.document.getElementById('project');return el?JSON.parse(el.textContent):null;});
|
|
621
|
-
if(!current)return {available:false};
|
|
622
|
-
const endScenes=(current.scenes??[]).filter(scene=>scene.role==='end-card');
|
|
623
|
-
const {descriptor}=moduleForProject(current);
|
|
624
|
-
if(descriptor?.qa?.playToEndCard)return descriptor.qa.playToEndCard(page,current);
|
|
625
|
-
if(endScenes.length){
|
|
626
|
-
const target=await this.getPrimaryTarget();
|
|
627
|
-
if(target){
|
|
628
|
-
for(let tap=0;tap<12;tap++){
|
|
629
|
-
await page.mouse.click(target.x,target.y);
|
|
630
|
-
const sceneNow=await page.evaluate(()=>globalThis.toraRuntime?.state?.()?.scene);
|
|
631
|
-
if(endScenes.some(scene=>scene.id===sceneNow))return {available:true,mode:'real-play'};
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
const winEndScene=endScenes.find(scene=>!/fail|loss|timeout/i.test(scene.id))??endScenes[0];
|
|
635
|
-
const ok=await page.evaluate(sceneId=>{
|
|
636
|
-
const canvas=globalThis.document.querySelector('canvas'),embedded=globalThis.document.getElementById('project');
|
|
637
|
-
if(!canvas||!embedded||typeof globalThis.ToraNative?.mountNative!=='function')return false;
|
|
638
|
-
globalThis.toraRuntime?.destroy?.();
|
|
639
|
-
globalThis.toraRuntime=globalThis.ToraNative.mountNative(JSON.parse(embedded.textContent),canvas,{edit:true,sceneId});
|
|
640
|
-
return true;
|
|
641
|
-
},winEndScene.id);
|
|
642
|
-
if(ok){
|
|
643
|
-
await page.evaluate(()=>new Promise(resolveFrame=>globalThis.requestAnimationFrame(()=>globalThis.requestAnimationFrame(resolveFrame))));
|
|
644
|
-
return {available:true,mode:'edit-layout'};
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
return {available:false};
|
|
820
|
+
async prepareClick(target,targetPage=page){if(target.interaction==='aim-launch')await targetPage.mouse.move(target.x,target.y);},
|
|
821
|
+
async click(target,targetPage=page){
|
|
822
|
+
if(target.interaction==='aim-launch'){await targetPage.mouse.down();await targetPage.mouse.move(target.x-64,target.y+28);await targetPage.mouse.up();}
|
|
823
|
+
else if(target.interaction==='drag-drop'){await targetPage.mouse.move(target.x,target.y);await targetPage.mouse.down();await targetPage.mouse.move(target.endX,target.endY,{steps:3});await targetPage.mouse.up();}
|
|
824
|
+
else if(target.interaction==='swipe'){await targetPage.mouse.move(target.x,target.y);await targetPage.mouse.down();await targetPage.mouse.move(target.endX,target.endY,{steps:3});await targetPage.mouse.up();}
|
|
825
|
+
else if(target.interaction==='hold'){await targetPage.mouse.move(target.x,target.y);await targetPage.mouse.down();await targetPage.waitForTimeout(55);await targetPage.mouse.up();}
|
|
826
|
+
else if(target.interaction==='draw'||target.interaction==='erase'){await targetPage.mouse.move(target.x,target.y);await targetPage.mouse.down();await targetPage.mouse.move(target.endX,target.endY,{steps:3});await targetPage.mouse.up();}
|
|
827
|
+
else await targetPage.mouse.click(target.x,target.y);
|
|
648
828
|
},
|
|
829
|
+
async enterEndCard(){return playEnding(page,this);},
|
|
830
|
+
async verifyStore(){return verifyStore(page);},
|
|
649
831
|
async enterTimeout(){
|
|
650
|
-
const current=
|
|
651
|
-
if(!current)return {available:false};
|
|
652
|
-
const {
|
|
653
|
-
const phaseVariable=descriptor?.qa?.phaseVariable??
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if(
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
if(descriptor?.qa?.validateTimeout&&!descriptor.qa.validateTimeout(timeoutState))throw Error('E_CREATIVE_TIMEOUT_OUTCOME');
|
|
684
|
-
if(!reached){await timeoutPage.close();return {available:false};}
|
|
685
|
-
return {
|
|
686
|
-
available:true,mode:'real-timeout',
|
|
687
|
-
async setViewport(vp){await timeoutPage.setViewportSize(vp);await timeoutPage.evaluate(()=>new Promise(r=>globalThis.requestAnimationFrame(()=>globalThis.requestAnimationFrame(r))));},
|
|
688
|
-
async screenshot(){return timeoutPage.screenshot({type:'png'});},
|
|
689
|
-
async getState(){return timeoutPage.evaluate(()=>globalThis.toraRuntime?.state?.()??null);},
|
|
690
|
-
async auditLayout(args){return timeoutPage.evaluate(opts=>globalThis.toraRuntime?.auditSceneLayout?.(opts)??null,args);},
|
|
691
|
-
async close(){await timeoutPage.close();},
|
|
832
|
+
const current=await readProject(page);
|
|
833
|
+
if(!current)return {available:false,required:false};
|
|
834
|
+
const descriptor=qaAdapterForProject(current),{timeout}=endingScenes(current);
|
|
835
|
+
const phaseVariable=descriptor?.qa?.phaseVariable??null;
|
|
836
|
+
const lossBindings=current.eventBindings.filter(binding=>binding.actions.some(
|
|
837
|
+
action=>action.kind==='changeScene'&&timeout.includes(action.sceneId),
|
|
838
|
+
));
|
|
839
|
+
const lossTimers=new Set(current.events.filter(event=>event.kind==='timer'&&lossBindings.some(binding=>binding.eventId===event.id))
|
|
840
|
+
.map(event=>event.behaviorId));
|
|
841
|
+
const timers=current.gameplay.filter(behavior=>behavior.kind==='timer');
|
|
842
|
+
const deadlineBehavior=timers.find(behavior=>behavior.id===descriptor?.qa?.deadlineBehaviorId)??
|
|
843
|
+
timers.find(behavior=>lossTimers.has(behavior.id))??timers.find(behavior=>/deadline|timeout/i.test(behavior.id));
|
|
844
|
+
const declaredTimeout=current.scenes.some(scene=>timeout.includes(scene.id)&&
|
|
845
|
+
/\b(timeout|deadline)\b/.test(semanticText(scene.id+' '+scene.label)));
|
|
846
|
+
const required=declaredTimeout||Boolean(deadlineBehavior&&(timeout.length||phaseVariable));
|
|
847
|
+
if(!required||!deadlineBehavior)return {available:false,required};
|
|
848
|
+
const deadlineSec=deadlineBehavior.parameters.seconds;
|
|
849
|
+
const timeoutPage=await context.newPage();
|
|
850
|
+
try{
|
|
851
|
+
await timeoutPage.setViewportSize(DEFAULT_VIEWPORTS[1]);
|
|
852
|
+
if(hostInit)await timeoutPage.addInitScript(hostInit);
|
|
853
|
+
else await timeoutPage.addInitScript(captureBrowserStore);
|
|
854
|
+
await timeoutPage.addInitScript(({phase,scenes})=>{
|
|
855
|
+
const original=globalThis.requestAnimationFrame.bind(globalThis);
|
|
856
|
+
let frame,now=0,manual=true;
|
|
857
|
+
globalThis.requestAnimationFrame=callback=>{if(!manual)return original(callback);frame=callback;return 1;};
|
|
858
|
+
globalThis.__pumpTimeout=steps=>{
|
|
859
|
+
const reached=()=>{const state=globalThis.toraRuntime?.state?.();return scenes.includes(state?.scene)||Boolean(phase&&state?.variables?.[phase]==='cta');};
|
|
860
|
+
for(let i=0;i<steps&&frame&&!reached();i++){
|
|
861
|
+
const callback=frame;frame=undefined;now+=80;callback(now);
|
|
862
|
+
}
|
|
863
|
+
manual=false;if(frame)original(frame);
|
|
864
|
+
return reached();
|
|
692
865
|
};
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
globalThis.toraRuntime=globalThis.ToraNative.mountNative(JSON.parse(embedded.textContent),canvas,{edit:true,sceneId});
|
|
702
|
-
return true;
|
|
703
|
-
},failScene.id);
|
|
704
|
-
if(ok){
|
|
705
|
-
await page.evaluate(()=>new Promise(resolveFrame=>globalThis.requestAnimationFrame(()=>globalThis.requestAnimationFrame(resolveFrame))));
|
|
706
|
-
return {available:true,mode:'edit-layout'};
|
|
866
|
+
},{phase:phaseVariable,scenes:timeout});
|
|
867
|
+
if(url)await timeoutPage.goto(url,{waitUntil:'load'});
|
|
868
|
+
else{await timeoutPage.goto('about:blank');await timeoutPage.setContent(html,{waitUntil:'load'});}
|
|
869
|
+
await timeoutPage.waitForFunction(()=>globalThis.toraRuntime&&typeof globalThis.__pumpTimeout==='function',undefined,{polling:25,timeout:5000});
|
|
870
|
+
if(descriptor?.qa?.prepareTimeout)await descriptor.qa.prepareTimeout(timeoutPage,current);
|
|
871
|
+
else{
|
|
872
|
+
const state=await timeoutPage.evaluate(()=>globalThis.toraRuntime.state());
|
|
873
|
+
if(!state.network?.started)await timeoutPage.mouse.click(1,1);
|
|
707
874
|
}
|
|
708
|
-
|
|
709
|
-
|
|
875
|
+
// Advance the real runtime on a small canvas, then restore the capture size.
|
|
876
|
+
await timeoutPage.setViewportSize({width:32,height:32});
|
|
877
|
+
const reached=await timeoutPage.evaluate(steps=>globalThis.__pumpTimeout(steps),Math.ceil((deadlineSec+11)/.08));
|
|
878
|
+
const state=await timeoutPage.evaluate(()=>globalThis.toraRuntime?.state?.());
|
|
879
|
+
if(descriptor?.qa?.validateTimeout&&!descriptor.qa.validateTimeout(state))throw Error('E_CREATIVE_TIMEOUT_OUTCOME');
|
|
880
|
+
if(!reached){await timeoutPage.close();return {available:false,required};}
|
|
881
|
+
await timeoutPage.setViewportSize(DEFAULT_VIEWPORTS[1]);
|
|
882
|
+
await settleFrame(timeoutPage);
|
|
883
|
+
return {available:true,required,mode:'real-timeout',
|
|
884
|
+
async setViewport(vp){await timeoutPage.setViewportSize(vp);await settleFrame(timeoutPage);},
|
|
885
|
+
async screenshot(){return timeoutPage.screenshot({type:'png'});},
|
|
886
|
+
async getState(){return timeoutPage.evaluate(()=>globalThis.toraRuntime?.state?.()??null);},
|
|
887
|
+
async auditLayout(args){return timeoutPage.evaluate(opts=>globalThis.toraRuntime?.auditSceneLayout?.(opts)??null,args);},
|
|
888
|
+
async verifyStore(){return verifyStore(timeoutPage);},
|
|
889
|
+
async close(){await timeoutPage.close();},
|
|
890
|
+
};
|
|
891
|
+
}catch(error){await timeoutPage.close().catch(()=>{});throw error;}
|
|
710
892
|
},
|
|
711
893
|
async enterState(state,stateHook){
|
|
712
894
|
if(typeof stateHook!=='string')throw Error('The Playwright state hook must be a global function name');
|
|
@@ -925,15 +1107,16 @@ async function openPlaywrightSession({html,htmlPath,project,primaryComponentId,n
|
|
|
925
1107
|
if(url)await vPage.goto(url,{waitUntil:'load'});
|
|
926
1108
|
else{if(hostInit)await vPage.evaluate(hostInit);await vPage.setContent(html,{waitUntil:'load'});}
|
|
927
1109
|
await vPage.waitForFunction(()=>globalThis.toraRuntime);
|
|
928
|
-
await vPage
|
|
1110
|
+
await settleFrame(vPage);
|
|
929
1111
|
await delay(250);
|
|
930
|
-
|
|
1112
|
+
const ending=await playEnding(vPage,this);
|
|
1113
|
+
if(!ending.required&&target){
|
|
931
1114
|
if(target.interaction==='aim-launch'){await vPage.mouse.move(target.x,target.y);await vPage.mouse.down();await vPage.mouse.move(target.x-64,target.y+28);await vPage.mouse.up();}
|
|
932
1115
|
else if(target.interaction==='drag-drop'||target.interaction==='swipe'||target.interaction==='draw'||target.interaction==='erase'){await vPage.mouse.move(target.x,target.y);await vPage.mouse.down();await vPage.mouse.move(target.endX,target.endY,{steps:5});await vPage.mouse.up();}
|
|
933
1116
|
else if(target.interaction==='hold'){await vPage.mouse.move(target.x,target.y);await vPage.mouse.down();await vPage.waitForTimeout(80);await vPage.mouse.up();}
|
|
934
1117
|
else await vPage.mouse.click(target.x,target.y);
|
|
935
1118
|
}
|
|
936
|
-
await delay(
|
|
1119
|
+
await delay(1100);
|
|
937
1120
|
const videoHandle=vPage.video();
|
|
938
1121
|
await videoContext.close();
|
|
939
1122
|
videoContext=null;
|
|
@@ -948,6 +1131,7 @@ async function openPlaywrightSession({html,htmlPath,project,primaryComponentId,n
|
|
|
948
1131
|
bytes:bytes.length,
|
|
949
1132
|
viewport:normalizeViewport(viewport),
|
|
950
1133
|
triageOnly:true,
|
|
1134
|
+
reachedEndCard:ending.available,
|
|
951
1135
|
};
|
|
952
1136
|
}finally{
|
|
953
1137
|
if(videoContext)await videoContext.close().catch(()=>{});
|
|
@@ -969,6 +1153,8 @@ function layoutRemediation(kind){
|
|
|
969
1153
|
'stage-overflow':'Move or resize the component so its transformed bounds remain inside the stage.',
|
|
970
1154
|
'parent-clip-crop':'Resize the child or clipping parent so no visible content is cut off.',
|
|
971
1155
|
'text-overflow':'Enable wrapping or auto-fit and enlarge the text container without reducing legibility.',
|
|
1156
|
+
'text-clipped':'Increase the text container height or reduce copy so no rendered lines are clipped.',
|
|
1157
|
+
'rtl-alignment':'Use right or center alignment for right-to-left copy and verify the rendered direction.',
|
|
972
1158
|
'text-illegible':'Increase the effective text size and contrast to a readable phone presentation.',
|
|
973
1159
|
'touch-target-small':'Provide at least a 44 by 44 CSS-pixel interactive hit area.',
|
|
974
1160
|
'interactive-overlap':'Separate interactive hit areas or change stacking so each target is unambiguous.',
|
|
@@ -981,9 +1167,18 @@ function layoutRemediation(kind){
|
|
|
981
1167
|
'text-clutter-heavy':'Cut narration and tutorial prose; playable ads are an experience, not a tutorial. Keep screens to concise visual cues and short punchy labels.',
|
|
982
1168
|
'particle-style-clash':'Match particle shape to the playable art direction (use circle/square for vector art; reserve pixel-confetti for pixel art).',
|
|
983
1169
|
'header-off-center':'Align centered banner or instruction text horizontally with the panel directly below it in both portrait and landscape.',
|
|
1170
|
+
'anchor-3d-target-offscreen':'Adjust the 3D camera, landscapeCamera settings, or 3D mesh position so every anchored 3D target remains clearly inside all portrait and landscape viewports.',
|
|
1171
|
+
'anchor-3d-misaligned':'Keep each anchored 2D UI overlay aligned with its projected 3D target bounds (reduce offsetX/offsetY or enable fitToProjectedBounds).',
|
|
1172
|
+
'anchor-3d-occluded':'Reposition the 3D camera, target mesh, or blocking foreground 3D mesh so the anchored target is unobstructed across portrait and landscape viewports.',
|
|
984
1173
|
})[kind]??'Repair the reported layout defect and rerun the viewport audit.';
|
|
985
1174
|
}
|
|
986
|
-
function addLayoutReport(audit,viewport,state,blockers,warnings){
|
|
1175
|
+
function addLayoutReport(audit,viewport,state,blockers,warnings,expectedCopy){
|
|
1176
|
+
if(expectedCopy){
|
|
1177
|
+
const expected=Array.isArray(expectedCopy)?expectedCopy:expectedCopy.include??[];
|
|
1178
|
+
for(const text of expected)if(typeof text!=='string'||!text.trim()||!audit?.texts?.some(row=>row.text.trim()===text.trim()))blockers.push(issue('blocker','localized-copy-missing',null,'Ensure every required localized string is visibly rendered in its intended state.',{viewport,detail:`Required copy was not rendered during ${state}: ${text}`,metrics:{state,expected:text}}));
|
|
1179
|
+
for(const text of Array.isArray(expectedCopy)?[]:expectedCopy.exclude??[])if(audit?.texts?.some(row=>row.text.trim()===String(text).trim()))blockers.push(issue('blocker','localized-copy-leaked',null,'Remove stale source-language copy from the localized state.',{viewport,detail:`Excluded copy was rendered during ${state}: ${text}`,metrics:{state,excluded:text}}));
|
|
1180
|
+
}
|
|
1181
|
+
if(expectedCopy&&(!audit||!Array.isArray(audit.texts)))return;
|
|
987
1182
|
if(!audit){
|
|
988
1183
|
warnings.push(issue('warning','layout-audit-unavailable',null,'Expose toraRuntime.auditSceneLayout() so clipping, text, hit-area, overlap, and safe-zone checks can run.',{viewport,detail:`No layout audit API was available for ${state}.`}));
|
|
989
1184
|
return;
|
|
@@ -999,6 +1194,7 @@ async function interact(session,viewport,target,openingState,blockers){
|
|
|
999
1194
|
const result={viewport:normalizeViewport(viewport),componentId:target.componentId,within150Ms:false,deltaType:null,maxResponseMs:INTERACTION_LIMIT_MS};
|
|
1000
1195
|
const beforeState=openingState??await session.getState(),beforeScreenshot=hash(await session.screenshot());
|
|
1001
1196
|
if(typeof session.prepareClick==='function')await session.prepareClick(target);
|
|
1197
|
+
await session.armResponseMeasurement?.();
|
|
1002
1198
|
const deadline=Date.now()+INTERACTION_LIMIT_MS;
|
|
1003
1199
|
try{await session.click(target);}catch(error){
|
|
1004
1200
|
const timedOut=error?.name==='TimeoutError'||error?.code==='ETIMEDOUT'||error?.timedOut===true;
|
|
@@ -1006,7 +1202,7 @@ async function interact(session,viewport,target,openingState,blockers){
|
|
|
1006
1202
|
blockers.push(issue('blocker',kind,target.componentId,'Restore a trusted pointer path to the primary target and ensure its click binding executes promptly.',{viewport,detail:error.message,metrics:{limitMs:INTERACTION_LIMIT_MS}}));
|
|
1007
1203
|
result.error=kind;return result;
|
|
1008
1204
|
}
|
|
1009
|
-
if(Date.now()>deadline){
|
|
1205
|
+
if(Date.now()>deadline&&typeof session.readResponseMeasurement!=='function'){
|
|
1010
1206
|
blockers.push(issue('blocker','interaction-timeout',target.componentId,'Produce immediate state or visual feedback within 150 ms of pointer input.',{viewport,detail:'The primary pointer action completed after the 150 ms response budget.',metrics:{limitMs:INTERACTION_LIMIT_MS}}));
|
|
1011
1207
|
result.error='interaction-timeout';return result;
|
|
1012
1208
|
}
|
|
@@ -1014,8 +1210,10 @@ async function interact(session,viewport,target,openingState,blockers){
|
|
|
1014
1210
|
while(true){
|
|
1015
1211
|
const afterState=await session.getState(),stateDelta=stateChanged(beforeState,afterState);
|
|
1016
1212
|
if(stateDelta){
|
|
1017
|
-
|
|
1018
|
-
|
|
1213
|
+
const browserMs=await session.readResponseMeasurement?.();
|
|
1214
|
+
const onTime=Number.isFinite(browserMs)?browserMs<=INTERACTION_LIMIT_MS:Date.now()<=deadline;
|
|
1215
|
+
if(onTime){result.within150Ms=true;result.deltaType='state';return result;}
|
|
1216
|
+
blockers.push(issue('blocker','interaction-timeout',target.componentId,'Produce immediate state or visual feedback within 150 ms of pointer input.',{viewport,detail:'The first observable response arrived after the 150 ms response budget.',metrics:{limitMs:INTERACTION_LIMIT_MS,...(Number.isFinite(browserMs)?{browserMs:Math.round(browserMs)}:{})}}));
|
|
1019
1217
|
result.error='interaction-timeout';return result;
|
|
1020
1218
|
}
|
|
1021
1219
|
const screenshotDelta=hash(await session.screenshot())!==beforeScreenshot;
|
|
@@ -1042,7 +1240,21 @@ export async function runBrowserQa(options={}){
|
|
|
1042
1240
|
if(!outputDir)throw Error('A deterministic output directory is required');
|
|
1043
1241
|
if(!htmlPath&&typeof options.html!=='string'&&typeof options.htmlString!=='string')throw Error('Supply an HTML artifact path or HTML string');
|
|
1044
1242
|
const html=typeof options.html==='string'?options.html:typeof options.htmlString==='string'?options.htmlString:await readFile(htmlPath,'utf8');
|
|
1045
|
-
const project=options.project??projectFromHtml(html),blockers=[],warnings=[],interactions=[],states=[],screenshots=[];
|
|
1243
|
+
const project=options.project??projectFromHtml(html),blockers=[],warnings=[],interactions=[],states=[],screenshots=[],storeChecks={},anchors3dChecks=[];
|
|
1244
|
+
const compactRect=rect=>rect?{left:Math.round(rect.left*10)/10,top:Math.round(rect.top*10)/10,right:Math.round(rect.right*10)/10,bottom:Math.round(rect.bottom*10)/10}:null;
|
|
1245
|
+
const recordAnchors3d=(result,viewport,state)=>{
|
|
1246
|
+
if(!Array.isArray(result?.anchors3d)||!result.anchors3d.length)return;
|
|
1247
|
+
anchors3dChecks.push({
|
|
1248
|
+
viewport:normalizeViewport(viewport),state,
|
|
1249
|
+
anchors:result.anchors3d.map(row=>({
|
|
1250
|
+
id:row.id,targetId:row.targetId,visible:Boolean(row.visible),
|
|
1251
|
+
behindCamera:Boolean(row.behindCamera),offscreen:Boolean(row.offscreen),
|
|
1252
|
+
clippedFraction:row.clippedFraction,occluded:Boolean(row.occluded),
|
|
1253
|
+
...(row.occluderId?{occluderId:row.occluderId}:{}),
|
|
1254
|
+
targetBounds:compactRect(row.targetBounds),overlayBounds:compactRect(row.overlayBounds),
|
|
1255
|
+
})),
|
|
1256
|
+
});
|
|
1257
|
+
};
|
|
1046
1258
|
let contactSheets=[],motionFilmstrips=[],video=null;
|
|
1047
1259
|
const screenshotDir=resolve(outputDir,'screenshots');await mkdir(screenshotDir,{recursive:true});
|
|
1048
1260
|
const staleCleanup=[
|
|
@@ -1076,7 +1288,16 @@ export async function runBrowserQa(options={}){
|
|
|
1076
1288
|
}catch(error){
|
|
1077
1289
|
blockers.push(issue('blocker','layout-audit-failed',null,'Repair the runtime layout audit so every key state can be inspected.',{viewport,detail:`${state}: ${error.message}`,metrics:{state}}));return;
|
|
1078
1290
|
}
|
|
1079
|
-
addLayoutReport(result,viewport,state,blockers,warnings);
|
|
1291
|
+
addLayoutReport(result,viewport,state,blockers,warnings,options.expectedCopyChecks?.[state]);
|
|
1292
|
+
recordAnchors3d(result,viewport,state);
|
|
1293
|
+
};
|
|
1294
|
+
const checkStore=async(targetSession,state)=>{
|
|
1295
|
+
const result=await targetSession.verifyStore();
|
|
1296
|
+
storeChecks[state]=result;
|
|
1297
|
+
if(result.ok)return;
|
|
1298
|
+
blockers.push(issue('blocker',result.reason,result.componentId??null,
|
|
1299
|
+
'Make the visible Store CTA open the configured destination through one deliberate tap.',
|
|
1300
|
+
{viewport:DEFAULT_VIEWPORTS[1],metrics:{state}}));
|
|
1080
1301
|
};
|
|
1081
1302
|
try{
|
|
1082
1303
|
const useAutoEndCard=!stateHook&&options.autoEndCard!==false&&!browserAdapter&&typeof session.enterEndCard==='function';
|
|
@@ -1084,6 +1305,9 @@ export async function runBrowserQa(options={}){
|
|
|
1084
1305
|
await session.setViewport(viewport);await session.load();
|
|
1085
1306
|
await capture(viewport,'opening');states.push({viewport:normalizeViewport(viewport),state:'opening',status:'checked'});await audit(viewport,'opening');
|
|
1086
1307
|
const openingState=await session.getState(),target=await session.getPrimaryTarget();
|
|
1308
|
+
if((openingState?.model3d?.textureErrors??0)>0){
|
|
1309
|
+
blockers.push(issue('blocker','model-texture-decode-failed',null,'Re-export or re-optimize the 3D GLB asset with valid PNG/JPEG embedded textures.',{viewport,detail:`${openingState.model3d.textureErrors} embedded GLB texture(s) failed to decode at runtime.`,metrics:{textureErrors:openingState.model3d.textureErrors}}));
|
|
1310
|
+
}
|
|
1087
1311
|
if(!target){
|
|
1088
1312
|
blockers.push(issue('blocker','primary-interaction-missing',primaryComponentId??null,'Declare a click event on an enabled component in the start scene and bind meaningful feedback to it.',{viewport,detail:'No generic primary target could be derived from project click events.'}));
|
|
1089
1313
|
states.push({viewport:normalizeViewport(viewport),state:'after-first-input',status:'unavailable',reason:'primary-interaction-missing'});
|
|
@@ -1105,7 +1329,7 @@ export async function runBrowserQa(options={}){
|
|
|
1105
1329
|
blockers.push(issue('blocker','state-hook-failed',null,'Repair the supplied generic state hook or declare the state unavailable.',{viewport,detail:`${state}: ${error.message}`,metrics:{state}}));continue;
|
|
1106
1330
|
}
|
|
1107
1331
|
if(!available){states.push({viewport:normalizeViewport(viewport),state,status:'unavailable',reason:'state-hook-unsupported'});continue;}
|
|
1108
|
-
states.push({viewport:normalizeViewport(viewport),state,status:'checked'});await capture(viewport,state);await audit(viewport,state);
|
|
1332
|
+
states.push({viewport:normalizeViewport(viewport),state,status:'checked',mode:'state-hook'});await capture(viewport,state);await audit(viewport,state);
|
|
1109
1333
|
}
|
|
1110
1334
|
}
|
|
1111
1335
|
if(useAutoEndCard){
|
|
@@ -1119,7 +1343,11 @@ export async function runBrowserQa(options={}){
|
|
|
1119
1343
|
discovered=null;
|
|
1120
1344
|
}
|
|
1121
1345
|
if(discovered&&!discovered.available){
|
|
1122
|
-
|
|
1346
|
+
const reason=discovered.required?'end-card-unreachable':'end-card-not-declared';
|
|
1347
|
+
for(const viewport of DEFAULT_VIEWPORTS)states.push({viewport:normalizeViewport(viewport),state:'end-card',status:'unavailable',reason});
|
|
1348
|
+
if(discovered.required)blockers.push(issue('blocker',reason,null,
|
|
1349
|
+
'Make the winning action reach the end card in the packaged playable. Start any reveal delay on the winning action.',
|
|
1350
|
+
{viewport:DEFAULT_VIEWPORTS[1],metrics:{state:'end-card'}}));
|
|
1123
1351
|
}else if(discovered?.available){
|
|
1124
1352
|
if(wantFilmstrip&&discovered.mode==='real-play'&&typeof session.captureMotionFilmstrip==='function'){
|
|
1125
1353
|
try{
|
|
@@ -1134,6 +1362,8 @@ export async function runBrowserQa(options={}){
|
|
|
1134
1362
|
states.push({viewport:normalizeViewport(viewport),state:'end-card',status:'checked',mode:discovered.mode});
|
|
1135
1363
|
await capture(viewport,'end-card');await audit(viewport,'end-card');
|
|
1136
1364
|
}
|
|
1365
|
+
await session.setViewport(DEFAULT_VIEWPORTS[1]);
|
|
1366
|
+
await checkStore(session,'end-card');
|
|
1137
1367
|
}
|
|
1138
1368
|
if(typeof session.enterTimeout==='function'){
|
|
1139
1369
|
await session.setViewport(DEFAULT_VIEWPORTS[1]);await session.load();
|
|
@@ -1146,7 +1376,11 @@ export async function runBrowserQa(options={}){
|
|
|
1146
1376
|
timedOut=null;
|
|
1147
1377
|
}
|
|
1148
1378
|
if(timedOut&&!timedOut.available){
|
|
1149
|
-
|
|
1379
|
+
const reason=timedOut.required?'timeout-unreachable':'timeout-not-declared';
|
|
1380
|
+
for(const viewport of DEFAULT_VIEWPORTS)states.push({viewport:normalizeViewport(viewport),state:'timeout',status:'unavailable',reason});
|
|
1381
|
+
if(timedOut.required)blockers.push(issue('blocker',reason,null,
|
|
1382
|
+
'Make the gameplay deadline reach a timeout card in the packaged playable.',
|
|
1383
|
+
{viewport:DEFAULT_VIEWPORTS[1],metrics:{state:'timeout'}}));
|
|
1150
1384
|
}else if(timedOut?.available){
|
|
1151
1385
|
const targetSession=timedOut.auditLayout?timedOut:session;
|
|
1152
1386
|
try{
|
|
@@ -1160,8 +1394,10 @@ export async function runBrowserQa(options={}){
|
|
|
1160
1394
|
const components=project?.components??[],byId=new Map(components.map(c=>[c.id,c]));
|
|
1161
1395
|
const active=new Set(components.filter(c=>{if(c.sceneId!==sceneId)return false;for(let cur=c;cur;cur=byId.get(cur.parentId))if(cur.prototype)return false;return true;}).map(c=>c.id));
|
|
1162
1396
|
const res=await targetSession.auditLayout({ids:[...active],interactiveIds:[...new Set([...(project?.events??[]).filter(e=>e.kind==='click'&&active.has(e.componentId)).map(e=>e.componentId),...(project?.gameplay??[]).filter(behavior=>['aim-launch','drag','swipe-input','hold-charge','virtual-joystick','draw-stroke','erase-mask'].includes(behavior.kind)&&active.has(behavior.componentId)).map(behavior=>behavior.componentId)])],network,minTouchPx:MIN_TOUCH_PX});
|
|
1163
|
-
addLayoutReport(res,viewport,'timeout',blockers,warnings);
|
|
1397
|
+
addLayoutReport(res,viewport,'timeout',blockers,warnings,options.expectedCopyChecks?.timeout);
|
|
1164
1398
|
}
|
|
1399
|
+
await targetSession.setViewport(DEFAULT_VIEWPORTS[1]);
|
|
1400
|
+
await checkStore(targetSession,'timeout');
|
|
1165
1401
|
}finally{await timedOut.close?.();}
|
|
1166
1402
|
}
|
|
1167
1403
|
}
|
|
@@ -1197,7 +1433,8 @@ export async function runBrowserQa(options={}){
|
|
|
1197
1433
|
}
|
|
1198
1434
|
}
|
|
1199
1435
|
}finally{await session.close?.();}
|
|
1200
|
-
const
|
|
1436
|
+
for(const state of Object.keys(options.expectedCopyChecks??{}))if(!states.some(row=>row.state===state&&row.status==='checked'))blockers.push(issue('blocker','localized-copy-state-unavailable',null,'Make every state containing localized copy reachable and auditable.',{detail:`Required localized state was not checked: ${state}`,metrics:{state}}));
|
|
1437
|
+
const report=formatCreativeQaReport({scope:'browser',blockers,warnings,interactions,states,screenshots,contactSheets,motionFilmstrips,video,checks:{viewports:DEFAULT_VIEWPORTS,browserContexts:wantVideo?2:1,primaryInteraction:'project-click-events',storeCta:storeChecks,interactionLimitMs:INTERACTION_LIMIT_MS,minTouchPx:MIN_TOUCH_PX,stateHook:stateHook?typeof stateHook:'not-supplied',expectedCopyStates:Object.keys(options.expectedCopyChecks??{}),...(anchors3dChecks.length?{anchors3d:anchors3dChecks}:{})}});
|
|
1201
1438
|
await writeCreativeQaReport(report,outputDir);return report;
|
|
1202
1439
|
}
|
|
1203
1440
|
export const runBrowserAudit=runBrowserQa;
|