// Cotton Meetings' wiring, in the Meetings app alone: the recorder// (`CottonUI`'s `MeetingsEngine`) reaches the core once the app has opened// it; the intents (`CottonMeetingsLive`) reach the recorder; and every change// of the recording is shown as its Live Activity, in the kit's words.#if COTTON_MEETINGSimportAppIntentsimportCottonKitimportCottonMeetingsLiveimportCottonUI/// Lets the app's target find the intents the package declares.structCottonMeetingsIntents: AppIntentsPackage {staticlet includedPackages: [any AppIntentsPackage.Type] = [MeetingsLivePackage.self] } @MainActorenumMeetingsGlue {staticfunc attach(_ core: @escaping @Sendable () async -> (any CottonCalling)?) {let engine = MeetingsEngine.shared engine.attach(core)// A process that ended mid-recording left its Activity standing;// nothing is recording at launch, so it goes.MeetingsLiveActivity.end() engine.onLive = { live inMeetingsLiveActivity.show(live.map(content)) }MeetingsIntentBridge.perform = { act inawait perform(act, on: engine) }// Every take a killed process left is finished by the core.Task { await engine.recoverAtLaunch() } }staticfunc perform(_ act: MeetingsLiveAct, on engine: MeetingsEngine) async -> MeetingsLiveAnswer {switch act {case .startMeeting, .startMemo:switchawait engine.start(act == .startMemo ? .memo : .meeting) {case .recording: return .donecase .blocked: return .needsAppcase .failed(let why): return .refused(why) }case .pause: engine.pause()case .resume: engine.resume()case .mark: engine.mark()case .stop: engine.stop() }return .done }staticfunc content(_ live: MeetingsLive) -> MeetingActivityAttributes.ContentState {MeetingActivityAttributes.ContentState( memo: live.kind == .memo, startedAt: live.startedAt, bankedMs: live.bankedMs, runningSince: live.runningSince, marks: live.marks, headline: live.headline, pause: live.words.pause, resume: live.words.resume, stop: live.words.stop, mark: live.words.mark) } }#endif