pulse-pixelstream-types 0.13.10

Shared Myko entity and command types for the Pulse Pixelstream recording cell.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
//! Shared myko entity/command/report types for the pixelstreaming app. WASM-safe:
//! the Leptos frontend and the native server both build against this crate, and
//! the TS bindings are generated from it.
//!
//! One `#[myko_item]` per module (the macro emits per-module helpers that would
//! otherwise collide).

pub mod cam_pref;
pub mod camera_home;
pub mod collection;
pub mod collection_membership;
pub mod commands;
pub mod control_lock;
pub mod frame_capture;
pub mod frame_capture_status;
pub mod frame_capture_target;
pub(crate) mod legacy_capture_run;
pub(crate) mod legacy_shot_list;
pub mod otio;
pub mod recording_job;
pub mod recording_job_request;
pub mod recording_job_status;
pub mod recording_plan;
pub mod recording_request;
pub mod recording_status;
pub mod reports;
pub mod shot;
pub mod stream;
pub mod timeline;
pub mod viewer;

/// Shared, validated editorial identity for synchronized nDisplay capture.
/// Pulse Cluster owns the wire contract; Pixelstream authors and persists it.
pub use pulse_capture_types::{
    CaptureCollection, CaptureCollectionId, CaptureContext, CaptureLabel, CaptureLibraryId,
    CollectionKind, CollectionPath, ContentRevision, EditorialContextError,
    PixelstreamCollectionPathSegment, PixelstreamCollectionRef,
};

pub use cam_pref::*;
pub use camera_home::*;
pub use collection::*;
pub use collection_membership::*;
pub use commands::*;
pub use control_lock::*;
pub use frame_capture::*;
pub use frame_capture_status::*;
pub use frame_capture_target::*;
pub use otio::*;
pub use recording_job::*;
pub use recording_job_request::*;
pub use recording_job_status::*;
pub use recording_plan::*;
pub use recording_request::*;
pub use recording_status::*;
pub use reports::*;
pub use shot::*;
pub use stream::*;
pub use timeline::*;
pub use viewer::*;

/// Force-link so the `#[myko_item]` / `#[myko_command]` / `#[myko_report]`
/// inventory registrations are pulled into whichever binary depends on this
/// crate. Call once at startup.
pub fn link() {}

#[cfg(test)]
mod deser_tests {
    use crate::{
        collection::CollectionPathSegment,
        commands::{JoinStream, MigrateOtioTimelines},
        control_lock::ControlLock,
        recording_job_request::{RecordingJobRequest, RecordingJobRequestId},
        recording_job_status::{RecordingJobStatus, RecordingJobStatusId},
        recording_plan::{RecordingJobAction, RecordingJobPhase, ShotEntryPlan},
        recording_request::{CaptureKind, RecordingKind, RecordingRequest, RecordingRequestId},
        recording_status::{RecordingState, RecordingStatus, RecordingStatusId},
        shot::{Shot, ShotId, ShotKind, DEFAULT_SHOT_LIBRARY_ID},
        timeline::{ShotDirection, ShotEntry, ShotEntryMode, Timeline, TimelineId},
        viewer::Viewer,
        CaptureContext, CaptureLabel, CollectionPath, ContentRevision, StoredCaptureContext,
    };

    #[test]
    fn shared_capture_context_uses_cluster_wire_contract() {
        let context = CaptureContext {
            collection: CollectionPath::try_from("cycle_4/moment_2".to_owned())
                .unwrap()
                .into(),
            label: Some(CaptureLabel::try_from("hero orbit".to_owned()).unwrap()),
            content_revision: Some(ContentRevision::try_from("workspace:42".to_owned()).unwrap()),
        };
        let value = serde_json::to_value(context).unwrap();
        assert_eq!(value["collection"], "cycle_4/moment_2");
        assert_eq!(value["label"], "hero orbit");
        assert_eq!(value["contentRevision"], "workspace:42");
    }

