@pie-players/pie-section-player-tools-event-debugger 0.3.2 → 0.3.4
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/EventPanel.svelte +91 -139
- package/dist/section-player-tools-event-debugger.js +1716 -1418
- package/package.json +8 -10
package/EventPanel.svelte
CHANGED
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
|
|
14
14
|
<script lang="ts">
|
|
15
15
|
import "@pie-players/pie-theme/components.css";
|
|
16
|
+
import PanelResizeHandle from "@pie-players/pie-section-player-tools-shared/PanelResizeHandle.svelte";
|
|
17
|
+
import PanelWindowControls from "@pie-players/pie-section-player-tools-shared/PanelWindowControls.svelte";
|
|
18
|
+
import {
|
|
19
|
+
computePanelSizeFromViewport,
|
|
20
|
+
createFloatingPanelPointerController,
|
|
21
|
+
getSectionControllerFromCoordinator,
|
|
22
|
+
isMatchingSectionControllerLifecycleEvent,
|
|
23
|
+
} from "@pie-players/pie-section-player-tools-shared";
|
|
16
24
|
import { createEventDispatcher, onDestroy, onMount } from "svelte";
|
|
17
25
|
|
|
18
26
|
type ControllerEvent = {
|
|
@@ -29,6 +37,7 @@
|
|
|
29
37
|
| "item-session-data-changed"
|
|
30
38
|
| "item-session-meta-changed"
|
|
31
39
|
| "item-selected"
|
|
40
|
+
| "section-navigation-change"
|
|
32
41
|
| "content-loaded"
|
|
33
42
|
| "item-player-error"
|
|
34
43
|
| "item-complete-changed"
|
|
@@ -76,16 +85,6 @@
|
|
|
76
85
|
let records = $state<EventRecord[]>([]);
|
|
77
86
|
let controllerAvailable = $state(false);
|
|
78
87
|
|
|
79
|
-
let isDragging = false;
|
|
80
|
-
let isResizing = false;
|
|
81
|
-
let dragStartX = 0;
|
|
82
|
-
let dragStartY = 0;
|
|
83
|
-
let dragStartPanelX = 0;
|
|
84
|
-
let dragStartPanelY = 0;
|
|
85
|
-
let resizeStartX = 0;
|
|
86
|
-
let resizeStartY = 0;
|
|
87
|
-
let resizeStartWidth = 0;
|
|
88
|
-
let resizeStartHeight = 0;
|
|
89
88
|
let nextRecordId = 1;
|
|
90
89
|
let activeController: {
|
|
91
90
|
subscribe?: (listener: (event: ControllerEvent) => void) => () => void;
|
|
@@ -139,6 +138,7 @@
|
|
|
139
138
|
value === "item-session-data-changed" ||
|
|
140
139
|
value === "item-session-meta-changed" ||
|
|
141
140
|
value === "item-selected" ||
|
|
141
|
+
value === "section-navigation-change" ||
|
|
142
142
|
value === "content-loaded" ||
|
|
143
143
|
value === "item-player-error" ||
|
|
144
144
|
value === "item-complete-changed" ||
|
|
@@ -153,6 +153,7 @@
|
|
|
153
153
|
|
|
154
154
|
function getEventLevel(type: EventType): EventLevel {
|
|
155
155
|
if (
|
|
156
|
+
type === "section-navigation-change" ||
|
|
156
157
|
type === "section-loading-complete" ||
|
|
157
158
|
type === "section-items-complete-changed" ||
|
|
158
159
|
type === "section-error"
|
|
@@ -211,12 +212,10 @@
|
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
function getController(): any | null {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
attemptId,
|
|
219
|
-
}) || null
|
|
215
|
+
return getSectionControllerFromCoordinator(
|
|
216
|
+
toolkitCoordinator,
|
|
217
|
+
sectionId,
|
|
218
|
+
attemptId,
|
|
220
219
|
);
|
|
221
220
|
}
|
|
222
221
|
|
|
@@ -247,55 +246,27 @@
|
|
|
247
246
|
}) || null;
|
|
248
247
|
}
|
|
249
248
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
document.removeEventListener("mouseup", stopDrag);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function startResize(event: MouseEvent) {
|
|
275
|
-
isResizing = true;
|
|
276
|
-
resizeStartX = event.clientX;
|
|
277
|
-
resizeStartY = event.clientY;
|
|
278
|
-
resizeStartWidth = panelWidth;
|
|
279
|
-
resizeStartHeight = panelHeight;
|
|
280
|
-
document.addEventListener("mousemove", onResize);
|
|
281
|
-
document.addEventListener("mouseup", stopResize);
|
|
282
|
-
event.preventDefault();
|
|
283
|
-
event.stopPropagation();
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function onResize(event: MouseEvent) {
|
|
287
|
-
if (!isResizing) return;
|
|
288
|
-
const deltaX = event.clientX - resizeStartX;
|
|
289
|
-
const deltaY = event.clientY - resizeStartY;
|
|
290
|
-
panelWidth = Math.max(340, Math.min(resizeStartWidth + deltaX, window.innerWidth - panelX));
|
|
291
|
-
panelHeight = Math.max(260, Math.min(resizeStartHeight + deltaY, window.innerHeight - panelY));
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function stopResize() {
|
|
295
|
-
isResizing = false;
|
|
296
|
-
document.removeEventListener("mousemove", onResize);
|
|
297
|
-
document.removeEventListener("mouseup", stopResize);
|
|
298
|
-
}
|
|
249
|
+
const pointerController = createFloatingPanelPointerController({
|
|
250
|
+
getState: () => ({
|
|
251
|
+
x: panelX,
|
|
252
|
+
y: panelY,
|
|
253
|
+
width: panelWidth,
|
|
254
|
+
height: panelHeight,
|
|
255
|
+
}),
|
|
256
|
+
setState: (next: {
|
|
257
|
+
x: number;
|
|
258
|
+
y: number;
|
|
259
|
+
width: number;
|
|
260
|
+
height: number;
|
|
261
|
+
}) => {
|
|
262
|
+
panelX = next.x;
|
|
263
|
+
panelY = next.y;
|
|
264
|
+
panelWidth = next.width;
|
|
265
|
+
panelHeight = next.height;
|
|
266
|
+
},
|
|
267
|
+
minWidth: 340,
|
|
268
|
+
minHeight: 260,
|
|
269
|
+
});
|
|
299
270
|
|
|
300
271
|
function clearRecords() {
|
|
301
272
|
records = [];
|
|
@@ -326,20 +297,32 @@
|
|
|
326
297
|
);
|
|
327
298
|
|
|
328
299
|
onMount(() => {
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
300
|
+
const initial = computePanelSizeFromViewport(
|
|
301
|
+
{ width: window.innerWidth, height: window.innerHeight },
|
|
302
|
+
{
|
|
303
|
+
widthRatio: 0.34,
|
|
304
|
+
heightRatio: 0.74,
|
|
305
|
+
minWidth: 380,
|
|
306
|
+
maxWidth: 720,
|
|
307
|
+
minHeight: 360,
|
|
308
|
+
maxHeight: 860,
|
|
309
|
+
alignX: "right",
|
|
310
|
+
alignY: "center",
|
|
311
|
+
paddingX: 16,
|
|
312
|
+
paddingY: 16,
|
|
313
|
+
},
|
|
314
|
+
);
|
|
315
|
+
panelX = initial.x;
|
|
316
|
+
panelY = initial.y;
|
|
317
|
+
panelWidth = initial.width;
|
|
318
|
+
panelHeight = initial.height;
|
|
336
319
|
ensureControllerSubscription();
|
|
337
320
|
unsubscribeLifecycle = toolkitCoordinator?.onSectionControllerLifecycle?.(
|
|
338
321
|
(event: { key?: { sectionId?: string; attemptId?: string } }) => {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
322
|
+
if (
|
|
323
|
+
!isMatchingSectionControllerLifecycleEvent(event, sectionId, attemptId)
|
|
324
|
+
)
|
|
325
|
+
return;
|
|
343
326
|
ensureControllerSubscription();
|
|
344
327
|
},
|
|
345
328
|
);
|
|
@@ -358,10 +341,10 @@
|
|
|
358
341
|
detachLifecycleSubscription();
|
|
359
342
|
unsubscribeLifecycle = toolkitCoordinator?.onSectionControllerLifecycle?.(
|
|
360
343
|
(event: { key?: { sectionId?: string; attemptId?: string } }) => {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
344
|
+
if (
|
|
345
|
+
!isMatchingSectionControllerLifecycleEvent(event, sectionId, attemptId)
|
|
346
|
+
)
|
|
347
|
+
return;
|
|
365
348
|
ensureControllerSubscription();
|
|
366
349
|
},
|
|
367
350
|
);
|
|
@@ -371,8 +354,7 @@
|
|
|
371
354
|
});
|
|
372
355
|
|
|
373
356
|
onDestroy(() => {
|
|
374
|
-
|
|
375
|
-
stopResize();
|
|
357
|
+
pointerController.stop();
|
|
376
358
|
detachControllerSubscription();
|
|
377
359
|
detachLifecycleSubscription();
|
|
378
360
|
});
|
|
@@ -384,35 +366,34 @@
|
|
|
384
366
|
>
|
|
385
367
|
<div
|
|
386
368
|
class="pie-section-player-tools-event-debugger__header"
|
|
387
|
-
onmousedown={startDrag}
|
|
369
|
+
onmousedown={(event: MouseEvent) => pointerController.startDrag(event)}
|
|
388
370
|
role="button"
|
|
389
371
|
tabindex="0"
|
|
390
372
|
aria-label="Drag event debugger panel"
|
|
391
373
|
>
|
|
392
374
|
<div class="pie-section-player-tools-event-debugger__header-title">
|
|
375
|
+
<svg
|
|
376
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
377
|
+
class="pie-section-player-tools-event-debugger__icon-sm"
|
|
378
|
+
fill="none"
|
|
379
|
+
viewBox="0 0 24 24"
|
|
380
|
+
stroke="currentColor"
|
|
381
|
+
>
|
|
382
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 10h8M8 14h5m-7 7h12a2 2 0 002-2V5a2 2 0 00-2-2H6a2 2 0 00-2 2v14a2 2 0 002 2z" />
|
|
383
|
+
</svg>
|
|
393
384
|
<h3 class="pie-section-player-tools-event-debugger__title">Session Broadcasts</h3>
|
|
394
|
-
<span class="pie-section-player-tools-event-debugger__counter">{records.length}</span>
|
|
395
385
|
</div>
|
|
396
386
|
<div class="pie-section-player-tools-event-debugger__header-actions">
|
|
397
|
-
<
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
{isMinimized ? "▴" : "▾"}
|
|
403
|
-
</button>
|
|
404
|
-
<button
|
|
405
|
-
class="pie-section-player-tools-event-debugger__icon-button"
|
|
406
|
-
onclick={() => dispatch("close")}
|
|
407
|
-
title="Close"
|
|
408
|
-
>
|
|
409
|
-
✕
|
|
410
|
-
</button>
|
|
387
|
+
<PanelWindowControls
|
|
388
|
+
minimized={isMinimized}
|
|
389
|
+
onToggle={() => (isMinimized = !isMinimized)}
|
|
390
|
+
onClose={() => dispatch("close")}
|
|
391
|
+
/>
|
|
411
392
|
</div>
|
|
412
393
|
</div>
|
|
413
394
|
|
|
414
395
|
{#if !isMinimized}
|
|
415
|
-
<div class="pie-section-player-tools-event-debugger__content-shell" style="height: {panelHeight -
|
|
396
|
+
<div class="pie-section-player-tools-event-debugger__content-shell" style="height: {panelHeight - 50}px;">
|
|
416
397
|
<div class="pie-section-player-tools-event-debugger__toolbar">
|
|
417
398
|
<div
|
|
418
399
|
class="pie-section-player-tools-event-debugger__toggle-group"
|
|
@@ -525,15 +506,7 @@
|
|
|
525
506
|
{/if}
|
|
526
507
|
|
|
527
508
|
{#if !isMinimized}
|
|
528
|
-
<
|
|
529
|
-
class="pie-section-player-tools-event-debugger__resize-handle"
|
|
530
|
-
onmousedown={startResize}
|
|
531
|
-
role="button"
|
|
532
|
-
tabindex="0"
|
|
533
|
-
title="Resize window"
|
|
534
|
-
>
|
|
535
|
-
◢
|
|
536
|
-
</div>
|
|
509
|
+
<PanelResizeHandle onPointerDown={(event: MouseEvent) => pointerController.startResize(event)} />
|
|
537
510
|
{/if}
|
|
538
511
|
</div>
|
|
539
512
|
|
|
@@ -543,22 +516,22 @@
|
|
|
543
516
|
z-index: 9999;
|
|
544
517
|
background: var(--color-base-100, #fff);
|
|
545
518
|
color: var(--color-base-content, #1f2937);
|
|
546
|
-
border:
|
|
519
|
+
border: 2px solid var(--color-base-300, #d1d5db);
|
|
547
520
|
border-radius: 8px;
|
|
548
|
-
box-shadow: 0
|
|
521
|
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
549
522
|
overflow: hidden;
|
|
550
523
|
font-family: var(--pie-font-family, Inter, system-ui, sans-serif);
|
|
551
524
|
}
|
|
552
525
|
|
|
553
526
|
.pie-section-player-tools-event-debugger__header {
|
|
554
|
-
|
|
555
|
-
padding: 0 12px;
|
|
527
|
+
padding: 8px 16px;
|
|
556
528
|
display: flex;
|
|
557
529
|
align-items: center;
|
|
558
530
|
justify-content: space-between;
|
|
559
531
|
background: var(--color-base-200, #f3f4f6);
|
|
560
532
|
cursor: move;
|
|
561
533
|
user-select: none;
|
|
534
|
+
border-bottom: 1px solid var(--color-base-300, #d1d5db);
|
|
562
535
|
}
|
|
563
536
|
|
|
564
537
|
.pie-section-player-tools-event-debugger__header-title {
|
|
@@ -567,32 +540,20 @@
|
|
|
567
540
|
gap: 8px;
|
|
568
541
|
}
|
|
569
542
|
|
|
543
|
+
.pie-section-player-tools-event-debugger__icon-sm {
|
|
544
|
+
width: 1rem;
|
|
545
|
+
height: 1rem;
|
|
546
|
+
}
|
|
547
|
+
|
|
570
548
|
.pie-section-player-tools-event-debugger__title {
|
|
571
549
|
margin: 0;
|
|
572
550
|
font-size: 0.95rem;
|
|
573
551
|
font-weight: 700;
|
|
574
552
|
}
|
|
575
553
|
|
|
576
|
-
.pie-section-player-tools-event-debugger__counter {
|
|
577
|
-
font-size: 0.75rem;
|
|
578
|
-
padding: 2px 7px;
|
|
579
|
-
border-radius: 999px;
|
|
580
|
-
background: var(--color-primary, #2563eb);
|
|
581
|
-
color: white;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
554
|
.pie-section-player-tools-event-debugger__header-actions {
|
|
585
555
|
display: flex;
|
|
586
|
-
gap:
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
.pie-section-player-tools-event-debugger__icon-button {
|
|
590
|
-
border: 1px solid var(--color-base-300, #d1d5db);
|
|
591
|
-
background: var(--color-base-100, #fff);
|
|
592
|
-
border-radius: 6px;
|
|
593
|
-
font-size: 0.8rem;
|
|
594
|
-
padding: 4px 7px;
|
|
595
|
-
cursor: pointer;
|
|
556
|
+
gap: 4px;
|
|
596
557
|
}
|
|
597
558
|
|
|
598
559
|
.pie-section-player-tools-event-debugger__content-shell {
|
|
@@ -729,13 +690,4 @@
|
|
|
729
690
|
opacity: 0.8;
|
|
730
691
|
}
|
|
731
692
|
|
|
732
|
-
.pie-section-player-tools-event-debugger__resize-handle {
|
|
733
|
-
position: absolute;
|
|
734
|
-
right: 6px;
|
|
735
|
-
bottom: 4px;
|
|
736
|
-
cursor: nwse-resize;
|
|
737
|
-
user-select: none;
|
|
738
|
-
font-size: 0.9rem;
|
|
739
|
-
opacity: 0.7;
|
|
740
|
-
}
|
|
741
693
|
</style>
|