@@ -12,9 +12,16 @@ import { classifyRoute, buildReportUrl, getQueryParam } from './routes.js';
1212// displayed instead of the default guess.
1313export const BRANCH_RESOLVED_EVENT = 'rf:branch-resolved' ;
1414
15- // Construct the event in the dispatch target's own realm: jsdom EventTargets
16- // reject events from another realm, and Bun's CustomEvent global is not an
17- // Event subclass at all (plain-node unit-test runs).
15+ /**
16+ * Creates a branch-resolution event in the dispatch target's realm.
17+ * Falls back to an Event carrying detail when CustomEvent is unavailable or
18+ * incompatible with Event in the current runtime.
19+ *
20+ * @param {EventTarget } target - Window, DOM node, or standalone event target.
21+ * @param {{username: string, repository: string, branch: string} } detail
22+ * The report identity and resolved branch carried by the event.
23+ * @returns {Event & {detail: object} } An event compatible with the target.
24+ */
1825function branchResolvedEvent ( target , detail ) {
1926 const realm =
2027 ( target && target . window === target && target ) || // a Window
@@ -29,6 +36,12 @@ function branchResolvedEvent(target, detail) {
2936 return Object . assign ( new Event ( BRANCH_RESOLVED_EVENT ) , { detail } ) ;
3037}
3138
39+ /**
40+ * Builds a user-listing path with the username encoded as one URL segment.
41+ *
42+ * @param {string } username - Repository owner's username.
43+ * @returns {string } The user-listing path, without a deployment base path.
44+ */
3245function userHref ( username ) {
3346 return `/${ encodeURIComponent ( username ) } ` ;
3447}
0 commit comments