Skip to content

Conversation

jpsantosbh
Copy link
Collaborator

@jpsantosbh jpsantosbh commented Jun 26, 2025

Description

Introduce @signalwire/client Package - Call Fabric SDK Refactoring

Type of change

  • Internal refactoring
  • Bug fix (bugfix - non-breaking)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

🎯 Overview

This PR introduces the new @signalwire/client package, which represents a major refactoring of the Call Fabric SDK from the existing @signalwire/js package. The new package provides a focused, cleaner API specifically for unified communication applications while maintaining backward compatibility through the original package.

🔧 Motivation

The original @signalwire/js package has grown to include multiple SDKs (Video, Chat, PubSub, and Call Fabric), leading to:

  • Increased bundle sizes for applications that only need Call Fabric functionality
  • Confusion between Room-based terminology (suited for video conferences) and Call-based terminology (better for unified communications)
  • Complex type inference and poor IDE experience with deeply nested types
  • Mixing of concerns between different SDK functionalities

📋 Key Changes

1. Package Structure

  • Created new @signalwire/client package focused exclusively on Call Fabric SDK
  • Removed Chat, PubSub, and Video SDK components from the new package
  • Maintained shared components (BaseRoomSession, RoomSessionDevice, etc.) for compatibility

2. Terminology Refactoring: Room → Call

All Fabric-prefixed classes and types have been renamed to use Call terminology:

// Before (@signalwire/js)
FabricRoomSession  CallSession
FabricRoomSessionMember  CallSessionMember
FabricRoomSessionConnection  CallSessionConnection
FabricRoomSessionContract  CallSessionContract
FabricRoomSessionEvents  CallSessionEvents

// Function renames
createFabricRoomSessionValidateProxy  createCallSessionValidateProxy
isFabricRoomSession  isCallSession

3. Type System Improvements

Type Aliasing with TypeScript Hack

Implemented a workaround to prevent TypeScript from resolving aliases back to original types:

// Prevents IDE from showing FabricMemberEntity
export type CallMemberEntity = FabricMemberEntity & {
  tshack?: undefined
}

Prettify Utility for Clean External Types

All exported types now use the Prettify<> utility for better IDE experience:

type ExternalCallMemberEntity = Prettify<CallMemberEntity>
export { ExternalCallMemberEntity as CallMemberEntity }

4. Simplified API Surface

  • Removed legacy helpers: createClient.ts, createRoomObject.ts, joinRoom.ts
  • Focused exports on Call Fabric functionality only
  • Removed advanced video features (recording, streaming workers)
  • Cleaner namespace structure without redundant paths

💔 Breaking Changes

For @signalwire/js Users

No breaking changes - the original package maintains all existing functionality and exports.

For Early @signalwire/client Adopters

  1. All Fabric* prefixed types and classes are now Call* prefixed
  2. No direct access to Video SDK components (use @signalwire/js instead)
  3. Chat and PubSub namespaces are not available

📚 Migration Guide

Migrating from @signalwire/js Fabric SDK to @signalwire/client

// Same call setup
import { SignalWire } from '@signalwire/client'
const client = await SignalWire({ token })
const call = await client.dial({ to: '...' })
call.on('member.joined', (e: CallMemberJoinedEventParams) => {})

Type Migration

// Type mappings
FabricRoomSession  CallSession
FabricRoomSessionMember  CallSessionMember
FabricMemberEntity  CallMemberEntity
FabricMemberJoinedEventParams  CallMemberJoinedEventParams
FabricMemberUpdatedEventParams  CallMemberUpdatedEventParams
FabricLayoutChangedEventParams  CallLayoutChangedEventParams

✅ Testing

  • All existing tests have been updated to use new terminology
  • Type inference tests added to ensure aliases work correctly
  • E2E tests updated for both packages
  • Backward compatibility tests for @signalwire/js

📊 Bundle Size Impact

Expected improvements for Call Fabric-only applications:

  • ~40% reduction in bundle size by excluding Video SDK components
  • ~25% reduction by excluding Chat and PubSub functionality
  • Cleaner tree-shaking with focused exports

