Skip to content

types(hook): add type declarations and JSDoc for musicKit integration#61

Merged
flexiondotorg merged 4 commits intomainfrom
hook
Mar 27, 2026
Merged

types(hook): add type declarations and JSDoc for musicKit integration#61
flexiondotorg merged 4 commits intomainfrom
hook

Conversation

@flexiondotorg
Copy link
Copy Markdown
Member

Summary

Add comprehensive TypeScript type declarations and JSDoc documentation for the musicKit integration, including window.__sidra interface, IPC channel types, and hook implementations. Enables type-safe communication between renderer and preload contexts.

Changes

  • Add TypeScript definitions for window.__sidra and IPC channels in src/types/hook.d.ts
  • Enhance musicKitHook with proper JSDoc type annotations and implementation details
  • Update navigationBar with JSDoc documentation for menu item structure
  • Add contract tests validating hook and channel type consistency
  • Update SPECIFICATION.md with typing guidance for extension developers

Testing

  • Contract tests verify hook function signatures match type declarations
  • JSDoc annotations provide IDE autocomplete and type checking
  • Type declarations prevent runtime errors from mismatched IPC messages

- Define SendChannel and ReceiveChannel string literal types to
  constrain IPC messaging between renderer and main process.
- Add SidraHook interface for methods exposed on window.__sidra by the
  hook script, with Promise return types for async operations.
- Add AMWrapperBridge interface for the contextBridge-exposed IPC
  bridge.
- Add SidraCommandMessage interface for the postMessage bridge contract
  between preload and hook script.
- Narrow Set<string> to Set<SendChannel> and Set<ReceiveChannel> in
  preload to enforce type-checked channel validation.

This establishes a type-checkable contract between
assets/musicKitHook.js and src/preload.ts,

Signed-off-by: Martin Wimpress <code@wimpress.io>
- Document attachToInstance function, event listeners, and message
  handler in musicKitHook
- Document createSvgElement, createButton, and factory functions in
  navigationBar
- Reference type declarations from Phase 1 (SidraHook,
  SidraCommandMessage)
- Clarify COMMANDS set and volume polling fallback behaviour

Signed-off-by: Martin Wimpress <code@wimpress.io>
Add two test suites verifying the type contract between SidraHook and
the preload at compile time. First suite checks that SidraHook method
names match the COMMANDS set; second suite verifies SendChannel and
ReceiveChannel types stay in sync with preload definitions. Enables
compile-time detection of misalignment between hook script and IPC
interface.

Signed-off-by: Martin Wimpress <code@wimpress.io>
- Add src/types/hook.d.ts to source structure file listing
- Add src/aboutWindow.ts module; remove About window from tray.ts
  description
- Correct showAboutWindow() export location to src/aboutWindow.ts
- Document type contract enforcement mechanism in IPC Event Flow section

Signed-off-by: Martin Wimpress <code@wimpress.io>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Auto-approved: This PR adds TypeScript type declarations, JSDoc documentation, and contract tests for the musicKit integration. It improves type safety without altering runtime logic.

@flexiondotorg flexiondotorg merged commit 71ec17c into main Mar 27, 2026
12 checks passed
@flexiondotorg flexiondotorg deleted the hook branch March 27, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant