@pie-players/pie-section-player-tools-session-debugger 0.3.5 → 0.3.8

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.
@@ -59,13 +59,18 @@
59
59
 
60
60
  type SectionControllerLike = {
61
61
  getRuntimeState?: () => SectionAttemptSliceLike | null;
62
- getSessionState?: () => SectionSessionStateLike | null;
62
+ getSession?: () => SectionSessionStateLike | null;
63
63
  subscribe?: (listener: (event: { itemId?: string; timestamp?: number }) => void) => () => void;
64
64
  };
65
65
 
66
66
  type ToolkitCoordinatorLike = {
67
67
  getSectionController?: (args: { sectionId: string; attemptId?: string }) => SectionControllerLike | undefined;
68
- subscribeSectionEvents: (args: {
68
+ subscribeItemEvents?: (args: {
69
+ sectionId: string;
70
+ attemptId?: string;
71
+ listener: (event: { itemId?: string; timestamp?: number }) => void;
72
+ }) => () => void;
73
+ subscribeSectionLifecycleEvents?: (args: {
69
74
  sectionId: string;
70
75
  attemptId?: string;
71
76
  listener: (event: { itemId?: string; timestamp?: number }) => void;
@@ -148,7 +153,7 @@
148
153
  ) {
149
154
  const controller = controllerOverride || getController();
150
155
  const sectionSlice = controller?.getRuntimeState?.() || null;
151
- const persistedSlice = controller?.getSessionState?.() || null;
156
+ const persistedSlice = controller?.getSession?.() || null;
152
157
  controllerAvailable = Boolean(controller);
153
158
  sessionPanelSnapshot = {
154
159
  currentItemIndex:
@@ -225,11 +230,20 @@
225
230
  return;
226
231
  }
227
232
  detachControllerSubscription();
228
- unsubscribeController = toolkitCoordinator?.subscribeSectionEvents({
233
+ const unsubscribeItem = toolkitCoordinator?.subscribeItemEvents?.({
229
234
  sectionId,
230
235
  attemptId,
231
236
  listener: handleControllerEvent
232
237
  }) || null;
238
+ const unsubscribeSection = toolkitCoordinator?.subscribeSectionLifecycleEvents?.({
239
+ sectionId,
240
+ attemptId,
241
+ listener: handleControllerEvent
242
+ }) || null;
243
+ unsubscribeController = () => {
244
+ unsubscribeItem?.();
245
+ unsubscribeSection?.();
246
+ };
233
247
  subscriptionTarget.controller = controller;
234
248
  subscriptionTarget.sectionId = sectionId;
235
249
  subscriptionTarget.attemptId = nextAttemptId;