🔮 Future Work

  • Extract common components to @signalwire/browser-common package
  • Deprecate fabric exports from @signalwire/js with migration warnings

📝 Documentation Updates

  • Update API documentation with new Call terminology
  • Create migration guide for existing Fabric SDK users
  • Update example applications
  • Add TypeScript usage examples with improved types

🔍 Review Checklist

  • All tests passing (apart from conversations API)
  • No regression in @signalwire/js functionality
  • Type exports properly aliased with tshack
  • Bundle size analysis completed
  • Migration guide reviewed

📸 Screenshots

Cursor_and_Claude_Code_—_temp-client-test


This refactoring sets the foundation for a cleaner, more maintainable SDK architecture while providing a better developer experience through improved naming conventions and type definitions.

jpsantosbh and others added 10 commits June 25, 2025 09:58
- Created new client package with version 0.0.1-alpha
- Updated package.json with correct name, description, and metadata
- Added agent mapping in sw.config.js for build system telemetry
- Added TypeScript path mapping in tsconfig.json for module resolution
- Package successfully builds and integrates with monorepo tooling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Created new e2e testing package specifically for the client SDK
- Updated all imports from '@signalwire/js' to '@signalwire/client' across 53 files
- Migrated 12 Call Fabric test files and 36 Video SDK test files
- Updated template files and CDN references to use new package
- Fixed package naming to follow monorepo conventions (@sw-internal/e2e-client)
- Ensures proper separation between JS SDK and Client SDK testing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link

changeset-bot bot commented Jun 26, 2025

🦋 Changeset detected

Latest commit: 738d498

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@signalwire/client Patch
@signalwire/webrtc Patch
@sw-internal/e2e-client Patch
@signalwire/js Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jpsantosbh jpsantosbh changed the title WIP: New Client SDK New Client SDK Jun 27, 2025
@jpsantosbh jpsantosbh marked this pull request as ready for review June 27, 2025 20:53
@LittorWired
Copy link
Contributor

@jpsantosbh looks like the build is failing

@iAmmar7
Copy link
Collaborator

iAmmar7 commented Jul 2, 2025

As requested, I have removed the changes from the JS package. @jpsantosbh

@jpsantosbh jpsantosbh requested a review from iAmmar7 July 3, 2025 12:20
jpsantosbh and others added 8 commits July 8, 2025 12:07
…ignalwire-js into joao/client_package_renamed
- Support muting/unmuting audio and video for all participants by passing memberId: "all"
- Export SetAudioFlagsParams type for microphone features support
- Update executeAction method to handle special case when memberId === 'all'

This ensures feature parity between the js and client packages for the Call Fabric SDK.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
# Conflicts:
#	.gitignore
#	internal/e2e-client/tests/callfabric/reattach.spec.ts
#	packages/client/CHANGELOG.md
#	packages/client/src/fabric/CallSession.ts
#	packages/client/src/index.ts
@jpsantosbh jpsantosbh requested a review from LittorWired July 10, 2025 11:52
"test": ""
},
"dependencies": {
"@signalwire/client": "0.0.1-alpha",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we investigate why? Shouldn't it work if the e2e-js works?


export type CallMemberUpdatedEventParams = FabricMemberUpdatedEventParams & Brand<'CallMemberUpdatedEventParams'>
export type CallMemberLeftEventParams = FabricMemberLeftEventParams & Brand<'CallMemberLeftEventParams'>
export type CallMemberTalkingEventParams = FabricMemberTalkingEventParams & Brand<'CallMemberTalkingEventParams'>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure these are all the types that we export from the CF SDK?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are the types emitted by the events, right?

callSession.on('member.talking', (params) =>

@jpsantosbh jpsantosbh requested a review from iAmmar7 July 11, 2025 13:11
@jpsantosbh jpsantosbh merged commit 92461cf into main Jul 11, 2025
30 of 61 checks passed
@jpsantosbh jpsantosbh deleted the joao/client_package_renamed branch July 11, 2025 16:51
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.

3 participants