    #[test]
    fn stored_capture_context_is_wire_identical_to_the_bare_contract() {
        // The newtype exists so this crate can implement Filterable for an
        // entity field whose type another crate owns. It must be invisible on
        // the wire: the prod event store holds ~1.5M events written before it
        // existed, and a replay that fails here is a data-loss-grade upgrade.
        let context = CaptureContext {
            collection: CollectionPath::try_from("cycle_4/moment_2".to_owned())
                .unwrap()
                .into(),
            label: Some(CaptureLabel::try_from("hero orbit".to_owned()).unwrap()),
            content_revision: Some(ContentRevision::try_from("workspace:42".to_owned()).unwrap()),
        };
        let bare = serde_json::to_value(&context).unwrap();
        let stored = serde_json::to_value(StoredCaptureContext(context.clone())).unwrap();
        assert_eq!(bare, stored, "newtype changed the serialized form");

        // And an event written before the newtype still reads back.
        let replayed: StoredCaptureContext = serde_json::from_value(bare).unwrap();
        assert_eq!(replayed.0, context);
    }

    #[test]
    fn recording_job_status_replays_a_pre_newtype_event() {
        // Shape taken from a persisted RecordingJobStatus event.
        let json = r#"{"streamerId":"render-13","jobId":"job-1","captureContext":{"collection":"cycle_4/moment_2","label":"hero orbit","contentRevision":"workspace:42"},"id":"render-13"}"#;
        let status = serde_json::from_str::<RecordingJobStatus>(json)
            .expect("pre-newtype RecordingJobStatus must still deserialize");
        let context = status
            .capture_context
            .as_ref()
            .expect("captureContext preserved");
        assert_eq!(
            context.label.as_ref().map(CaptureLabel::as_str),
            Some("hero orbit")
        );
        // Round-trips back to the same wire form.
        let reserialized = serde_json::to_value(&status).unwrap();
        assert_eq!(
            reserialized["captureContext"]["collection"],
            "cycle_4/moment_2"
        );
    }

    // Exactly what the server sends over the wire (from a captured query-response).
    #[test]
    fn controllock_wire_deser() {
        let j = r#"{"streamId":"s1","viewerId":"v1","clientId":"c1","id":"s1"}"#;
        let r = serde_json::from_str::<ControlLock>(j);
        assert!(r.is_ok(), "ControlLock deser failed: {:?}", r.err());
    }

    #[test]
    fn viewer_wire_deser() {
        let j = r#"{"streamId":"s1","viewerId":"v1","name":"n","color":"red","cursor":null,"clientId":"c1","id":"s1:v1"}"#;
        let r = serde_json::from_str::<Viewer>(j);
        assert!(r.is_ok(), "Viewer deser failed: {:?}", r.err());
    }

    #[test]
    fn legacy_guest_join_stream_defaults_optional_identity() {
        let j = r#"{"streamId":"s1","viewerId":"v1","name":"Anonymous Puffin","color":"red"}"#;
        let join =
            serde_json::from_str::<JoinStream>(j).expect("legacy JoinStream must deserialize");
        assert_eq!(join.name, "Anonymous Puffin");
        assert!(join.identity_issuer.is_none());
        assert!(join.identity_subject.is_none());
        assert!(join.avatar_url.is_none());
    }

    #[test]
    fn shot_kind_uses_film_accurate_static_wire_term() {
        assert_eq!(serde_json::to_value(ShotKind::Static).unwrap(), "static");
        for legacy in ["stationary", "preset", "preset_hold"] {
            let encoded = format!("\"{legacy}\"");
            assert_eq!(
                serde_json::from_str::<ShotKind>(&encoded).unwrap(),
                ShotKind::Static
            );
        }
        assert_eq!(
            Shot::stable_id("shared", &ShotKind::Static, "Wide"),
            "shared:shot:static:Wide"
        );
    }

