  // SkaperStudio private cloud adapter: use the native, editable .lyl package.
  useEffect(() => {
    let busy=false;
    const receive=async(event:MessageEvent)=>{
      const request=event.data;
      if(event.origin!==location.origin||event.source!==window.parent||request?.channel!=="skaperstudio-cloud-v1"||!["snapshot","status"].includes(request.type))return;
      const reply=(value:Record<string,unknown>)=>window.parent.postMessage({channel:"skaperstudio-cloud-v1",id:request.id,...value},location.origin);
      if(request.type==="status"){reply({ok:true});return}
      if(busy){reply({error:"busy"});return}busy=true;
      try{
        const view=historyViewStateRef.current;
        const history=view?editorHistoryBranch(historyRef.current,view.index,"unlimited"):editorHistoryForExport(historyRef.current,historyIndexRef.current,"unlimited");
        const data=await exportLylProject({projectId:projectInfoRef.current.projectId,projectName:projectInfoRef.current.projectName,createdAt:projectInfoRef.current.projectCreatedAt,modifiedAt:Date.now(),shapes:view?view.shapes:shapesRef.current,notes:view?view.notes:notesRef.current,history:history.entries,historyIndex:history.index,assets:projectAssetsRef.current,attachments:projectAttachmentsRef.current,workspace:workspaceSettingsRef.current,snapGrid,placementElevation:view?view.placementElevation:placementElevation,placementWorkplane:view?view.placementWorkplane:placementWorkplane,sketchPlacementWorkplane:view?view.placementWorkplane:placementWorkplane});
        reply({ok:true,data,title:projectInfoRef.current.projectName,localId:projectInfoRef.current.projectId});
      }catch(error){reply({error:error instanceof Error?error.message:"export_failed"})}finally{busy=false}
    };
    window.addEventListener('message',receive);return()=>window.removeEventListener('message',receive);
  },[snapGrid,placementElevation,placementWorkplane]);
