@webmusic/kernel 0.1.0
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/LICENSE +21 -0
- package/README.md +435 -0
- package/dist/audio-context.cjs +10 -0
- package/dist/audio-context.cjs.map +1 -0
- package/dist/audio-context.d.cts +13 -0
- package/dist/audio-context.d.ts +13 -0
- package/dist/audio-context.js +10 -0
- package/dist/audio-context.js.map +1 -0
- package/dist/build-receipt.json +7 -0
- package/dist/chunk-3INDOVUC.cjs +134 -0
- package/dist/chunk-3INDOVUC.cjs.map +1 -0
- package/dist/chunk-53YD73OY.js +162 -0
- package/dist/chunk-53YD73OY.js.map +1 -0
- package/dist/chunk-7ZTZZ5PN.cjs +25 -0
- package/dist/chunk-7ZTZZ5PN.cjs.map +1 -0
- package/dist/chunk-BR63OD53.cjs +1 -0
- package/dist/chunk-BR63OD53.cjs.map +1 -0
- package/dist/chunk-C3YWUZW3.cjs +57 -0
- package/dist/chunk-C3YWUZW3.cjs.map +1 -0
- package/dist/chunk-FJLY3RWZ.js +134 -0
- package/dist/chunk-FJLY3RWZ.js.map +1 -0
- package/dist/chunk-GO4N5T27.js +94 -0
- package/dist/chunk-GO4N5T27.js.map +1 -0
- package/dist/chunk-HOKRTYPV.js +199 -0
- package/dist/chunk-HOKRTYPV.js.map +1 -0
- package/dist/chunk-HY2YIL75.js +16 -0
- package/dist/chunk-HY2YIL75.js.map +1 -0
- package/dist/chunk-HZQX4J2J.cjs +199 -0
- package/dist/chunk-HZQX4J2J.cjs.map +1 -0
- package/dist/chunk-ILKEVUJ3.js +57 -0
- package/dist/chunk-ILKEVUJ3.js.map +1 -0
- package/dist/chunk-JNXB74G3.cjs +987 -0
- package/dist/chunk-JNXB74G3.cjs.map +1 -0
- package/dist/chunk-N6KU2HYA.js +25 -0
- package/dist/chunk-N6KU2HYA.js.map +1 -0
- package/dist/chunk-PXG64RU4.js +25 -0
- package/dist/chunk-PXG64RU4.js.map +1 -0
- package/dist/chunk-SM5YPDDI.cjs +162 -0
- package/dist/chunk-SM5YPDDI.cjs.map +1 -0
- package/dist/chunk-TEM2I2NN.js +1 -0
- package/dist/chunk-TEM2I2NN.js.map +1 -0
- package/dist/chunk-UMTPJ76S.cjs +94 -0
- package/dist/chunk-UMTPJ76S.cjs.map +1 -0
- package/dist/chunk-VVZX7DQ6.cjs +254 -0
- package/dist/chunk-VVZX7DQ6.cjs.map +1 -0
- package/dist/chunk-VY6WWZSW.cjs +16 -0
- package/dist/chunk-VY6WWZSW.cjs.map +1 -0
- package/dist/chunk-WNFGDB7B.js +254 -0
- package/dist/chunk-WNFGDB7B.js.map +1 -0
- package/dist/chunk-XBJBY4J5.js +987 -0
- package/dist/chunk-XBJBY4J5.js.map +1 -0
- package/dist/chunk-ZMU72HJS.cjs +25 -0
- package/dist/chunk-ZMU72HJS.cjs.map +1 -0
- package/dist/effect.cjs +2 -0
- package/dist/effect.cjs.map +1 -0
- package/dist/effect.d.cts +19 -0
- package/dist/effect.d.ts +19 -0
- package/dist/effect.js +2 -0
- package/dist/effect.js.map +1 -0
- package/dist/elements.cjs +24 -0
- package/dist/elements.cjs.map +1 -0
- package/dist/elements.d.cts +76 -0
- package/dist/elements.d.ts +76 -0
- package/dist/elements.js +24 -0
- package/dist/elements.js.map +1 -0
- package/dist/events.cjs +8 -0
- package/dist/events.cjs.map +1 -0
- package/dist/events.d.cts +36 -0
- package/dist/events.d.ts +36 -0
- package/dist/events.js +8 -0
- package/dist/events.js.map +1 -0
- package/dist/index.cjs +77 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/meter.cjs +12 -0
- package/dist/meter.cjs.map +1 -0
- package/dist/meter.d.cts +76 -0
- package/dist/meter.d.ts +76 -0
- package/dist/meter.js +12 -0
- package/dist/meter.js.map +1 -0
- package/dist/player.cjs +16 -0
- package/dist/player.cjs.map +1 -0
- package/dist/player.d.cts +49 -0
- package/dist/player.d.ts +49 -0
- package/dist/player.js +16 -0
- package/dist/player.js.map +1 -0
- package/dist/sync.cjs +12 -0
- package/dist/sync.cjs.map +1 -0
- package/dist/sync.d.cts +304 -0
- package/dist/sync.d.ts +304 -0
- package/dist/sync.js +12 -0
- package/dist/sync.js.map +1 -0
- package/dist/tick.cjs +10 -0
- package/dist/tick.cjs.map +1 -0
- package/dist/tick.d.cts +48 -0
- package/dist/tick.d.ts +48 -0
- package/dist/tick.js +10 -0
- package/dist/tick.js.map +1 -0
- package/dist/transport.cjs +8 -0
- package/dist/transport.cjs.map +1 -0
- package/dist/transport.d.cts +114 -0
- package/dist/transport.d.ts +114 -0
- package/dist/transport.js +8 -0
- package/dist/transport.js.map +1 -0
- package/dist/worker.cjs +10 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +49 -0
- package/dist/worker.d.ts +49 -0
- package/dist/worker.js +10 -0
- package/dist/worker.js.map +1 -0
- package/package.json +164 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/mamingchen/GitHub/public/WebMusic/platform/kernel/dist/chunk-JNXB74G3.cjs","../src/sync.ts"],"names":["_now"],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACoLA,IAAM,4BAAA,EAA8B,CAAA;AASpC,IAAM,sBAAA,EAAwB,IAAA;AA5M9B,IAAA,OAAA,EAAA,UAAA,EAAA,IAAA,EAAA,OAAA,EAAA,eAAA,EAAA,gBAAA,EAAA,OAAA,EAAA,YAAA,EAAA,mBAAA,EAAA,UAAA,EAAA,KAAA,EAAA,SAAA,EAAA,WAAA,EAAA,SAAA,EAAA,gBAAA,EAAA,UAAA,EAAA,aAAA,EAAA,mBAAA,EAAA,cAAA,EAAA,eAAA,EAAA,OAAA,EAAA,SAAA,EAAA,iBAAA,E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CAAA,IAAA,EAAK,MAAA,CAAA,uBAAO,OAAA,4BAAA,CAAU,GAAA;AAAA,EACxB;AACF,CAAA;AApGW,OAAA,EAAA,IAAA,OAAA,CAAA,CAAA;AACA,QAAA,EAAA,IAAA,OAAA,CAAA,CAAA;AACAA,MAAAA,EAAA,IAAA,OAAA,CAAA,CAAA;AACT,WAAA,EAAA,IAAA,OAAA,CAAA,CAAA;AACA,YAAA,EAAA,IAAA,OAAA,CAAA,CAAA;AAkGF,SAAS,uBAAA,CAAwB,IAAA,EAAc,KAAA,EAAqB;AAClE,EAAA,GAAA,CAAI,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,EAAA,GAAK,MAAA,EAAQ,CAAA,EAAG;AACxC,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,EAAA;AACvB,EAAA;AACF;AAEyB;AAEJ,EAAA;AAGI,IAAA;AACvB,EAAA;AACF;AAGyB;AACD,EAAA;AACf,IAAA;AAAa,IAAA;AAAc,IAAA;AAAQ,MAAA;AACnC,IAAA;AAAQ,MAAA;AAAuD,MAAA;AAC/D,IAAA;AACS,MAAA;AACZ,MAAA;AACG,IAAA;AAA0B,MAAA;AAA+B,MAAA;AAC9D,IAAA;AAA6B,MAAA;AAC/B,EAAA;AACF;AD3U0B;AACA;AACA;AACA;AACA","file":"/Users/mamingchen/GitHub/public/WebMusic/platform/kernel/dist/chunk-JNXB74G3.cjs","sourcesContent":[null,"// ============================================================================\n// Family-neutral synchronized-transport choreography: one master transport,\n// N schedulable followers, all positions on the MASTER's position axis\n// against one shared reference clock (typically AudioContext.currentTime).\n//\n// This is the sync machinery the score↔audio bridge proved out — command\n// serialization, generation guards, drift monitoring, scheduled joins,\n// master-self-stop reconciliation — hoisted here so every transport pairing\n// (score+clip, future families, external masters) reuses one hardened\n// implementation instead of re-writing it per pair. @webmusic/bridge remains\n// the domain assembly: it adapts ScorePlayer/AudioClipPlayer onto these role\n// contracts and keeps its public ScoreAudioSync surface.\n//\n// The master MUST expose a kernel TransportClockReader — the group anchors\n// by READING the clock, the exact affine map the master plays by, with no\n// sampling skew. A transport without a clock is wrapped in\n// {@link MirrorClockMaster}, which owns the sampled mirror-clock fallback\n// (dead-reckoning plus reconciliation) as ONE adapter instead of a second\n// code path inside the group.\n//\n// The group is the session command authority: revisioned invalidation and\n// settlement wrap its existing cancellation/re-entry choreography. Engines\n// still own their clocks. This is not same-instance writable-clock injection;\n// see platform/shared-clock-injection.md for that separate migration boundary.\n// ============================================================================\n\nimport {TransportClock, type TransportClockReader} from './transport';\nimport {\n MAX_TIMER_DELAY_MS,\n createTickSource,\n type TickSource,\n type TickSourceOptions,\n} from './tick';\n\n/**\n * Master role: the transport whose clock is the group's timeline. Everything\n * is on the master's own position axis (for a score player: nominal score\n * seconds; for a clip player: clip seconds).\n */\nexport interface SyncMasterTransport {\n /**\n * Start the transport. `when` (optional, absolute reference-clock seconds)\n * proposes an ARMED start: a master supporting scheduled starts arms its\n * clock there so followers can join at the very same instant. Masters\n * without the capability ignore the argument and start immediately — the\n * group detects which happened by observing `clock.holding`, never\n * through a declared flag.\n */\n play(when?: number): Promise<void> | void;\n pause(): void;\n stop(): void;\n /**\n * Seek to a position on the master's axis. A returned promise settles\n * once the seek has been applied and any mid-playback restart attempted;\n * the group awaits it before re-anchoring followers. The promise MAY\n * resolve with the transport left paused when the restart failed — the\n * group treats that as a failed resume: it pauses the followers, settles\n * into the paused state and reports 'resume after seek' through\n * {@link TransportGroupOptions.onOperationError}. While playing, the\n * group passes a proposed re-entry time the same way {@link play} does.\n */\n seekPosition(position: number, when?: number): void | Promise<void>;\n setRate?(rate: number): void;\n /** Current position on the master's axis. */\n readonly position: number;\n /** Read-only transport clock (master position axis). REQUIRED — wrap a\n * clockless transport in {@link MirrorClockMaster}. */\n readonly clock: TransportClockReader;\n /**\n * Optional pre-drift-check reconciliation hook (adapters). Called once\n * per drift check with the current reference time; returning 'stalled'\n * tells the group the master stopped on its own (the adapter has already\n * paused its clock) — the group then wraps or settles exactly as for an\n * observed master stop.\n */\n reconcile?(now: number): 'ok' | 'stalled';\n dispose?(): void;\n}\n\n/** Follower role: a transport that can join the master's timeline. */\nexport interface SyncFollowerTransport {\n /**\n * Start playback. `when` (optional, absolute reference-clock seconds) is\n * the scheduled start the join dance relies on: the follower MUST honor\n * it sample-accurately for gapless joins (a follower that starts\n * immediately instead will sit one lead-in ahead and be re-corrected\n * forever by the drift monitor).\n */\n play(when?: number): Promise<void> | void;\n pause(): void;\n stop(): void;\n seek(position: number): void;\n setRate?(rate: number): void;\n /** Current position on the follower's own axis. */\n readonly position: number;\n /** Whether the follower is running, when it can say (optional). */\n readonly running?: boolean;\n /**\n * Read-only clock on the follower's own axis, when the transport has one.\n * When present, the drift monitor reads position and running state from\n * it instead of sampling `position`/`running`.\n */\n readonly clock?: TransportClockReader;\n dispose?(): void;\n}\n\n/** Per-follower registration options. */\nexport interface FollowerOptions {\n /** Follower position corresponding to master position zero. Default 0. */\n offsetSeconds?: number;\n /** Positive affine scale: local position = offsetSeconds + master position × positionScale.\n * The follower's playback rate is scaled by the same factor. Default 1.\n * This is a constant map, not nonlinear warping. */\n positionScale?: number;\n /** Local loop bounds for a transport ALREADY configured to loop natively.\n * The group maps join/seek positions and drift into this phase; it does not\n * configure or schedule that native loop. Positions before the loop end\n * retain their intro; at/past the end they wrap into [start, end). */\n loop?: SyncLoopRegion;\n}\n\nexport interface TransportGroupOptions {\n /** Scheduling headroom before followers join, in seconds. Default 0.06. */\n leadInSeconds?: number;\n /** Re-join a follower when |follower − expected| exceeds this. Default 0.03 s. */\n driftToleranceSeconds?: number;\n /** Drift check cadence. Default 250 ms. 0 disables the monitor. */\n driftCheckIntervalMs?: number;\n /** Loop region on the master axis; also settable live via {@link TransportGroup.setLoop}. */\n loop?: SyncLoopRegion | null;\n /** Injectable tick source options (tests; custom hosting). */\n tick?: TickSourceOptions;\n /**\n * Observer for failures of the group's own fire-and-forget operations\n * (drift and rate re-joins, loop wraps, pause/stop reconciliation). Those\n * run behind the command queue with no caller promise to reject, and on\n * failure they settle the group into a paused state — without an observer\n * that settlement is silent. Observer exceptions are swallowed.\n */\n onOperationError?: (operation: string, error: unknown) => void;\n}\n\n/** A loop region on the master position axis. */\nexport interface SyncLoopRegion {\n startSeconds: number;\n endSeconds: number;\n}\n\n/** Commands accepted by the group's single authority. Positions use the master's\n * stable content axis, never a duration divided by the current playback rate. */\nexport type TransportCommand =\n | {readonly type: 'play' | 'pause' | 'stop'}\n | {readonly type: 'seek'; readonly position: number}\n | {readonly type: 'rate'; readonly rate: number}\n | {readonly type: 'loop'; readonly loop: SyncLoopRegion | null};\n\n/** Coherent observation at one reference-clock instant. This is a snapshot,\n * not a display timer; read again or use clock.positionAt for moving positions. */\nexport interface TransportSnapshot {\n readonly revision: number;\n readonly referenceTime: number;\n readonly position: number;\n readonly rate: number;\n readonly paused: boolean;\n readonly holding: boolean;\n readonly loop: Readonly<SyncLoopRegion> | null;\n readonly pending: boolean;\n readonly disposed: boolean;\n}\n\nexport interface TransportCommit {\n readonly revision: number;\n readonly command: TransportCommand;\n /** A newer command or disposal supersedes this operation's authority. */\n readonly status: 'committed' | 'superseded';\n readonly snapshot: TransportSnapshot;\n}\n\n/** Invalidation precedes participant commands, settlement follows their\n * asynchronous work. Engines retract/re-arm through their existing commands;\n * this observer protocol does not inject a shared writable clock. */\nexport type TransportEvent =\n | {readonly type: 'snapshot'; readonly snapshot: TransportSnapshot}\n | {readonly type: 'reconcile'; readonly operation: string; readonly phase: 'invalidate' | 'settled'; readonly snapshot: TransportSnapshot}\n | {readonly type: 'operation-error'; readonly operation: string; readonly error: unknown; readonly snapshot: TransportSnapshot}\n | {readonly type: 'invalidate'; readonly revision: number; readonly command: TransportCommand; readonly snapshot: TransportSnapshot}\n | {readonly type: 'commit'; readonly commit: TransportCommit; readonly snapshot: TransportSnapshot}\n | {readonly type: 'error'; readonly revision: number; readonly command: TransportCommand; readonly error: unknown; readonly snapshot: TransportSnapshot};\n\n/**\n * How many consecutive drift corrections may fail before the group stops\n * re-joining a follower and reports instead. Each correction restarts the\n * follower audibly, so a mismatch the corrections cannot fix must not\n * stutter forever.\n */\nconst MAX_CONSECUTIVE_DRIFT_JOINS = 3;\n\n/**\n * Relative slope error before {@link MirrorClockMaster} re-learns a\n * clockless transport's rate. Loose enough to ignore the quantization noise\n * of a transport whose position updates on a frame boundary, tight enough\n * that a refused or clamped rate is caught on the first reconcile that has\n * two samples.\n */\nconst MIRROR_RATE_TOLERANCE = 0.02;\n\ninterface FollowerRecord {\n transport: SyncFollowerTransport;\n offset: number;\n scale: number;\n loop: SyncLoopRegion | null;\n /** Reference time a scheduled join is armed for; drift holds off until then. */\n joinAt: number;\n /**\n * Last rate handed to this follower. Only consulted for followers without\n * a clock to read back; `undefined` until the first application, so a\n * follower constructed at its own rate is corrected rather than assumed.\n */\n lastRate?: number;\n /** Consecutive corrections that did not bring this follower into tolerance. */\n consecutiveDriftJoins: number;\n /** Set once corrections are proven not to converge; cleared by any command. */\n driftJoinsSuppressed: boolean;\n}\n\n/**\n * Drives one master transport and N schedulable followers as a single\n * transport. Positions are on the MASTER's axis; each follower runs\n * `offsetSeconds` ahead of the master's zero. The reference clock is\n * injected (`now`), so the group itself is Web-Audio-free and testable\n * against any monotonic time source.\n */\nexport class TransportGroup {\n #master: SyncMasterTransport;\n readonly #followers: FollowerRecord[] = [];\n readonly #now: () => number;\n #leadIn: number;\n #driftTolerance: number;\n #driftIntervalMs: number;\n #ticker: TickSource | null = null;\n #tickOptions: TickSourceOptions;\n #ticksPerDriftCheck: number;\n #tickCount = 0;\n #loop: SyncLoopRegion | null = null;\n #wrapping = false;\n #generation = 0;\n #revision = 0;\n readonly #pendingCommands = new Set<number>();\n readonly #observers = new Set<(event: TransportEvent) => void>();\n #lastSnapshot?: TransportSnapshot;\n #pendingTransitions = 0;\n /** Serializes transport commands so late async settlements cannot reorder state. */\n #commandActive = false;\n #queuedCommands: Array<() => void> = [];\n #intent: 'playing' | 'paused' | 'stopped' | 'disposed' = 'paused';\n #disposed = false;\n readonly #onOperationError: ((operation: string, error: unknown) => void) | undefined;\n\n constructor(\n master: SyncMasterTransport,\n now: () => number,\n options: TransportGroupOptions = {},\n ) {\n this.#master = master;\n this.#now = now;\n this.#leadIn = options.leadInSeconds ?? 0.06;\n this.#driftTolerance = options.driftToleranceSeconds ?? 0.03;\n this.#driftIntervalMs = options.driftCheckIntervalMs ?? 250;\n this.#onOperationError = options.onOperationError;\n this.#tickOptions = {intervalMs: 25, ...options.tick};\n assertFiniteNonNegative('leadInSeconds', this.#leadIn);\n assertFiniteNonNegative('driftToleranceSeconds', this.#driftTolerance);\n assertFiniteNonNegative('driftCheckIntervalMs', this.#driftIntervalMs);\n const tickInterval = this.#tickOptions.intervalMs ?? 25;\n if (!Number.isSafeInteger(tickInterval) || tickInterval < 1 || tickInterval > MAX_TIMER_DELAY_MS) {\n throw new RangeError(\n `tick.intervalMs must be a positive safe integer no greater than ${MAX_TIMER_DELAY_MS}.`,\n );\n }\n this.#ticksPerDriftCheck = Math.max(1, Math.round(this.#driftIntervalMs / (this.#tickOptions.intervalMs ?? 25)));\n if (options.loop) {\n assertValidLoop(options.loop);\n this.#loop = {...options.loop};\n }\n }\n\n /** The group timeline: a read-through to the master's own clock. */\n get clock(): TransportClockReader {\n return this.#master.clock;\n }\n\n /** Current position on the master axis. */\n get position(): number {\n return this.#master.position;\n }\n\n /** Read one coherent state on the master's stable position axis. */\n get snapshot(): TransportSnapshot {\n if (this.#disposed && this.#lastSnapshot) {\n return Object.freeze({...this.#lastSnapshot, revision: this.#revision, pending: false, disposed: true});\n }\n const referenceTime = this.#now();\n const clock = this.clock;\n const loop = this.loop;\n const snapshot: TransportSnapshot = Object.freeze({\n revision: this.#revision,\n referenceTime,\n position: clock.positionAt(referenceTime),\n rate: clock.rate,\n paused: clock.paused,\n holding: clock.holding && clock.state.originTime > referenceTime,\n loop: loop ? Object.freeze(loop) : null,\n pending: this.#pendingCommands.size > 0 || this.#pendingTransitions > 0,\n disposed: this.#disposed,\n });\n this.#lastSnapshot = snapshot;\n return snapshot;\n }\n\n /** Register before synchronously delivering the initial snapshot. Observer\n * failures are contained. Unsubscribe never stops borrowed playback. */\n subscribe(listener: (event: TransportEvent) => void): () => void {\n this.#assertActive();\n this.#observers.add(listener);\n try { listener({type: 'snapshot', snapshot: this.snapshot}); } catch {\n // A failed initial delivery must not leave an orphan subscription.\n this.#observers.delete(listener);\n }\n return () => { this.#observers.delete(listener); };\n }\n\n /** Submit a command and await its actual participant settlement. Failures\n * reject and emit an error; superseded work cannot claim a committed result.\n * Pause/stop take effect synchronously and await any late-start reconciliation.\n * Call this authority exclusively while coordinating a session. */\n dispatch(command: TransportCommand): Promise<TransportCommit> {\n return this.#dispatch(command, true);\n }\n\n #dispatch(input: TransportCommand, strict: boolean): Promise<TransportCommit> {\n this.#assertActive();\n validateCommand(input);\n const command = Object.freeze(input.type === 'loop'\n ? {...input, loop: input.loop ? Object.freeze({...input.loop}) : null}\n : {...input});\n const revision = ++this.#revision;\n this.#pendingCommands.add(revision);\n this.#publish({type: 'invalidate', revision, command, snapshot: this.snapshot});\n let operation: Promise<void> | void = undefined;\n try {\n // An observer may synchronously replace this command or dispose us.\n if (revision === this.#revision && !this.#disposed) {\n switch (command.type) {\n case 'play': operation = this.#play(strict); break;\n case 'pause': operation = this.#pause(); break;\n case 'stop': operation = this.#stop(); break;\n case 'seek': operation = this.#seek(command.position, strict); break;\n case 'rate': operation = this.#setRate(command.rate, strict, revision); break;\n case 'loop': operation = this.#setLoop(command.loop); break;\n }\n }\n } catch (error) {\n operation = Promise.reject(error);\n }\n return Promise.resolve(operation).then(() => {\n this.#pendingCommands.delete(revision);\n const snapshot = this.snapshot;\n const commit: TransportCommit = Object.freeze({\n revision, command,\n status: revision === this.#revision && !this.#disposed ? 'committed' : 'superseded',\n snapshot,\n });\n this.#publish({type: 'commit', commit, snapshot});\n return commit;\n }, (error: unknown) => {\n if (strict && revision === this.#revision && !this.#disposed) this.#rollbackFailedPlay();\n this.#pendingCommands.delete(revision);\n this.#publish({type: 'error', revision, command, error, snapshot: this.snapshot});\n throw error;\n });\n }\n\n #publish(event: TransportEvent): void {\n for (const listener of [...this.#observers]) {\n if (!this.#observers.has(listener)) continue;\n try { listener(event); } catch { /* Observers cannot interrupt transport cleanup. */ }\n // A reentrant command publishes its newer state first; do not then\n // deliver this stale snapshot to the remaining observers.\n if (event.snapshot.revision !== this.#revision) break;\n }\n }\n\n /**\n * Register a follower. While the group is playing, the follower joins the\n * running timeline on the next scheduled join.\n */\n addFollower(transport: SyncFollowerTransport, options: FollowerOptions = {}): void {\n this.#assertActive();\n const offset = options.offsetSeconds ?? 0;\n assertFiniteNonNegative('offsetSeconds', offset);\n const scale = options.positionScale ?? 1;\n if (!Number.isFinite(scale) || scale <= 0) throw new RangeError('positionScale must be finite and > 0.');\n if (scale !== 1 && !transport.setRate) throw new Error('A scaled follower must support setRate.');\n if (options.loop) assertValidLoop(options.loop);\n const record: FollowerRecord = {\n transport,\n offset,\n scale,\n loop: options.loop ? {...options.loop} : null,\n joinAt: 0,\n consecutiveDriftJoins: 0,\n driftJoinsSuppressed: false,\n };\n this.#followers.push(record);\n if (!this.clock.paused) {\n this.#observeReconciliation('follower join', () => this.#queueJoin(this.#generation, 'follower join', [record]));\n }\n }\n\n /**\n * Remove a follower from the group (the transport itself is left as-is,\n * still playing if it was; the caller owns its lifecycle from here).\n * Returns false when the transport was not a member.\n */\n removeFollower(transport: SyncFollowerTransport): boolean {\n const index = this.#followers.findIndex((record) => record.transport === transport);\n if (index < 0) return false;\n this.#followers.splice(index, 1);\n return true;\n }\n\n /** Number of registered followers. */\n get followerCount(): number {\n return this.#followers.length;\n }\n\n /**\n * Set (or clear) a loop region on the master axis, live. The wrap runs\n * through {@link seek}, so it inherits the shared re-entry origin; the\n * boundary is detected by a worker-backed tick watcher, so the wrap\n * instant may trail the boundary by the watcher/preparation delay and lead-in.\n * Browser throttling means this is not a bounded timing guarantee.\n */\n setLoop(loop: SyncLoopRegion | null): void {\n this.#assertActive();\n if (loop) assertValidLoop(loop);\n void this.#dispatch({type: 'loop', loop}, false).catch((error: unknown) => this.#reportOperationError('loop', error));\n }\n\n #setLoop(loop: SyncLoopRegion | null): void {\n this.#assertActive();\n if (loop) assertValidLoop(loop);\n this.#loop = loop ? {...loop} : null;\n if (this.clock.paused) {\n if (!this.#needsMonitor()) this.#stopDriftMonitor();\n } else if (this.#needsMonitor()) {\n this.#startDriftMonitor();\n } else {\n this.#stopDriftMonitor();\n }\n }\n\n get loop(): SyncLoopRegion | null {\n return this.#loop ? {...this.#loop} : null;\n }\n\n /**\n * Start master and followers on one shared origin. The group proposes\n * `now + leadInSeconds` to the master; one that supports scheduled starts\n * arms there and every follower joins at that very instant. A master that\n * ignores the proposal starts immediately and followers join a lead-in\n * later, offset-matched to its anchor.\n */\n async play(): Promise<void> {\n await this.#dispatch({type: 'play'}, false);\n }\n\n async #play(strict: boolean): Promise<void> {\n this.#assertActive();\n const generation = ++this.#generation;\n this.#pendingTransitions += 1;\n this.#intent = 'playing';\n this.#resetDriftConvergence();\n return this.#enqueueCommand(async () => {\n try {\n if (!this.#isCurrent(generation)) return;\n await this.#master.play(this.#now() + this.#leadIn);\n if (!this.#isCurrent(generation)) {\n this.#reapplySynchronousIntent();\n return;\n }\n if (strict && this.clock.paused) throw new Error('Master transport did not start.');\n await this.#joinFollowers(generation, this.#followers, strict);\n if (this.#isCurrent(generation)) this.#startDriftMonitor();\n } catch (error) {\n if (this.#isCurrent(generation)) this.#rollbackFailedPlay();\n throw error;\n } finally {\n this.#pendingTransitions -= 1;\n }\n });\n }\n\n pause(): void {\n if (this.#disposed) return;\n void this.#dispatch({type: 'pause'}, false).catch((error: unknown) => this.#reportOperationError('pause', error));\n }\n\n #pause(): Promise<void> | void {\n if (this.#disposed) return;\n const hadPendingTransition = this.#pendingTransitions > 0;\n ++this.#generation;\n this.#intent = 'paused';\n this.#resetDriftConvergence();\n this.#stopDriftMonitor();\n this.#applyPause();\n if (hadPendingTransition) {\n return this.#enqueueCommand(() => {\n if (!this.#disposed) this.#applyPause();\n });\n }\n }\n\n stop(): void {\n if (this.#disposed) return;\n void this.#dispatch({type: 'stop'}, false).catch((error: unknown) => this.#reportOperationError('stop', error));\n }\n\n #stop(): Promise<void> | void {\n if (this.#disposed) return;\n const hadPendingTransition = this.#pendingTransitions > 0;\n ++this.#generation;\n this.#intent = 'stopped';\n this.#resetDriftConvergence();\n this.#stopDriftMonitor();\n this.#applyStop();\n if (hadPendingTransition) {\n return this.#enqueueCommand(() => {\n if (!this.#disposed) this.#applyStop();\n });\n }\n }\n\n /**\n * Seek master and followers to a master-axis position. While playing, the\n * group proposes a shared re-entry origin exactly as {@link play} does\n * and re-joins the followers there, so all sides come back in together.\n * Loop wraps run through this path and inherit the same shared origin.\n */\n async seek(position: number): Promise<void> {\n await this.#dispatch({type: 'seek', position}, false);\n }\n\n async #seek(position: number, strict: boolean): Promise<void> {\n this.#assertActive();\n assertFiniteNonNegative('position', position);\n this.#pendingTransitions += 1;\n this.#resetDriftConvergence();\n return this.#enqueueCommand(async () => {\n try {\n if (this.#disposed) return;\n const generation = this.#generation;\n const wasRunning = !this.clock.paused;\n // Propose a shared re-entry origin only for a mid-playback seek: a\n // seek while paused must not start playback.\n await this.#master.seekPosition(\n position,\n wasRunning ? this.#now() + this.#leadIn : undefined,\n );\n const settled = this.#readSettledMasterPosition();\n if (!this.#isCurrent(generation)) {\n this.#reconcileStaleSeek(settled);\n this.#reapplySynchronousIntent();\n return;\n }\n if (this.clock.paused) {\n // A master that was running but comes back paused failed to\n // resume (seekPosition resolves even then) — mirror the stop\n // instead of seeking still-running followers out from under it.\n if (wasRunning && this.#intent === 'playing') {\n this.#settleFailedResume();\n if (strict) throw new Error('Master transport stayed paused after seek.');\n this.#reconcileStaleSeek(settled);\n return;\n }\n for (const record of [...this.#followers]) {\n if (!this.#isCurrent(generation)) break;\n if (!this.#followers.includes(record)) continue;\n record.transport.seek(this.#localPosition(record, settled));\n }\n } else {\n await this.#joinFollowers(generation, this.#followers, strict);\n }\n } finally {\n this.#pendingTransitions -= 1;\n }\n });\n }\n\n /**\n * Set the playback rate on the master and every follower. Followers\n * re-join immediately on the shared clock. NOTE: the group does not clamp\n * the rate beyond finite-and-positive — a domain wrapper owns any shared\n * range its transports require.\n */\n setRate(rate: number): void {\n this.#assertActive();\n validateCommand({type: 'rate', rate});\n void this.#dispatch({type: 'rate', rate}, false).catch((error: unknown) => this.#reportOperationError('rate', error));\n }\n\n #setRate(rate: number, strict: boolean, revision: number, queued = false): Promise<void> | void {\n if (strict && !queued) {\n this.#pendingTransitions += 1;\n return this.#enqueueCommand(async () => {\n try {\n if (revision !== this.#revision || this.#disposed) return;\n await this.#setRate(rate, strict, revision, true);\n } finally {\n this.#pendingTransitions -= 1;\n }\n });\n }\n this.#assertActive();\n if (!Number.isFinite(rate) || rate <= 0) {\n throw new RangeError(`rate must be finite and > 0, got ${rate}.`);\n }\n const generation = this.#generation;\n this.#resetDriftConvergence();\n try {\n this.#master.setRate?.(rate);\n } catch (error) {\n if (strict) throw error;\n this.#reportOperationError('master rate match', error);\n }\n if (revision !== this.#revision || this.#disposed) return;\n if (strict && this.clock.rate !== rate) throw new Error('Master transport did not accept the requested rate.');\n for (const record of [...this.#followers]) {\n if (revision !== this.#revision || this.#disposed) return;\n if (!this.#followers.includes(record)) continue;\n this.#applyFollowerRate(record, rate, strict);\n }\n if (revision !== this.#revision || this.#disposed) return;\n if (!this.clock.paused) {\n return queued\n ? this.#joinFollowers(generation, this.#followers, strict)\n : this.#queueJoin(generation, 'rate re-join', this.#followers, strict);\n }\n }\n\n dispose(): void {\n if (this.#disposed) return;\n this.#lastSnapshot = this.snapshot;\n this.#disposed = true;\n ++this.#revision;\n ++this.#generation;\n this.#intent = 'disposed';\n const ticker = this.#ticker;\n this.#ticker = null;\n const errors: unknown[] = [];\n const releases: Array<() => void> = [() => ticker?.dispose()];\n for (const record of this.#followers) {\n releases.push(() => record.transport.dispose?.());\n }\n releases.push(() => this.#master.dispose?.());\n for (const release of releases) {\n try {\n release();\n } catch (error) {\n errors.push(error);\n }\n }\n this.#publish({type: 'snapshot', snapshot: this.snapshot});\n this.#observers.clear();\n if (errors.length > 0) throw errors[0];\n }\n\n /**\n * One drift check: every follower is measured against the master clock,\n * and each one out of tolerance is re-joined on the shared clock (the\n * same scheduled-start dance as {@link play}). Returns the largest\n * absolute drift observed (0 with no followers or while holding off).\n */\n checkDrift(): number {\n this.#assertActive();\n if (this.#pendingTransitions > 0) return 0;\n const now = this.#now();\n if (this.#master.reconcile) {\n const verdict = this.#master.reconcile(now);\n if (verdict === 'stalled' && this.#intent === 'playing') {\n this.#handleMasterStopped();\n return 0;\n }\n }\n let worst = 0;\n const stragglers: FollowerRecord[] = [];\n for (const record of this.#followers) {\n // Hold off while a scheduled join is still pending — the follower's\n // position deliberately parks at its offset through the pre-roll.\n if (now < record.joinAt) continue;\n const expected = this.#localPosition(record, this.clock.positionAt(now));\n // Prefer the follower's own clock over sampling: exact read at `now`,\n // and `paused` is authoritative where the optional `running` getter\n // may be absent entirely.\n const followerClock = record.transport.clock;\n // A follower's own pre-roll may extend past the common join instant.\n // Its parked position is not drift until that actual start arrives.\n if (followerClock?.holding && now < followerClock.state.originTime) continue;\n const followerPosition = followerClock\n ? followerClock.positionAt(now)\n : record.transport.position;\n const followerRunning = followerClock\n ? !followerClock.paused\n : record.transport.running !== false;\n let localDrift = this.#wrapLocal(record, followerPosition) - expected;\n if (record.loop && followerPosition >= record.loop.startSeconds && expected >= record.loop.startSeconds) {\n const period = record.loop.endSeconds - record.loop.startSeconds;\n localDrift = ((localDrift + period / 2) % period + period) % period - period / 2;\n }\n const drift = localDrift / record.scale;\n // Drift is REPORTED for every member, running or not — a follower whose\n // clock reports paused (ended, torn down) is a real divergence a caller\n // may want to see. It is simply never corrected into a re-join thrash.\n if (Math.abs(drift) > Math.abs(worst)) worst = drift;\n if (!followerRunning) continue;\n // A slope mismatch counts as divergence in its own right: re-joining on\n // position alone re-diverges immediately, which is a re-join every\n // check forever rather than convergence. Both axes carry the same rate\n // scalar after applying the explicit local-axis scale, so an\n // inequality here is real divergence, not a unit difference.\n const rateMismatch = followerClock !== undefined && followerClock.rate !== this.clock.rate * record.scale;\n if (Math.abs(drift) <= this.#driftTolerance && !rateMismatch) {\n // In tolerance on both axes: whatever the last correction did, it stuck.\n record.consecutiveDriftJoins = 0;\n record.driftJoinsSuppressed = false;\n continue;\n }\n if (record.driftJoinsSuppressed) continue;\n record.consecutiveDriftJoins += 1;\n if (record.consecutiveDriftJoins > MAX_CONSECUTIVE_DRIFT_JOINS) {\n // Every correction so far re-anchored this follower and the drift\n // came straight back, so it cannot hold the master's slope (an\n // unclampable master rate, a follower without setRate). Re-joining\n // forever would just restart it once per check with no prospect of\n // converging; stop and say so instead. A check that lands back in\n // tolerance, or any explicit command, re-arms corrections.\n record.driftJoinsSuppressed = true;\n this.#reportOperationError(\n 'drift re-join',\n new Error(\n `TransportGroup: ${record.consecutiveDriftJoins} consecutive drift corrections failed to ` +\n `converge (drift ${drift.toFixed(4)}s, master rate ${this.clock.rate}). The follower ` +\n 'cannot follow the master rate; automatic re-joins are paused until they agree again.',\n ),\n );\n continue;\n }\n stragglers.push(record);\n }\n if (stragglers.length > 0) {\n this.#observeReconciliation('drift re-join', () => this.#queueJoin(this.#generation, 'drift re-join', stragglers));\n }\n return worst;\n }\n\n #wrapLocal(record: FollowerRecord, position: number): number {\n const loop = record.loop;\n if (!loop || position < loop.endSeconds) return position;\n return loop.startSeconds + (position - loop.startSeconds) % (loop.endSeconds - loop.startSeconds);\n }\n\n #localPosition(record: FollowerRecord, masterPosition: number): number {\n return this.#wrapLocal(record, record.offset + masterPosition * record.scale);\n }\n\n /**\n * Schedule followers to (re)join the running master: one reference-clock\n * read, the seek target exact-by-construction for `when` — the same\n * affine map the master plays by. A holding (scheduled-start) master\n * clock whose origin is still in the future is taken as-is, even inside\n * the lead-in horizon: the master has not made a sound yet, so joining\n * exactly at the armed origin is what makes the shared start gapless.\n */\n async #joinFollowers(generation: number, targets: readonly FollowerRecord[], strict = false): Promise<void> {\n if (!this.#isCurrent(generation)) return;\n // External callbacks may remove members while this operation is visiting\n // them. Preserve the visit order without skipping the next live member.\n const members = [...targets];\n for (const record of members) {\n if (!this.#isCurrent(generation)) return;\n if (this.#followers.includes(record)) record.transport.pause();\n }\n const clock = this.clock;\n if (clock.paused) return;\n const now = this.#now();\n const armedOrigin = clock.holding ? clock.state.originTime : -Infinity;\n const when = armedOrigin > now ? armedOrigin : now + this.#leadIn;\n const position = clock.positionAt(when);\n const starts: Array<Promise<void> | void> = [];\n for (const record of members) {\n if (!this.#isCurrent(generation)) break;\n if (!this.#followers.includes(record)) continue;\n try {\n record.joinAt = when;\n // Align the local slope before seeking the mapped future phase.\n this.#applyFollowerRate(record, clock.rate, strict);\n // Rate callbacks can detach a follower or synchronously replace\n // the command. Its old join must not mutate either lifetime.\n if (!this.#isCurrent(generation) || !this.#followers.includes(record)) continue;\n record.transport.seek(this.#localPosition(record, position));\n if (!this.#isCurrent(generation) || !this.#followers.includes(record)) continue;\n starts.push(record.transport.play(when));\n } catch (error) {\n starts.push(Promise.reject(error));\n break;\n }\n }\n // A rejected participant must not leave a still-pending sibling able to\n // restart after failure cleanup has already been reported as complete.\n const settled = await Promise.allSettled(starts);\n if (!this.#isCurrent(generation)) this.#reapplySynchronousIntent();\n const failure = settled.find((result) => result.status === 'rejected');\n if (failure?.status === 'rejected') throw failure.reason;\n if (strict && this.#isCurrent(generation)) {\n for (const record of members) {\n if (!this.#followers.includes(record)) continue;\n const followerClock = record.transport.clock;\n const running = followerClock ? !followerClock.paused : record.transport.running;\n if (running === false) throw new Error('Follower transport did not start.');\n }\n }\n }\n\n /**\n * Hand a follower a rate, skipping the call when it already runs at it.\n * A follower with a clock is asked directly; for one without, the last\n * applied value is remembered. Best-effort by contract: `setRate` is\n * optional on {@link SyncFollowerTransport}, and a transport that has one\n * may still clamp or refuse it — the convergence check below is what\n * surfaces a mismatch neither side can resolve.\n */\n #applyFollowerRate(record: FollowerRecord, rate: number, strict = false): void {\n rate *= record.scale;\n if (!record.transport.setRate) {\n if (strict && (record.transport.clock?.rate ?? 1) !== rate) {\n throw new Error('Follower transport cannot accept the requested rate.');\n }\n return;\n }\n if (!Number.isFinite(rate) || rate <= 0) return;\n const current = record.transport.clock?.rate ?? record.lastRate;\n if (current === rate) return;\n try {\n record.transport.setRate(rate);\n if (strict && record.transport.clock && record.transport.clock.rate !== rate) {\n throw new Error('Follower transport did not accept the requested rate.');\n }\n record.lastRate = rate;\n } catch (error) {\n if (strict) throw error;\n this.#reportOperationError('follower rate match', error);\n }\n }\n\n /** Re-arm drift corrections; any explicit command counts as a fresh start. */\n #resetDriftConvergence(): void {\n for (const record of this.#followers) {\n record.consecutiveDriftJoins = 0;\n record.driftJoinsSuppressed = false;\n }\n }\n\n /**\n * One watcher drives every concern off a kernel tick source (worker-backed\n * where the platform allows, so background-tab throttling does not starve\n * it): master-stop reconciliation and the loop boundary every tick, drift\n * every `driftCheckIntervalMs` worth of ticks.\n */\n #onTick(): void {\n if (this.#disposed) return;\n const revision = this.#revision;\n try {\n this.#reconcileMasterStop();\n this.#checkLoop();\n this.#tickCount += 1;\n if (this.#driftIntervalMs > 0 && this.#tickCount % this.#ticksPerDriftCheck === 0) {\n this.checkDrift();\n }\n } catch (error) {\n // There is no awaiting caller for a timer callback. Report its failure\n // after settling the current session, without pausing a newer command\n // that an adapter may have synchronously dispatched before throwing.\n if (this.#disposed) return;\n if (revision === this.#revision) this.#rollbackFailedPlay();\n this.#reportOperationError('transport monitor', error);\n }\n }\n\n /**\n * The master can stop on its own (a score player finishing at its natural\n * end pauses and rewinds its clock, racing the group's boundary watcher\n * tick-for-tick). A self-stopped clock while the group means to play\n * either wraps (loop active — the loop's continuation intent outranks the\n * master's own finish) or settles into the paused state.\n */\n #reconcileMasterStop(): void {\n if (this.#intent !== 'playing' || this.#wrapping || this.#pendingTransitions > 0) return;\n if (!this.clock.paused) return;\n this.#handleMasterStopped();\n }\n\n #handleMasterStopped(): void {\n if (this.#loop && !this.#wrapping) {\n this.#wrap(this.#loop.startSeconds);\n } else {\n this.#settleMasterStopped();\n }\n }\n\n #checkLoop(): void {\n const loop = this.#loop;\n if (!loop || this.clock.paused || this.#wrapping || this.#pendingTransitions > 0) return;\n if (this.clock.positionAt(this.#now()) >= loop.endSeconds) {\n this.#wrap(loop.startSeconds);\n }\n }\n\n /**\n * Wrap to the loop start. A running master re-joins inside seek(); a\n * master that stopped on its own (natural finish at or past the loop end)\n * is restarted afterwards. A failed wrap settles into the paused state\n * instead of retrying every tick, and is reported as 'loop wrap'.\n */\n #wrap(startSeconds: number): void {\n this.#wrapping = true;\n void this.seek(startSeconds)\n .then(() => {\n if (!this.#disposed && this.#intent === 'playing' && this.clock.paused) {\n return this.play();\n }\n })\n .catch((error: unknown) => {\n this.#reportOperationError('loop wrap', error);\n if (!this.#disposed && this.#intent === 'playing') this.#settleMasterStopped();\n })\n .finally(() => {\n this.#wrapping = false;\n });\n }\n\n #startDriftMonitor(): void {\n if (!this.#needsMonitor()) {\n this.#stopDriftMonitor();\n return;\n }\n this.#ticker ??= createTickSource(this.#tickOptions);\n this.#ticker.start(() => this.#onTick());\n }\n\n #stopDriftMonitor(): void {\n this.#ticker?.stop();\n this.#tickCount = 0;\n }\n\n #needsMonitor(): boolean {\n return this.#loop !== null || this.#driftIntervalMs > 0;\n }\n\n #isCurrent(generation: number): boolean {\n return !this.#disposed && generation === this.#generation;\n }\n\n #reportOperationError(operation: string, error: unknown): void {\n this.#publish({type: 'operation-error', operation, error, snapshot: this.snapshot});\n try {\n this.#onOperationError?.(operation, error);\n } catch {\n // The observer must never disturb transport-state handling.\n }\n }\n\n /**\n * The master stopped although the group meant to be playing (a swallowed\n * restart failure, or the master ending on its own): pause the followers\n * and settle, exactly as an explicit pause() would.\n */\n #settleMasterStopped(): void {\n this.pause();\n }\n\n #settleFailedResume(): void {\n this.#settleMasterStopped();\n this.#reportOperationError(\n 'resume after seek',\n new Error('TransportGroup: the master transport stayed paused after a mid-playback seek.'),\n );\n }\n\n #assertActive(): void {\n if (this.#disposed) throw new Error('TransportGroup has been disposed.');\n }\n\n #observeReconciliation(operation: string, apply: () => Promise<void>): void {\n const revision = ++this.#revision;\n this.#pendingCommands.add(revision);\n this.#publish({type: 'reconcile', operation, phase: 'invalidate', snapshot: this.snapshot});\n const pending = revision === this.#revision && !this.#disposed ? apply() : Promise.resolve();\n void pending.catch((error: unknown) => this.#reportOperationError(operation, error)).finally(() => {\n this.#pendingCommands.delete(revision);\n this.#publish({type: 'reconcile', operation, phase: 'settled', snapshot: this.snapshot});\n });\n }\n\n /**\n * Queue an independent re-join as a visible transition. Public pause/stop\n * calls can then schedule one final reconciliation behind it, preventing\n * a late follower play() settlement from reviving playback.\n */\n #queueJoin(generation: number, operation: string, targets: readonly FollowerRecord[], strict = false): Promise<void> {\n const revision = this.#revision;\n this.#pendingTransitions += 1;\n return this.#enqueueCommand(async () => {\n try {\n await this.#joinFollowers(generation, targets, strict);\n } finally {\n this.#pendingTransitions -= 1;\n }\n }).catch((error: unknown) => {\n // The FIFO may already have begun a newer seek/rate command before\n // this rejection handler runs. Old failure must not pause that owner.\n if (this.#isCurrent(generation) && revision === this.#revision) this.#rollbackFailedPlay();\n if (!this.#disposed) this.#reportOperationError(operation, error);\n if (strict) throw error;\n });\n }\n\n /**\n * Run the first idle command immediately so master.play() remains inside\n * the browser's transient user-activation stack. Only commands that\n * actually have an async predecessor wait in the FIFO.\n */\n #enqueueCommand<Result>(operation: () => Result | PromiseLike<Result>): Promise<Result> {\n return new Promise<Result>((resolve, reject) => {\n const run = () => {\n let result: Result | PromiseLike<Result>;\n try {\n result = operation();\n } catch (error) {\n reject(error);\n this.#finishCommand();\n return;\n }\n Promise.resolve(result).then(\n (value) => {\n resolve(value);\n this.#finishCommand();\n },\n (error: unknown) => {\n reject(error);\n this.#finishCommand();\n },\n );\n };\n\n if (this.#commandActive) {\n this.#queuedCommands.push(run);\n } else {\n this.#commandActive = true;\n run();\n }\n });\n }\n\n #finishCommand(): void {\n const next = this.#queuedCommands.shift();\n if (next) {\n next();\n } else {\n this.#commandActive = false;\n }\n }\n\n /** Read the master's actual post-seek position (it may clamp). */\n #readSettledMasterPosition(): number {\n const position = this.#master.position;\n if (!Number.isFinite(position) || position < 0) {\n throw new RangeError('Master transport returned an invalid position after seek.');\n }\n return position;\n }\n\n /** Preserve the completed seek position when pause superseded it. */\n #reconcileStaleSeek(position: number): void {\n if (this.#disposed || this.#intent !== 'paused') return;\n const generation = this.#generation;\n for (const record of [...this.#followers]) {\n if (!this.#isCurrent(generation)) break;\n if (!this.#followers.includes(record)) continue;\n record.transport.seek(this.#localPosition(record, position));\n }\n }\n\n /** Re-apply pause/stop after an older async master command settles late. */\n #reapplySynchronousIntent(): void {\n if (this.#disposed) return;\n if (this.#intent === 'paused') {\n this.#applyPause();\n } else if (this.#intent === 'stopped') {\n this.#applyStop();\n }\n }\n\n #applyPause(): void {\n const generation = this.#generation;\n const errors: unknown[] = [];\n for (const record of [...this.#followers]) {\n if (!this.#isCurrent(generation)) break;\n if (!this.#followers.includes(record)) continue;\n try { record.transport.pause(); } catch (error) { errors.push(error); }\n }\n if (this.#isCurrent(generation)) {\n try { this.#master.pause(); } catch (error) { errors.push(error); }\n }\n if (errors.length > 0) throw errors[0];\n }\n\n #applyStop(): void {\n const generation = this.#generation;\n const errors: unknown[] = [];\n for (const record of [...this.#followers]) {\n if (!this.#isCurrent(generation)) break;\n if (!this.#followers.includes(record)) continue;\n try { record.transport.stop(); } catch (error) { errors.push(error); }\n }\n if (this.#isCurrent(generation)) {\n try { this.#master.stop(); } catch (error) { errors.push(error); }\n }\n if (errors.length > 0) throw errors[0];\n }\n\n #rollbackFailedPlay(): void {\n ++this.#generation;\n this.#intent = 'paused';\n this.#stopDriftMonitor();\n try {\n this.#applyPause();\n } catch {\n // Preserve the original failure while respecting callback re-entry.\n }\n }\n}\n\n/**\n * Minimal command surface a clockless transport must offer so\n * {@link MirrorClockMaster} can adapt it into the master role.\n */\nexport interface ClocklessMasterTransport {\n play(when?: number): Promise<void> | void;\n pause(): void;\n stop(): void;\n seekPosition(position: number, when?: number): void | Promise<void>;\n setRate?(rate: number): void;\n readonly position: number;\n dispose?(): void;\n}\n\n/**\n * Adapts a transport WITHOUT a readable clock into the required-clock\n * master role by dead-reckoning a mirror TransportClock across the command\n * surface, and reconciling the reckoning against the transport's actual\n * position on every drift check:\n *\n * - two identical position samples while the mirror advanced past the\n * tolerance mean the transport stopped on its own (ended, clamped at its\n * duration, paused out of band) — the adapter pauses the mirror and\n * reports 'stalled', which the group treats as a master stop;\n * - a moving transport that diverged from the extrapolation (refused or\n * clamped rate, tempo automation) re-anchors the mirror so drift is\n * measured against the transport, not the reckoning.\n *\n * This is the ONE home of the sampled fallback the score↔audio bridge used\n * to interleave through its clocked path.\n */\nexport class MirrorClockMaster implements SyncMasterTransport {\n readonly #inner: ClocklessMasterTransport;\n readonly #mirror: TransportClock;\n readonly #now: () => number;\n #tolerance: number;\n #lastSample: {position: number; mirrorPosition: number; time: number} | null = null;\n\n constructor(inner: ClocklessMasterTransport, now: () => number, options: {reconcileToleranceSeconds?: number} = {}) {\n this.#inner = inner;\n this.#now = now;\n this.#tolerance = options.reconcileToleranceSeconds ?? 0.03;\n assertFiniteNonNegative('reconcileToleranceSeconds', this.#tolerance);\n this.#mirror = new TransportClock(now);\n }\n\n get clock(): TransportClockReader {\n return this.#mirror;\n }\n\n get position(): number {\n return this.#inner.position;\n }\n\n async play(when?: number): Promise<void> {\n await this.#inner.play(when);\n this.#lastSample = null;\n this.#mirror.start(this.#now(), this.#inner.position);\n }\n\n pause(): void {\n this.#inner.pause();\n this.#lastSample = null;\n this.#mirror.pause(this.#now());\n }\n\n stop(): void {\n this.#inner.stop();\n this.#lastSample = null;\n const now = this.#now();\n this.#mirror.pause(now);\n this.#mirror.seekTo(0, now);\n }\n\n async seekPosition(position: number, when?: number): Promise<void> {\n await this.#inner.seekPosition(position, when);\n this.#lastSample = null;\n this.#mirror.seekTo(this.#inner.position, this.#now());\n }\n\n setRate(rate: number): void {\n this.#inner.setRate?.(rate);\n this.#lastSample = null;\n this.#mirror.setRate(rate, this.#now());\n }\n\n reconcile(now: number): 'ok' | 'stalled' {\n const actual = this.#inner.position;\n if (!Number.isFinite(actual) || actual < 0) return 'ok';\n const mirrorPosition = this.#mirror.positionAt(now);\n const sample = this.#lastSample;\n this.#lastSample = {position: actual, mirrorPosition, time: now};\n if (\n sample !== null &&\n actual === sample.position &&\n mirrorPosition - sample.mirrorPosition > this.#tolerance &&\n !this.#mirror.paused\n ) {\n this.#lastSample = null;\n this.#mirror.pause(now);\n return 'stalled';\n }\n // Correct the reckoning's SLOPE, not only its intercept. A transport\n // that clamped or refused the shared rate advances at a rate the mirror\n // does not know; re-anchoring the position alone leaves the mirror\n // drifting away again before the next check, which is what turns a rate\n // mismatch into an endless correction loop. The next join then hands the\n // followers the rate the transport actually runs at.\n if (sample !== null && !this.#mirror.paused) {\n const elapsed = now - sample.time;\n const advanced = actual - sample.position;\n if (elapsed > 0 && advanced > 0) {\n const measured = advanced / elapsed;\n const current = this.#mirror.rate;\n if (\n Number.isFinite(measured) &&\n measured > 0 &&\n Math.abs(measured - current) > MIRROR_RATE_TOLERANCE * current\n ) {\n this.#mirror.setRate(measured, now);\n }\n }\n }\n if (Math.abs(mirrorPosition - actual) > this.#tolerance) {\n this.#mirror.seekTo(actual, now);\n }\n return 'ok';\n }\n\n dispose(): void {\n this.#inner.dispose?.();\n }\n}\n\nfunction assertFiniteNonNegative(name: string, value: number): void {\n if (!Number.isFinite(value) || value < 0) {\n throw new RangeError(`${name} must be finite and >= 0.`);\n }\n}\n\nfunction assertValidLoop(loop: SyncLoopRegion): void {\n if (\n !Number.isFinite(loop.startSeconds) || loop.startSeconds < 0 ||\n !Number.isFinite(loop.endSeconds) || !(loop.endSeconds > loop.startSeconds)\n ) {\n throw new RangeError('Loop bounds must be finite, non-negative, and endSeconds must be greater than startSeconds.');\n }\n}\n\n/** Validate before changing revision or touching participants. */\nfunction validateCommand(command: TransportCommand): void {\n switch (command.type) {\n case 'play': case 'pause': case 'stop': return;\n case 'seek': assertFiniteNonNegative('position', command.position); return;\n case 'rate':\n if (!Number.isFinite(command.rate) || command.rate <= 0) throw new RangeError('rate must be finite and > 0.');\n return;\n case 'loop': if (command.loop) assertValidLoop(command.loop); return;\n default: throw new TypeError('Unknown transport command.');\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/player.ts
|
|
2
|
+
function isTimedPlayer(player) {
|
|
3
|
+
return typeof player.seconds === "number" && typeof player.duration === "number";
|
|
4
|
+
}
|
|
5
|
+
function isStatefulPlayer(player) {
|
|
6
|
+
return typeof player.playing === "boolean";
|
|
7
|
+
}
|
|
8
|
+
function isRateControlledPlayer(player) {
|
|
9
|
+
return typeof player.setRate === "function";
|
|
10
|
+
}
|
|
11
|
+
function isVolumeControlledPlayer(player) {
|
|
12
|
+
return typeof player.setVolume === "function";
|
|
13
|
+
}
|
|
14
|
+
function isDisposablePlayer(player) {
|
|
15
|
+
return typeof player.dispose === "function";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
isTimedPlayer,
|
|
20
|
+
isStatefulPlayer,
|
|
21
|
+
isRateControlledPlayer,
|
|
22
|
+
isVolumeControlledPlayer,
|
|
23
|
+
isDisposablePlayer
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-N6KU2HYA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/player.ts"],"sourcesContent":["// ============================================================================\n// Playback control contract shared by both families. AudioClipPlayer\n// satisfies it on the audio side; ScorePlayer and TonePlayer satisfy it\n// structurally on the score side. Each family pins its players against the\n// contract in its own src/play/headless/playerlike-contract.ts. For the pure\n// clock/anchor math a player uses internally, see ./transport.\n// ============================================================================\n\n/**\n * Structural playback control contract.\n *\n * Members use method shorthand syntax DELIBERATELY: method bivariance is what\n * lets a typed-emitter `on<K extends keyof E>(...)` satisfy the loose\n * `on(event: string, ...)` here. Do not convert to arrow-property signatures —\n * under strictFunctionTypes that rejects every typed-emitter implementer.\n */\nexport interface PlayerLike {\n play(): Promise<void> | void;\n pause(): void;\n stop(): void;\n seek(seconds: number): void;\n setRate?(rate: number): void;\n setVolume?(volume: number): void;\n readonly seconds?: number;\n readonly duration?: number;\n readonly playing?: boolean;\n on(event: string, listener: (data: unknown) => void): () => void;\n dispose?(): void;\n}\n\n// ----------------------------------------------------------------------------\n// Capability tiers. PlayerLike's optional members are deliberate: the base\n// contract is the lowest common denominator both families can always promise.\n// The interfaces below NAME each optional capability, and the guards are the\n// supported feature-testing protocol — a generic consumer narrows with a\n// guard once instead of poking optional members everywhere. Implementers\n// advertise a capability by making its members non-optional; consumers must\n// treat a failed guard as \"capability absent\", never as an error.\n// ----------------------------------------------------------------------------\n\n/** A player that reports timeline position and total duration in seconds. */\nexport interface TimedPlayerLike extends PlayerLike {\n readonly seconds: number;\n readonly duration: number;\n}\n\n/** A player whose playing state is readable synchronously. */\nexport interface StatefulPlayerLike extends PlayerLike {\n readonly playing: boolean;\n}\n\n/** A player with adjustable playback rate. */\nexport interface RateControlledPlayerLike extends PlayerLike {\n setRate(rate: number): void;\n}\n\n/** A player with adjustable output volume. */\nexport interface VolumeControlledPlayerLike extends PlayerLike {\n setVolume(volume: number): void;\n}\n\n/** A player owning resources that must be released when it is done. */\nexport interface DisposablePlayerLike extends PlayerLike {\n dispose(): void;\n}\n\nexport function isTimedPlayer(player: PlayerLike): player is TimedPlayerLike {\n return typeof player.seconds === 'number' && typeof player.duration === 'number';\n}\n\nexport function isStatefulPlayer(player: PlayerLike): player is StatefulPlayerLike {\n return typeof player.playing === 'boolean';\n}\n\nexport function isRateControlledPlayer(player: PlayerLike): player is RateControlledPlayerLike {\n return typeof player.setRate === 'function';\n}\n\nexport function isVolumeControlledPlayer(player: PlayerLike): player is VolumeControlledPlayerLike {\n return typeof player.setVolume === 'function';\n}\n\nexport function isDisposablePlayer(player: PlayerLike): player is DisposablePlayerLike {\n return typeof player.dispose === 'function';\n}\n"],"mappings":";AAkEO,SAAS,cAAc,QAA+C;AAC3E,SAAO,OAAO,OAAO,YAAY,YAAY,OAAO,OAAO,aAAa;AAC1E;AAEO,SAAS,iBAAiB,QAAkD;AACjF,SAAO,OAAO,OAAO,YAAY;AACnC;AAEO,SAAS,uBAAuB,QAAwD;AAC7F,SAAO,OAAO,OAAO,YAAY;AACnC;AAEO,SAAS,yBAAyB,QAA0D;AACjG,SAAO,OAAO,OAAO,cAAc;AACrC;AAEO,SAAS,mBAAmB,QAAoD;AACrF,SAAO,OAAO,OAAO,YAAY;AACnC;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __typeError = (msg) => {
|
|
2
|
+
throw TypeError(msg);
|
|
3
|
+
};
|
|
4
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
5
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
6
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
9
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
10
|
+
set _(value) {
|
|
11
|
+
__privateSet(obj, member, value, setter);
|
|
12
|
+
},
|
|
13
|
+
get _() {
|
|
14
|
+
return __privateGet(obj, member, getter);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
__privateGet,
|
|
20
|
+
__privateAdd,
|
|
21
|
+
__privateSet,
|
|
22
|
+
__privateMethod,
|
|
23
|
+
__privateWrapper
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-PXG64RU4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk7ZTZZ5PNcjs = require('./chunk-7ZTZZ5PN.cjs');
|
|
6
|
+
|
|
7
|
+
// src/transport.ts
|
|
8
|
+
var _originTime, _originPosition, _rate, _paused, _holdUntilOrigin, _now;
|
|
9
|
+
var TransportClock = class {
|
|
10
|
+
/** @param now Optional reference clock enabling the zero-arg `position` getter. */
|
|
11
|
+
constructor(now) {
|
|
12
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _originTime, 0);
|
|
13
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _originPosition, 0);
|
|
14
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _rate, 1);
|
|
15
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _paused, true);
|
|
16
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _holdUntilOrigin, false);
|
|
17
|
+
_chunk7ZTZZ5PNcjs.__privateAdd.call(void 0, this, _now);
|
|
18
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _now, now);
|
|
19
|
+
}
|
|
20
|
+
get state() {
|
|
21
|
+
return {
|
|
22
|
+
originTime: _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originTime),
|
|
23
|
+
originPosition: _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originPosition),
|
|
24
|
+
rate: _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _rate),
|
|
25
|
+
paused: _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _paused)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
get rate() {
|
|
29
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _rate);
|
|
30
|
+
}
|
|
31
|
+
get paused() {
|
|
32
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _paused);
|
|
33
|
+
}
|
|
34
|
+
/** Current position via the injected `now()` clock. Throws when none was injected. */
|
|
35
|
+
get position() {
|
|
36
|
+
if (!_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _now)) throw new Error("TransportClock has no injected now() clock; use positionAt(t).");
|
|
37
|
+
return this.positionAt(_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _now).call(this));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* True when a {@link startAt} start is armed. The flag is cleared by the
|
|
41
|
+
* next {@link start} or {@link pause} — NOT by the origin time passing —
|
|
42
|
+
* so callers combining it with {@link TransportClockState.originTime}
|
|
43
|
+
* should treat "holding and origin still in the future" as the pre-roll
|
|
44
|
+
* condition (positionAt handles this internally either way).
|
|
45
|
+
*/
|
|
46
|
+
get holding() {
|
|
47
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _holdUntilOrigin);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Position at reference time `t`. While paused this is constant. `t` before
|
|
51
|
+
* the anchor yields positions before it (possibly negative) — callers clamp
|
|
52
|
+
* to their own domain — EXCEPT after {@link startAt}, where the position
|
|
53
|
+
* holds at the armed origin position through the pre-roll (mirroring how a
|
|
54
|
+
* scheduled `source.start(when)` sounds nothing before `when`).
|
|
55
|
+
*/
|
|
56
|
+
positionAt(t) {
|
|
57
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _paused)) return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originPosition);
|
|
58
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _holdUntilOrigin) && t < _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originTime)) return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originPosition);
|
|
59
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originPosition) + (t - _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originTime)) * _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _rate);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Inverse of {@link positionAt}. Throws RangeError while paused: no
|
|
63
|
+
* reference time maps to a position when the transport is frozen — guard
|
|
64
|
+
* with {@link paused} before calling. While a {@link startAt} start is
|
|
65
|
+
* armed, positions before the armed origin position also throw: the
|
|
66
|
+
* position holds through the pre-roll and never passes below the origin,
|
|
67
|
+
* so no reference time maps to them (extrapolating backwards would return
|
|
68
|
+
* a time whose {@link positionAt} is NOT the requested position).
|
|
69
|
+
*/
|
|
70
|
+
timeAt(position) {
|
|
71
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _paused)) throw new RangeError("TransportClock is paused; no reference time maps to a position.");
|
|
72
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _holdUntilOrigin) && position < _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originPosition)) {
|
|
73
|
+
throw new RangeError(
|
|
74
|
+
"TransportClock is holding a scheduled start; no reference time maps to a position before the armed origin position."
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originTime) + (position - _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originPosition)) / _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _rate);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Anchor at `(t, position ?? current position)` and unpause. Re-anchoring
|
|
81
|
+
* while already playing is idempotent for the position at `t`.
|
|
82
|
+
*/
|
|
83
|
+
start(t, position) {
|
|
84
|
+
assertFiniteAnchor("start time", t);
|
|
85
|
+
if (position !== void 0) assertFiniteAnchor("start position", position);
|
|
86
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _originPosition, _nullishCoalesce(position, () => ( this.positionAt(t))));
|
|
87
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _originTime, t);
|
|
88
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _paused, false);
|
|
89
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _holdUntilOrigin, false);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Arm a SCHEDULED start: anchor at a (typically future) reference time and
|
|
93
|
+
* unpause, with the position holding at `position` until `t` arrives —
|
|
94
|
+
* the clock-side mirror of a sample-accurate `play(when)`. Transitions
|
|
95
|
+
* during the pre-roll keep the armed origin: {@link setRate} changes the
|
|
96
|
+
* slope after `t` without collapsing the hold, {@link seekTo} re-arms the
|
|
97
|
+
* held position, and {@link pause} cancels the pending start.
|
|
98
|
+
*/
|
|
99
|
+
startAt(t, position) {
|
|
100
|
+
assertFiniteAnchor("startAt time", t);
|
|
101
|
+
assertFiniteAnchor("startAt position", position);
|
|
102
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _originPosition, position);
|
|
103
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _originTime, t);
|
|
104
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _paused, false);
|
|
105
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _holdUntilOrigin, true);
|
|
106
|
+
}
|
|
107
|
+
/** Fold elapsed time into the anchor; `positionAt()` is constant afterwards. */
|
|
108
|
+
pause(t) {
|
|
109
|
+
assertFiniteAnchor("pause time", t);
|
|
110
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _originPosition, this.positionAt(t));
|
|
111
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _originTime, t);
|
|
112
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _paused, true);
|
|
113
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _holdUntilOrigin, false);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Re-anchor at a new position; preserves the paused/playing state. During
|
|
117
|
+
* an armed pre-roll the scheduled origin time is kept (the pending start
|
|
118
|
+
* stays pending at the new position).
|
|
119
|
+
*/
|
|
120
|
+
seekTo(position, t) {
|
|
121
|
+
assertFiniteAnchor("seek position", position);
|
|
122
|
+
assertFiniteAnchor("seek time", t);
|
|
123
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _originPosition, position);
|
|
124
|
+
if (!(_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _holdUntilOrigin) && t < _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originTime))) {
|
|
125
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _originTime, t);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Re-anchor so the position is continuous across the rate change:
|
|
130
|
+
* `originPosition = positionAt(t); originTime = t; rate = r`.
|
|
131
|
+
* Throws RangeError unless `r` is finite and > 0.
|
|
132
|
+
*/
|
|
133
|
+
setRate(r, t) {
|
|
134
|
+
if (!Number.isFinite(r) || r <= 0) {
|
|
135
|
+
throw new RangeError(`TransportClock rate must be finite and > 0, got ${r}.`);
|
|
136
|
+
}
|
|
137
|
+
assertFiniteAnchor("setRate time", t);
|
|
138
|
+
if (_chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _holdUntilOrigin) && t < _chunk7ZTZZ5PNcjs.__privateGet.call(void 0, this, _originTime)) {
|
|
139
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _rate, r);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _originPosition, this.positionAt(t));
|
|
143
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _originTime, t);
|
|
144
|
+
_chunk7ZTZZ5PNcjs.__privateSet.call(void 0, this, _rate, r);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
_originTime = new WeakMap();
|
|
148
|
+
_originPosition = new WeakMap();
|
|
149
|
+
_rate = new WeakMap();
|
|
150
|
+
_paused = new WeakMap();
|
|
151
|
+
_holdUntilOrigin = new WeakMap();
|
|
152
|
+
_now = new WeakMap();
|
|
153
|
+
function assertFiniteAnchor(name, value) {
|
|
154
|
+
if (!Number.isFinite(value)) {
|
|
155
|
+
throw new RangeError(`TransportClock ${name} must be a finite number, got ${value}.`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
exports.TransportClock = TransportClock;
|
|
162
|
+
//# sourceMappingURL=chunk-SM5YPDDI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/mamingchen/GitHub/public/WebMusic/platform/kernel/dist/chunk-SM5YPDDI.cjs","../src/transport.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,IAAA,WAAA,EAAA,eAAA,EAAA,KAAA,EAAA,OAAA,EAAA,gBAAA,EAAA,IAAA;AA4CO,IAAM,eAAA,EAAN,MAAqB;AAAA;AAAA,EAS1B,WAAA,CAAY,GAAA,EAAoB;AARhC,IAAA,4CAAA,IAAA,EAAA,WAAA,EAAc,CAAA,CAAA;AACd,IAAA,4CAAA,IAAA,EAAA,eAAA,EAAkB,CAAA,CAAA;AAClB,IAAA,4CAAA,IAAA,EAAA,KAAA,EAAQ,CAAA,CAAA;AACR,IAAA,4CAAA,IAAA,EAAA,OAAA,EAAU,IAAA,CAAA;AACV,IAA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AA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AAC3B,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,eAAA,EAAkB,IAAI,CAAA,8BAAA,EAAiC,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA,EACtF;AACF;AD9CA;AACA;AACE;AACF,wCAAC","file":"/Users/mamingchen/GitHub/public/WebMusic/platform/kernel/dist/chunk-SM5YPDDI.cjs","sourcesContent":[null,"// ============================================================================\n// Pure transport math shared by both families' playback engines, and the\n// timeline-mapping contract that lets musical time axes (score quarters,\n// audio beats) interoperate through seconds. No Web Audio, no domain types —\n// numbers in, numbers out. For the imperative playback control surface a\n// player exposes, see ./player.\n//\n// Terminology: TransportClock's \"position\" is a TIMELINE position (typically\n// media seconds); TimelineMapping's \"position\" is a MUSICAL position\n// (quarters, beats — the consumer defines the unit). The mapping converts\n// between the two axes.\n// ============================================================================\n\n/** Immutable snapshot of a transport anchor. All numbers, unit-agnostic. */\nexport interface TransportClockState {\n /** Reference-clock timestamp of the anchor. */\n readonly originTime: number;\n /** Timeline position at `originTime`. */\n readonly originPosition: number;\n /** Finite and > 0; position advances `rate`× reference time. */\n readonly rate: number;\n readonly paused: boolean;\n}\n\n/**\n * Affine mapping between an external monotonic reference clock (any number\n * domain — `AudioContext.currentTime`, `performance.now()/1000`, a test\n * counter) and a timeline position. Pure: never reads a real clock unless\n * `now` is injected; every mutator takes the current reference time\n * explicitly.\n *\n * position(t) = paused ? originPosition\n * : originPosition + (t - originTime) * rate\n *\n * The semantics mirror the two engines this abstracts: re-anchor math is the\n * score scheduler's retune (capture position, reset both anchors) and\n * BufferEngine's setRate; pause folds elapsed time into `originPosition`.\n * Loop/wrap is deliberately OUT of scope — consumers implement it as\n * `seekTo(loopStart, t)`, which is exactly what the engines do today.\n * Negative times and positions pass through unclamped; clamping to a\n * duration is domain policy. Every anchor mutator rejects non-finite\n * numbers: a NaN reference time or position would silently poison the\n * anchor and every later `positionAt` read, with no error at the source.\n */\nexport class TransportClock {\n #originTime = 0;\n #originPosition = 0;\n #rate = 1;\n #paused = true;\n #holdUntilOrigin = false;\n readonly #now?: () => number;\n\n /** @param now Optional reference clock enabling the zero-arg `position` getter. */\n constructor(now?: () => number) {\n this.#now = now;\n }\n\n get state(): TransportClockState {\n return {\n originTime: this.#originTime,\n originPosition: this.#originPosition,\n rate: this.#rate,\n paused: this.#paused,\n };\n }\n\n get rate(): number {\n return this.#rate;\n }\n\n get paused(): boolean {\n return this.#paused;\n }\n\n /** Current position via the injected `now()` clock. Throws when none was injected. */\n get position(): number {\n if (!this.#now) throw new Error('TransportClock has no injected now() clock; use positionAt(t).');\n return this.positionAt(this.#now());\n }\n\n /**\n * True when a {@link startAt} start is armed. The flag is cleared by the\n * next {@link start} or {@link pause} — NOT by the origin time passing —\n * so callers combining it with {@link TransportClockState.originTime}\n * should treat \"holding and origin still in the future\" as the pre-roll\n * condition (positionAt handles this internally either way).\n */\n get holding(): boolean {\n return this.#holdUntilOrigin;\n }\n\n /**\n * Position at reference time `t`. While paused this is constant. `t` before\n * the anchor yields positions before it (possibly negative) — callers clamp\n * to their own domain — EXCEPT after {@link startAt}, where the position\n * holds at the armed origin position through the pre-roll (mirroring how a\n * scheduled `source.start(when)` sounds nothing before `when`).\n */\n positionAt(t: number): number {\n if (this.#paused) return this.#originPosition;\n if (this.#holdUntilOrigin && t < this.#originTime) return this.#originPosition;\n return this.#originPosition + (t - this.#originTime) * this.#rate;\n }\n\n /**\n * Inverse of {@link positionAt}. Throws RangeError while paused: no\n * reference time maps to a position when the transport is frozen — guard\n * with {@link paused} before calling. While a {@link startAt} start is\n * armed, positions before the armed origin position also throw: the\n * position holds through the pre-roll and never passes below the origin,\n * so no reference time maps to them (extrapolating backwards would return\n * a time whose {@link positionAt} is NOT the requested position).\n */\n timeAt(position: number): number {\n if (this.#paused) throw new RangeError('TransportClock is paused; no reference time maps to a position.');\n if (this.#holdUntilOrigin && position < this.#originPosition) {\n throw new RangeError(\n 'TransportClock is holding a scheduled start; no reference time maps to a position before the armed origin position.',\n );\n }\n return this.#originTime + (position - this.#originPosition) / this.#rate;\n }\n\n /**\n * Anchor at `(t, position ?? current position)` and unpause. Re-anchoring\n * while already playing is idempotent for the position at `t`.\n */\n start(t: number, position?: number): void {\n assertFiniteAnchor('start time', t);\n if (position !== undefined) assertFiniteAnchor('start position', position);\n this.#originPosition = position ?? this.positionAt(t);\n this.#originTime = t;\n this.#paused = false;\n this.#holdUntilOrigin = false;\n }\n\n /**\n * Arm a SCHEDULED start: anchor at a (typically future) reference time and\n * unpause, with the position holding at `position` until `t` arrives —\n * the clock-side mirror of a sample-accurate `play(when)`. Transitions\n * during the pre-roll keep the armed origin: {@link setRate} changes the\n * slope after `t` without collapsing the hold, {@link seekTo} re-arms the\n * held position, and {@link pause} cancels the pending start.\n */\n startAt(t: number, position: number): void {\n assertFiniteAnchor('startAt time', t);\n assertFiniteAnchor('startAt position', position);\n this.#originPosition = position;\n this.#originTime = t;\n this.#paused = false;\n this.#holdUntilOrigin = true;\n }\n\n /** Fold elapsed time into the anchor; `positionAt()` is constant afterwards. */\n pause(t: number): void {\n assertFiniteAnchor('pause time', t);\n this.#originPosition = this.positionAt(t);\n this.#originTime = t;\n this.#paused = true;\n this.#holdUntilOrigin = false;\n }\n\n /**\n * Re-anchor at a new position; preserves the paused/playing state. During\n * an armed pre-roll the scheduled origin time is kept (the pending start\n * stays pending at the new position).\n */\n seekTo(position: number, t: number): void {\n assertFiniteAnchor('seek position', position);\n assertFiniteAnchor('seek time', t);\n this.#originPosition = position;\n if (!(this.#holdUntilOrigin && t < this.#originTime)) {\n this.#originTime = t;\n }\n }\n\n /**\n * Re-anchor so the position is continuous across the rate change:\n * `originPosition = positionAt(t); originTime = t; rate = r`.\n * Throws RangeError unless `r` is finite and > 0.\n */\n setRate(r: number, t: number): void {\n if (!Number.isFinite(r) || r <= 0) {\n throw new RangeError(`TransportClock rate must be finite and > 0, got ${r}.`);\n }\n assertFiniteAnchor('setRate time', t);\n if (this.#holdUntilOrigin && t < this.#originTime) {\n // Pre-roll: the position has not started moving; only the slope after\n // the armed origin changes. (Naively re-anchoring at `t` here is the\n // BufferEngine pre-roll setRate bug this mode exists to prevent.)\n this.#rate = r;\n return;\n }\n this.#originPosition = this.positionAt(t);\n this.#originTime = t;\n this.#rate = r;\n }\n}\n\nfunction assertFiniteAnchor(name: string, value: number): void {\n if (!Number.isFinite(value)) {\n throw new RangeError(`TransportClock ${name} must be a finite number, got ${value}.`);\n }\n}\n\n/**\n * Read-only view of a {@link TransportClock} — what a transport OWNER exposes\n * to consumers (the sync bridge, views) so they can anchor against the clock\n * without being able to re-anchor it.\n */\nexport type TransportClockReader = Pick<\n TransportClock,\n 'state' | 'rate' | 'paused' | 'holding' | 'positionAt' | 'timeAt'\n>;\n\n/**\n * Monotonic non-decreasing map between a musical position axis (quarters,\n * beats — the consumer defines the unit) and media seconds. Implementations\n * should be total over all reals (extrapolate past the ends); they MAY clamp\n * negative inputs, and MAY quantize (the score family's TimeMap quantizes the\n * inverse to 1/480 quarter), so round-trips are only approximate and only on\n * `[0, duration]`.\n */\nexport interface TimelineMapping {\n positionToSeconds(position: number): number;\n secondsToPosition(seconds: number): number;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-TEM2I2NN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/events.ts
|
|
2
|
+
function isPromiseLike(value) {
|
|
3
|
+
return value != null && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
4
|
+
}
|
|
5
|
+
var EventEmitter = class {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.listeners = /* @__PURE__ */ new Map();
|
|
8
|
+
}
|
|
9
|
+
on(event, listener) {
|
|
10
|
+
let set = this.listeners.get(event);
|
|
11
|
+
if (!set) {
|
|
12
|
+
set = /* @__PURE__ */ new Set();
|
|
13
|
+
this.listeners.set(event, set);
|
|
14
|
+
}
|
|
15
|
+
set.add(listener);
|
|
16
|
+
return () => this.off(event, listener);
|
|
17
|
+
}
|
|
18
|
+
once(event, listener) {
|
|
19
|
+
let fired = false;
|
|
20
|
+
const off = this.on(event, (data) => {
|
|
21
|
+
if (fired) return;
|
|
22
|
+
fired = true;
|
|
23
|
+
off();
|
|
24
|
+
return listener(data);
|
|
25
|
+
});
|
|
26
|
+
return off;
|
|
27
|
+
}
|
|
28
|
+
off(event, listener) {
|
|
29
|
+
_optionalChain([this, 'access', _ => _.listeners, 'access', _2 => _2.get, 'call', _3 => _3(event), 'optionalAccess', _4 => _4.delete, 'call', _5 => _5(listener)]);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Delivery snapshots the subscribers present at dispatch start — the same
|
|
33
|
+
* membership semantics as {@link emitSafely}. Iterating the live set instead
|
|
34
|
+
* would deliver the in-flight event to listeners added during dispatch,
|
|
35
|
+
* making the ordinary self-rearming `once` idiom an infinite loop.
|
|
36
|
+
*/
|
|
37
|
+
emit(event, data) {
|
|
38
|
+
const set = this.listeners.get(event);
|
|
39
|
+
if (!set) return;
|
|
40
|
+
for (const l of [...set]) l(data);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Deliver an event without allowing one subscriber to prevent later
|
|
44
|
+
* subscribers from running. The ordinary {@link emit} method deliberately
|
|
45
|
+
* retains its historic exception propagation; lifecycle-sensitive owners
|
|
46
|
+
* such as playback engines opt into this boundary explicitly.
|
|
47
|
+
*
|
|
48
|
+
* Delivery snapshots the subscribers present at dispatch start. Synchronous
|
|
49
|
+
* throws and rejected promises are both reported. Errors thrown or rejected
|
|
50
|
+
* by the observer are ignored: a diagnostic hook must never become a second
|
|
51
|
+
* path out of a scheduler callback.
|
|
52
|
+
*/
|
|
53
|
+
emitSafely(event, data, onError) {
|
|
54
|
+
const set = this.listeners.get(event);
|
|
55
|
+
if (!set) return 0;
|
|
56
|
+
const snapshot = [...set];
|
|
57
|
+
const report = (error, mode) => {
|
|
58
|
+
try {
|
|
59
|
+
const observation = onError(error, mode);
|
|
60
|
+
if (isPromiseLike(observation)) {
|
|
61
|
+
void Promise.resolve(observation).catch(() => {
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
for (const listener of snapshot) {
|
|
68
|
+
try {
|
|
69
|
+
const result = listener(data);
|
|
70
|
+
if (isPromiseLike(result)) {
|
|
71
|
+
void Promise.resolve(result).catch((error) => {
|
|
72
|
+
report(error, "rejection");
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
report(error, "throw");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return snapshot.length;
|
|
80
|
+
}
|
|
81
|
+
removeAllListeners(event) {
|
|
82
|
+
if (event !== void 0) this.listeners.delete(event);
|
|
83
|
+
else this.listeners.clear();
|
|
84
|
+
}
|
|
85
|
+
/** Alias of removeAllListeners for backward compatibility. */
|
|
86
|
+
clear(event) {
|
|
87
|
+
this.removeAllListeners(event);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
exports.EventEmitter = EventEmitter;
|
|
94
|
+
//# sourceMappingURL=chunk-UMTPJ76S.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/mamingchen/GitH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A,EAAU;AAC/B,MAAA,IAAI;AACF,QAAA,MAAM,OAAA,EAAS,QAAA,CAAS,IAAI,CAAA;AAC5B,QAAA,GAAA,CAAI,aAAA,CAAc,MAAM,CAAA,EAAG;AACzB,UAAA,KAAK,OAAA,CAAQ,OAAA,CAAQ,MAAM,CAAA,CAAE,KAAA,CAAM,CAAC,KAAA,EAAA,GAAmB;AACrD,YAAA,MAAA,CAAO,KAAA,EAAO,WAAW,CAAA;AAAA,UAC3B,CAAC,CAAA;AAAA,QACH;AAAA,MACF,EAAA,MAAA,CAAS,KAAA,EAAO;AACd,QAAA,MAAA,CAAO,KAAA,EAAO,OAAO,CAAA;AAAA,MACvB;AAAA,IACF;AACA,IAAA,OAAO,QAAA,CAAS,MAAA;AAAA,EAClB;AAAA,EAEA,kBAAA,CAAmB,KAAA,EAA6B;AAI9C,IAAA,GAAA,CAAI,MAAA,IAAU,KAAA,CAAA,EAAW,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,KAAK,CAAA;AAAA,IAAA,KAC/C,IAAA,CAAK,SAAA,CAAU,KAAA,CAAM,CAAA;AAAA,EAC5B;AAAA;AAAA,EAGA,KAAA,CAAM,KAAA,EAA6B;AACjC,IAAA,IAAA,CAAK,kBAAA,CAAmB,KAAK,CAAA;AAAA,EAC/B;AACF,CAAA;ADjCA;AACA;AACE;AACF,oCAAC","file":"/Users/mamingchen/GitHub/public/WebMusic/platform/kernel/dist/chunk-UMTPJ76S.cjs","sourcesContent":[null,"// ============================================================================\n// Typed pub-sub shared by every @webscore/* and @webaudio/* package.\n// Extracted from @webscore/core (the hardened superset of the two family\n// copies); @webaudio's variant lacked emitSafely and is compatible.\n// ============================================================================\n\ntype Listener<T> = (data: T) => unknown;\n\nexport type EventListenerFailureMode = 'throw' | 'rejection';\n\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return value != null &&\n (typeof value === 'object' || typeof value === 'function') &&\n typeof (value as {then?: unknown}).then === 'function';\n}\n\n/**\n * Tiny typed pub-sub.\n * Subscribers receive a typed payload per event name.\n */\nexport class EventEmitter<TEvents extends object = Record<string, unknown>> {\n private readonly listeners = new Map<keyof TEvents, Set<Listener<unknown>>>();\n\n on<K extends keyof TEvents>(event: K, listener: Listener<TEvents[K]>): () => void {\n let set = this.listeners.get(event);\n if (!set) {\n set = new Set();\n this.listeners.set(event, set);\n }\n set.add(listener as Listener<unknown>);\n return () => this.off(event, listener);\n }\n\n once<K extends keyof TEvents>(event: K, listener: Listener<TEvents[K]>): () => void {\n let fired = false;\n const off = this.on(event, (data) => {\n // A nested dispatch can consume this subscription while an outer\n // dispatch still holds its wrapper in a subscriber snapshot.\n if (fired) return;\n fired = true;\n off();\n return listener(data);\n });\n return off;\n }\n\n off<K extends keyof TEvents>(event: K, listener: Listener<TEvents[K]>): void {\n this.listeners.get(event)?.delete(listener as Listener<unknown>);\n }\n\n /**\n * Delivery snapshots the subscribers present at dispatch start — the same\n * membership semantics as {@link emitSafely}. Iterating the live set instead\n * would deliver the in-flight event to listeners added during dispatch,\n * making the ordinary self-rearming `once` idiom an infinite loop.\n */\n emit<K extends keyof TEvents>(event: K, data: TEvents[K]): void {\n const set = this.listeners.get(event);\n if (!set) return;\n for (const l of [...set]) l(data);\n }\n\n /**\n * Deliver an event without allowing one subscriber to prevent later\n * subscribers from running. The ordinary {@link emit} method deliberately\n * retains its historic exception propagation; lifecycle-sensitive owners\n * such as playback engines opt into this boundary explicitly.\n *\n * Delivery snapshots the subscribers present at dispatch start. Synchronous\n * throws and rejected promises are both reported. Errors thrown or rejected\n * by the observer are ignored: a diagnostic hook must never become a second\n * path out of a scheduler callback.\n */\n emitSafely<K extends keyof TEvents>(\n event: K,\n data: TEvents[K],\n onError: (\n error: unknown,\n mode: EventListenerFailureMode,\n ) => void | PromiseLike<void>,\n ): number {\n const set = this.listeners.get(event);\n if (!set) return 0;\n const snapshot = [...set];\n const report = (error: unknown, mode: EventListenerFailureMode): void => {\n try {\n const observation = onError(error, mode);\n if (isPromiseLike(observation)) {\n void Promise.resolve(observation).catch(() => {});\n }\n } catch {\n // The caller selected safe delivery; preserve that guarantee even\n // when its diagnostic observer is itself faulty.\n }\n };\n for (const listener of snapshot) {\n try {\n const result = listener(data);\n if (isPromiseLike(result)) {\n void Promise.resolve(result).catch((error: unknown) => {\n report(error, 'rejection');\n });\n }\n } catch (error) {\n report(error, 'throw');\n }\n }\n return snapshot.length;\n }\n\n removeAllListeners(event?: keyof TEvents): void {\n // Tested against `undefined`, not truthiness: `keyof TEvents` admits `''`\n // and `0`, and a caller clearing one of those keys would otherwise wipe\n // every listener on the emitter instead.\n if (event !== undefined) this.listeners.delete(event);\n else this.listeners.clear();\n }\n\n /** Alias of removeAllListeners for backward compatibility. */\n clear(event?: keyof TEvents): void {\n this.removeAllListeners(event);\n }\n}\n"]}
|