    #[test]
    fn recording_status_uses_only_the_0_5_wire_contract() {
        let status = RecordingStatus {
            id: RecordingStatusId::from("render-13".to_owned()),
            streamer_id: "render-13".to_owned(),
            state: RecordingState::SavedToNas,
            file_name: "capture.mp4".to_owned(),
            nas_path: "/mnt/nas/recordings/pixelstream/capture.mkv".to_owned(),
            dropbox_path: "recordings/pixelstream/cycle_3/dailies/capture.mp4".to_owned(),
            error: String::new(),
            started_at_ms: 1_785_460_000_000,
        };
        let value = serde_json::to_value(status).unwrap();
        assert_eq!(value["state"], "ready_for_handoff");
        assert_eq!(value["fileName"], "capture.mp4");
        assert_eq!(value["startedAtMs"], 1_785_460_000_000_u64);
        // Both destinations travel as themselves; the UI used to compose a
        // Dropbox path out of a file name and show it for an artifact that was
        // still only on the NAS.
        assert_eq!(
            value["nasPath"],
            "/mnt/nas/recordings/pixelstream/capture.mkv"
        );
        assert_eq!(
            value["dropboxPath"],
            "recordings/pixelstream/cycle_3/dailies/capture.mp4"
        );
        assert!(value.get("path").is_none());
        assert!(value.get("startedAt").is_none());

        let old = r#"{
            "id":"render-13",
            "streamerId":"render-13",
            "state":"done",
            "path":"capture.mp4",
            "startedAt":1785460000000
        }"#;
        assert!(serde_json::from_str::<RecordingStatus>(old).is_err());
    }

    #[test]
    fn recording_request_direction_is_backward_compatible_and_explicit() {
        let legacy = r#"{
            "id":"render-13",
            "streamerId":"render-13",
            "active":true,
            "rig":"Hero Push Forward"
        }"#;
        let legacy = serde_json::from_str::<RecordingRequest>(legacy).unwrap();
        assert_eq!(legacy.travel_direction, None);
        assert_eq!(legacy.shot_index, None);
        assert_eq!(legacy.capture_kind, RecordingKind::Video);

        let reverse = RecordingRequest {
            id: RecordingRequestId::from("render-13".to_owned()),
            streamer_id: "render-13".to_owned(),
            active: true,
            capture_kind: RecordingKind::Screenshot,
            rig: "Hero Push Forward".to_owned(),
            preset: String::new(),
            stream_name: String::new(),
            travel_direction: Some(ShotDirection::Reverse),
            shot_index: Some(8),
            take_number: 1,
            entry_id: "entry-8".to_owned(),
            timeline_id: String::new(),
            timeline_name: String::new(),
            timeline_revision: 0,
            collection_path: Vec::new(),
            requested_at_ms: 1,
        };
        let value = serde_json::to_value(reverse).unwrap();
        assert_eq!(value["travelDirection"], "reverse");
        assert_eq!(value["shotIndex"], 8);
        assert_eq!(value["captureKind"], "screenshot");
    }

    #[test]
    fn recording_job_wire_contract_is_explicit_and_resume_safe() {
        assert_eq!(
            serde_json::to_value(RecordingJobAction::Pause).unwrap(),
            "pause"
        );
        let item = ShotEntryPlan {
            entry_id: "entry-1".to_owned(),
            shot_id: "shot-1".to_owned(),
            name: "Floor Dolly".to_owned(),
            shot_index: Some(4),
            kind: ShotKind::Moving,
            target_name: "Floor Dolly".to_owned(),
            translation_speed_cm_s: 10.0,
            rotation_speed_deg_s: 2.0,
            hold_duration_ms: 5_000,
            travel_duration_ms: 30_000,
            direction: ShotDirection::Reverse,
            next_take_number: 1,
            open_ended: false,
        };
        let request = RecordingJobRequest {
            id: RecordingJobRequestId::from("render-02".to_owned()),
            streamer_id: "render-02".to_owned(),
            job_id: "job-1".to_owned(),
            command_id: "command-1".to_owned(),
            action: RecordingJobAction::Start,
            capture_kind: CaptureKind::Video,
            capture_context: None,
            timeline_id: "timeline-1".to_owned(),
            timeline_name: "Client selects".to_owned(),
            timeline_revision: 4,
            collection_id: "launch-film".to_owned(),
            collection_path: vec![
                CollectionPathSegment {
                    collection_id: "autumn-campaign".to_owned(),
                    name: "Autumn campaign".to_owned(),
                },
                CollectionPathSegment {
                    collection_id: "launch-film".to_owned(),
                    name: "Launch film".to_owned(),
                },
            ],
            entries: vec![item.clone()],
            preset_duration_ms: 0,
            translation_speed_cm_s: 0.0,
            rotation_speed_deg_s: 0.0,
            requested_at_ms: 10,
        };
        let value = serde_json::to_value(request).unwrap();
        assert_eq!(value["action"], "start");
        assert_eq!(value["timelineId"], "timeline-1");
        assert_eq!(value["timelineName"], "Client selects");
        assert_eq!(value["timelineRevision"], 4);
        assert!(value.get("shotListId").is_none());
        assert_eq!(value["collectionId"], "launch-film");
        assert_eq!(value["collectionPath"][0]["name"], "Autumn campaign");
        assert_eq!(value["collectionPath"][1]["name"], "Launch film");
        assert_eq!(value["entries"][0]["translationSpeedCmS"], 10.0);
        assert_eq!(value["entries"][0]["rotationSpeedDegS"], 2.0);
        assert_eq!(value["entries"][0]["direction"], "reverse");
        assert_eq!(value["entries"][0]["shotIndex"], 4);

        let mut status = RecordingJobStatus {
            id: RecordingJobStatusId::from("render-02".to_owned()),
            streamer_id: "render-02".to_owned(),
            job_id: "job-1".to_owned(),
            capture_kind: CaptureKind::Video,
            capture_context: None,
            timeline_id: "timeline-1".to_owned(),
            timeline_name: "Client selects".to_owned(),
            timeline_revision: 4,
            collection_id: "launch-film".to_owned(),
            collection_path: vec![CollectionPathSegment {
                collection_id: "launch-film".to_owned(),
                name: "Launch film".to_owned(),
            }],
            phase: RecordingJobPhase::Paused,
            pause_requested: false,
            entries: vec![item],
            index: 0,
            completed: 0,
            error: "resume required".to_owned(),
            updated_at_ms: 11,
            elapsed_ms: 4_000,
            estimated_total_ms: 90_000,
            estimated_remaining_ms: 86_000,
            takes: Vec::new(),
            started_at_ms: 1,
        };
        assert!(status.can_resume());
        assert_eq!(status.resume_progress(), (1, 1));
        assert_eq!(serde_json::to_value(&status).unwrap()["phase"], "paused");

        status.phase = RecordingJobPhase::Canceled;
        assert!(!status.can_resume());

        status.phase = RecordingJobPhase::Complete;
        status.error = "1 take rejected; the job continued".to_owned();
        assert!(status.can_resume());
        assert_eq!(
            status.summary(),
            "Recording complete with warnings · 0 of 1 takes durable on NAS · 1 take rejected; the job continued"
        );
    }

    #[test]
    fn timeline_mode_migrates_legacy_enabled_values() {
        assert_eq!(
            serde_json::from_str::<ShotEntryMode>("true").unwrap(),
            ShotEntryMode::Forward
        );
        assert_eq!(
            serde_json::from_str::<ShotEntryMode>("false").unwrap(),
            ShotEntryMode::Excluded
        );
        assert_eq!(
            serde_json::from_str::<ShotEntryMode>(r#""both""#).unwrap(),
            ShotEntryMode::Both
        );

        let legacy_shot = r#"{
            "id":"render-02:moving:Floor Dolly",
            "streamerId":"render-02",
            "name":"Floor Dolly",
            "kind":"moving",
            "targetName":"Floor Dolly",
            "translationSpeedCmS":10.0,
            "rotationSpeedDegS":2.0,
            "holdDurationMs":5000,
            "batchMode":"excluded",
            "sortOrder":0
        }"#;
        let shot = serde_json::from_str::<Shot>(legacy_shot).unwrap();
        assert_eq!(shot.effective_library_id(), "shared");
        assert_eq!(shot.default_entry_mode, ShotEntryMode::Excluded);
        assert_eq!(shot.shot_index, 0);
        let shot_wire = serde_json::to_value(shot).unwrap();
        assert_eq!(shot_wire["sortOrder"], 0);
        assert!(shot_wire.get("shotIndex").is_none());

        let legacy_plan = r#"{
            "shotId":"shot-1",
            "name":"Floor Dolly",
            "kind":"moving",
            "targetName":"Floor Dolly",
            "translationSpeedCmS":10.0,
            "rotationSpeedDegS":2.0,
            "holdDurationMs":5000
        }"#;
        let legacy_plan = serde_json::from_str::<ShotEntryPlan>(legacy_plan).unwrap();
        assert_eq!(legacy_plan.direction, ShotDirection::Forward);
        assert_eq!(legacy_plan.shot_index, None);
    }

    #[test]
    fn legacy_clips_without_overrides_remain_compatible() {
        let mut timeline = Timeline {
            id: TimelineId::from(Timeline::legacy_default_id("render-02")),
            library_id: "shared".to_owned(),
            streamer_id: "render-02".to_owned(),
            name: "Client selects".to_owned(),
            revision: 3,
            entries: vec![ShotEntry {
                shot_id: "shot-a".to_owned(),
                direction: ShotEntryMode::Both,
                ..Default::default()
            }],
            sort_order: 0,
        };

        timeline.normalize_entries();
        assert_eq!(timeline.entries.len(), 2);
        assert_eq!(timeline.capture_count(), 2);
        assert_eq!(timeline.next_revision(), 4);
        assert!(timeline
            .entries
            .iter()
            .all(|entry| !entry.entry_id.is_empty()));
        assert_eq!(timeline.entries[0].direction, ShotEntryMode::Forward);
        assert_eq!(timeline.entries[1].direction, ShotEntryMode::Reverse);

        timeline.add_entry("shot-b", ShotEntryMode::Forward);

        let first_entry_id = timeline.entries[0].entry_id.clone();
        timeline.remove_entry(&first_entry_id);
        assert_eq!(timeline.entries.len(), 2);

        let value = serde_json::to_value(timeline).unwrap();
        assert_eq!(value["entries"][0]["shotId"], "shot-a");
        assert!(value["entries"][0].get("translationSpeedCmS").is_none());
        assert!(value["entries"][0].get("rotationSpeedDegS").is_none());
        assert!(value.get("clips").is_none());
        assert!(value["entries"][0].get("cueId").is_none());
        assert!(value["entries"][0].get("clipId").is_none());
        assert!(value["entries"][0].get("mode").is_none());
    }

    #[test]
    fn the_same_shot_has_independent_parameters_in_each_timeline() {
        let shot = Shot {
            id: ShotId::from("shared:shot:moving:hero"),
            library_id: DEFAULT_SHOT_LIBRARY_ID.to_owned(),
            streamer_id: String::new(),
            name: "Hero".to_owned(),
            kind: ShotKind::Moving,
            target_name: "Hero".to_owned(),
            translation_speed_cm_s: 10.0,
            rotation_speed_deg_s: 2.0,
            hold_duration_ms: 5_000,
            travel_duration_ms: 30_000,
            default_entry_mode: ShotEntryMode::Forward,
            shot_index: 0,
        };
        let mut fast = ShotEntry::from_shot(&shot, ShotEntryMode::Forward);
        let mut slow = ShotEntry::from_shot(&shot, ShotEntryMode::Forward);
        fast.translation_speed_cm_s = Some(20.0);
        fast.travel_duration_ms = Some(15_000);
        slow.translation_speed_cm_s = Some(5.0);
        slow.travel_duration_ms = Some(60_000);

        assert_eq!(fast.resolved_shot(&shot).translation_speed_cm_s, 20.0);
        assert_eq!(slow.resolved_shot(&shot).translation_speed_cm_s, 5.0);
        assert_eq!(fast.resolved_shot(&shot).travel_duration_ms, 15_000);
        assert_eq!(slow.resolved_shot(&shot).travel_duration_ms, 60_000);
        assert_eq!(shot.translation_speed_cm_s, 10.0);
    }

    #[test]
    fn timeline_normalizes_membership_without_persisting_a_second_index() {
        let legacy = r#"{
            "id":"render-02:timeline:legacy",
            "streamerId":"render-02",
            "name":"Legacy",
            "version":0,
            "entries":[
                {"shotId":"shot-b","mode":"forward"},
                {"shotId":"shot-a","mode":"reverse"}
            ],
            "sortOrder":0
        }"#;
        let mut timeline: Timeline = serde_json::from_str(legacy).unwrap();
        timeline.normalize_entries();
        assert_eq!(timeline.entries[0].shot_id, "shot-b");
        assert_eq!(timeline.entries[1].shot_id, "shot-a");
        assert!(serde_json::to_value(timeline).unwrap()["entries"][0]
            .get("index")
            .is_none());
    }

    #[test]
    fn timeline_migration_accepts_the_myko_transaction_envelope() {
        serde_json::from_str::<MigrateOtioTimelines>(r#"{"tx":"migration-tx"}"#)
            .expect("migration command must accept Myko's map-shaped envelope");
    }
}

