Skip to content

Conversation

dlarocque
Copy link
Contributor

Refactor WebSocketHandler to remove separate implementations for each platform. I was able to refactor this in a way so that there are no difference in the code that is used in Node and Browser.

The tests now stub WebSocket on globalThis instead of on 'window', which allows us to stub it out on Node too! Disappointed I didn't discover this earlier. Now that we can stub the global WebSocket in Node, we don't need the 'ws' dependency for the test ws server!

@dlarocque dlarocque requested a review from a team as a code owner August 19, 2025 14:27
Copy link

changeset-bot bot commented Aug 19, 2025

⚠️ No Changeset found

Latest commit: 41d8ae0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Aug 19, 2025

Size Report 1

Affected Products

  • @firebase/ai

    TypeBase (a38b5fd)Merge (bf32ffa)Diff
    browser47.2 kB47.2 kB-21 B (-0.0%)
    main50.6 kB50.6 kB-21 B (-0.0%)
    module47.2 kB47.2 kB-21 B (-0.0%)
  • firebase

    TypeBase (a38b5fd)Merge (bf32ffa)Diff
    firebase-ai.js37.3 kB37.3 kB-13 B (-0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/zVOLOItaqD.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Aug 19, 2025

Size Analysis Report 1

Affected Products

  • @firebase/ai

    • getLiveGenerativeModel

      Size

      TypeBase (a38b5fd)Merge (bf32ffa)Diff
      size10.8 kB10.9 kB+18 B (+0.2%)
      size-with-ext-deps28.5 kB28.5 kB+16 B (+0.1%)

      Dependency

      TypeBase (a38b5fd)Merge (bf32ffa)Diff
      functions

      assignRoleToPartsAndValidateSendMessageRequest
      createWebSocketHandler
      decodeInstanceIdentifier
      formatNewContent
      formatSystemInstruction
      getLiveGenerativeModel
      registerAI

      assignRoleToPartsAndValidateSendMessageRequest
      decodeInstanceIdentifier
      formatNewContent
      formatSystemInstruction
      getLiveGenerativeModel
      registerAI

      - createWebSocketHandler

      classes

      AIError
      AIModel
      AIService
      Backend
      BrowserWebSocketHandler
      GoogleAIBackend
      LiveGenerativeModel
      LiveSession
      VertexAIBackend
      WebSocketUrl

      AIError
      AIModel
      AIService
      Backend
      GoogleAIBackend
      LiveGenerativeModel
      LiveSession
      VertexAIBackend
      WebSocketHandlerImpl
      WebSocketUrl

      + WebSocketHandlerImpl
      - BrowserWebSocketHandler

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/uYdBiuHffm.html

@dlarocque dlarocque merged commit 3d20d7b into dl/live-v1 Aug 19, 2025
43 of 45 checks passed
@dlarocque dlarocque deleted the dl/live-refactor-ws branch August 19, 2025 18:52
dlarocque added a commit that referenced this pull request Aug 19, 2025
* Live API v1

* update docs

* Docs and naming changes

* Skip problematic Google AI tests

* Fix mediaChunks errors

* Log warnings for 'close' event reasons

* Add note about support to getLiveGenerativeModel docs

* Review comments

* add license header

* docs review

* remove candidateCount

* Live Refactor WebSocket (#9212)

* refactor websocket

* remove test ws server
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