@pie-players/pie-section-player-tools-event-debugger 0.3.16 → 0.3.19
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 +67 -2
- package/dist/section-player-tools-event-debugger.js +1774 -1614
- package/package.json +3 -3
package/EventPanel.svelte
CHANGED
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
shadow: "open",
|
|
5
5
|
props: {
|
|
6
6
|
maxEvents: { type: "Number", attribute: "max-events" },
|
|
7
|
+
maxEventsByLevel: {
|
|
8
|
+
type: "Object",
|
|
9
|
+
attribute: "max-events-by-level",
|
|
10
|
+
},
|
|
7
11
|
toolkitCoordinator: { type: "Object", attribute: "toolkit-coordinator" },
|
|
8
12
|
sectionId: { type: "String", attribute: "section-id" },
|
|
9
13
|
attemptId: { type: "String", attribute: "attempt-id" },
|
|
14
|
+
persistenceScope: { type: "String", attribute: "persistence-scope" },
|
|
15
|
+
persistencePanelId: { type: "String", attribute: "persistence-panel-id" },
|
|
10
16
|
},
|
|
11
17
|
}}
|
|
12
18
|
/>
|
|
@@ -70,6 +76,7 @@
|
|
|
70
76
|
| "section-items-complete-changed"
|
|
71
77
|
| "section-error";
|
|
72
78
|
type EventLevel = "item" | "section";
|
|
79
|
+
type EventLimitOverrides = Partial<Record<EventLevel, number>>;
|
|
73
80
|
|
|
74
81
|
type EventRecord = {
|
|
75
82
|
id: number;
|
|
@@ -89,14 +96,20 @@
|
|
|
89
96
|
|
|
90
97
|
let {
|
|
91
98
|
maxEvents = 200,
|
|
99
|
+
maxEventsByLevel = {},
|
|
92
100
|
toolkitCoordinator = null,
|
|
93
101
|
sectionId = "",
|
|
94
102
|
attemptId = undefined,
|
|
103
|
+
persistenceScope = "",
|
|
104
|
+
persistencePanelId = "controller-events",
|
|
95
105
|
}: {
|
|
96
106
|
maxEvents?: number;
|
|
107
|
+
maxEventsByLevel?: EventLimitOverrides;
|
|
97
108
|
toolkitCoordinator?: ToolkitCoordinatorLike | null;
|
|
98
109
|
sectionId?: string;
|
|
99
110
|
attemptId?: string;
|
|
111
|
+
persistenceScope?: string;
|
|
112
|
+
persistencePanelId?: string;
|
|
100
113
|
} = $props();
|
|
101
114
|
let isPaused = $state(false);
|
|
102
115
|
let selectedLevel = $state<EventLevel>("item");
|
|
@@ -229,13 +242,57 @@
|
|
|
229
242
|
];
|
|
230
243
|
return;
|
|
231
244
|
}
|
|
232
|
-
|
|
233
|
-
records = [next, ...records].slice(0, cappedMaxEvents);
|
|
245
|
+
records = pruneAndSortRecords([next, ...records]);
|
|
234
246
|
if (selectedRecordId == null) {
|
|
235
247
|
selectedRecordId = next.id;
|
|
236
248
|
}
|
|
237
249
|
}
|
|
238
250
|
|
|
251
|
+
function resolveCap(rawCap: unknown, fallback: number): number {
|
|
252
|
+
const parsed = Number(rawCap);
|
|
253
|
+
if (!Number.isFinite(parsed)) return Math.max(10, Math.min(2000, fallback));
|
|
254
|
+
return Math.max(10, Math.min(2000, parsed));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function getCapForLevel(level: EventLevel): number {
|
|
258
|
+
const globalCap = resolveCap(maxEvents || 200, 200);
|
|
259
|
+
const override = maxEventsByLevel?.[level];
|
|
260
|
+
return resolveCap(override, globalCap);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function pruneAndSortRecords(nextRecords: EventRecord[]): EventRecord[] {
|
|
264
|
+
const sorted = [...nextRecords].sort((left, right) => {
|
|
265
|
+
if (left.timestamp === right.timestamp) {
|
|
266
|
+
return right.id - left.id;
|
|
267
|
+
}
|
|
268
|
+
return right.timestamp - left.timestamp;
|
|
269
|
+
});
|
|
270
|
+
const nextByLevel: Record<EventLevel, number> = { item: 0, section: 0 };
|
|
271
|
+
const pruned: EventRecord[] = [];
|
|
272
|
+
for (const record of sorted) {
|
|
273
|
+
const level = getEventLevel(record.type);
|
|
274
|
+
const levelCap = getCapForLevel(level);
|
|
275
|
+
if (nextByLevel[level] >= levelCap) continue;
|
|
276
|
+
pruned.push(record);
|
|
277
|
+
nextByLevel[level] += 1;
|
|
278
|
+
}
|
|
279
|
+
return pruned;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function reconcileRecordsWithLimits(): void {
|
|
283
|
+
const nextRecords = pruneAndSortRecords(records);
|
|
284
|
+
if (nextRecords.length !== records.length) {
|
|
285
|
+
records = nextRecords;
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
for (let index = 0; index < nextRecords.length; index += 1) {
|
|
289
|
+
if (nextRecords[index]?.id !== records[index]?.id) {
|
|
290
|
+
records = nextRecords;
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
239
296
|
function handleControllerEvent(event: ControllerEvent): void {
|
|
240
297
|
pushRecord(event || {});
|
|
241
298
|
}
|
|
@@ -416,6 +473,12 @@
|
|
|
416
473
|
};
|
|
417
474
|
});
|
|
418
475
|
|
|
476
|
+
$effect(() => {
|
|
477
|
+
void maxEvents;
|
|
478
|
+
void maxEventsByLevel;
|
|
479
|
+
reconcileRecordsWithLimits();
|
|
480
|
+
});
|
|
481
|
+
|
|
419
482
|
onDestroy(() => {
|
|
420
483
|
detachControllerSubscription();
|
|
421
484
|
detachLifecycleSubscription();
|
|
@@ -427,6 +490,8 @@
|
|
|
427
490
|
ariaLabel="Drag event debugger panel"
|
|
428
491
|
minWidth={360}
|
|
429
492
|
minHeight={280}
|
|
493
|
+
{persistenceScope}
|
|
494
|
+
{persistencePanelId}
|
|
430
495
|
initialSizing={{
|
|
431
496
|
widthRatio: 0.34,
|
|
432
497
|
heightRatio: 0.74,
|