// myko 6 requires every queryable field's type to implement `Filterable`.
// Plain enums get value equality (`Eq`/`In` filters work as an operator would
// expect); payload structs with no query-meaningful equality take the opaque
// escape hatch, which renders their query field structurally absent.
myko::impl_filterable_eq!(
    crate::recording_plan::RecordingJobAction,
    crate::recording_plan::RecordingJobPhase,
    crate::recording_request::RecordingKind,
    crate::recording_status::RecordingState,
    crate::shot::ShotKind,
    crate::timeline::ShotDirection,
    crate::timeline::ShotEntryMode,
    crate::frame_capture::FrameCapturePhase,
);

myko::impl_filterable_opaque!(
    crate::frame_capture::FrameCaptureTarget,
    StoredCaptureContext,
);

/// `CaptureContext` as an entity field.
///
/// Every field of a `#[myko_item]` needs `Filterable`, and this crate cannot
/// implement it for `CaptureContext` — pulse-capture-types owns that type and
/// the orphan rule forbids the impl. A newtype this crate does own can carry
/// it, and `Unfilterable` is the right filter anyway: frozen editorial
/// identity is payload, never a query axis.
///
/// `#[serde(transparent)]` means the wire form is exactly the bare contract
/// type, so persisted events and TS bindings are unchanged — this exists for
/// the type system, not for the format.
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize, myko::TS)]
#[serde(transparent)]
#[ts(type = "unknown")]
pub struct StoredCaptureContext(pub CaptureContext);

impl From<CaptureContext> for StoredCaptureContext {
    fn from(context: CaptureContext) -> Self {
        Self(context)
    }
}

impl From<StoredCaptureContext> for CaptureContext {
    fn from(stored: StoredCaptureContext) -> Self {
        stored.0
    }
}

impl std::ops::Deref for StoredCaptureContext {
    type Target = CaptureContext;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}