Skip to content

add experimental core room exports - #2141

Merged
lukasIO merged 47 commits into
mainfrom
core
Oct 19, 2026
Merged

lukasIO merged 47 commits into
mainfrom
core

Conversation

@lukasIO

@lukasIO lukasIO commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Split Room into CoreRoom plus extensions. createRoom(options, [extensions]) from livekit-client/core builds a room with only the extensions an application needs; e2ee, frameMetadata and dataStreams take their options directly. Room.dispose() releases a room for good. Video publishing (camera, screen share, simulcast, SVC, backup codecs) is the video extension; receiving video stays in core. The new livekit-client/core entry (ESM only, experimental) exports CoreRoom and the extensions. simulateParticipants and the legacy chat messages are extensions too; the core entry does not offer legacy chat.

lukasIO and others added 8 commits October 8, 2026 00:37
`pnpm size:breakdown` bundles `export { Room }` with esbuild and reports the
minified bytes per feature, plus what each feature would save if it were
left out of the bundle.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… behind it

`Room` becomes `CoreRoom.with(dataStreams, rpc)`. `CoreRoom.with(...)`
returns a room class that installs the given extensions and their
dependencies in its constructor. Each extension returns the methods it adds
to the room and to the local participant, under the names the SDK uses
today. The full entry augments `CoreRoom` and `LocalParticipant` with the
extension APIs, so the full build keeps its types wherever those classes
appear.

Also adds `Room.dispose()`, and moves `import 'webrtc-adapter'` into the
main entry so a core-only bundle can leave it out.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Core keeps the data track channel in RTCEngine and the `dataTracks` map on
RemoteParticipant. The extension owns both managers, the engine event
wiring, the signal request errors and `publishDataTrack`. Core gains hooks
for participant creation and updates, the sync state and the E2EE slot.

Remote data tracks of a leaving participant now unpublish after that
participant's media tracks, not before. Both still happen before the
room emits ParticipantDisconnected to user listeners.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Core keeps the E2EE manager slot that RTCEngine and the publish path read.
The `e2ee` extension creates the manager from the room options, fills the
slot through the extension context, wires the encryption events and adds
`setE2EEEnabled`. The `frameMetadata` extension owns the receiver side
manager. The full Room now installs all five extensions.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`src/core.ts` exports `CoreRoom` and the extensions. `pnpm check:core`
bundles `CoreRoom` alone and fails if any extension module is reachable.
The entry is not in package.json exports yet.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`import { type X }` keeps a runtime import under verbatimModuleSyntax, so
SignalClient pulled data-track/types into the core bundle. The main entry
now exports the types that `Room.with` and `TrackProcessor.onPublish`
reference.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`dist/livekit-client.core.esm.mjs` is built from src/core.ts (ESM only,
not in package.json exports yet). size-limit now also measures
`{ CoreRoom }` and `{ CoreRoom, rpc }` from it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5056f99

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

This PR includes changesets to release 1 package
Name Type
livekit-client Minor

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

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 115.84 KB (+1.34% 🔺)
dist/livekit-client.umd.js 125.08 KB (+1.24% 🔺)
dist/core/core.mjs 78.69 KB (+100% 🔺)

lukasIO and others added 11 commits October 8, 2026 02:22
Camera and screen share capture, simulcast, SVC, backup codecs, codec
selection and the dynacast quality updates now live in src/room/video.
Core keeps receiving video. Two slots connect them: the publish pipeline
on LocalParticipant (`videoPublisher`) and the video track factory in
track/create.ts. The full entry registers the factory at module load so
`createLocalTracks({ video })` works before a Room exists. Video presets
are marked pure so an audio-only bundle drops them.

Core bundle: 353.3 -> 329.2 KiB minified, 96.5 -> 89.2 KiB gzip.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`src/exports.ts` is the export surface both entries share. The main entry
adds `Room` and the type augmentations; the core entry adds `CoreRoom` and
the extension objects. The core entry is built per module with dependencies
left external (dist/core/), so a consumer's bundler drops unused modules
whole; a single-file core bundle was not tree-shakeable by esbuild. The
connection checker builds its own room from CoreRoom so that the full Room
never reaches the core graph.

Also adds examples/core, a README section, and size-limit entries for the
new entry.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…nsions

`simulatedParticipants` adds `room.simulateParticipants()`; core keeps a
small `simulateConnected()` seam and `simulateScenario`. `chat` adds
`sendChatMessage` / `editChatMessage` and routes the chatMessage data
packet; the full Room installs it, the core entry does not export it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Loggers created at module scope, the default reconnect policy, the
extension symbols, the data track and serializer tags, the packet trailer
magic bytes, the facing-mode maps and the preset arrays are side-effect
free. The annotation lets bundlers drop them with the code that uses them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The resolver moves out of the class into installExtensions(): the full
Room installs every extension in its constructor, and the core entry's
createRoom() installs the list an app gives it. Dependencies install
first, an explicitly listed instance wins over a dependency's default,
and a key listed twice throws.

e2ee, frameMetadata and dataStreams take their options directly
(`e2ee({ keyProvider, worker })`); listed bare they read RoomOptions as
before, and a function is evaluated per room. CoreRoomOptions is
RoomOptions without those slices.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… types

tsc's declaration emitter wrote import("../..") for inferred types that
it could reach through the index barrel, and three source files imported
types from '../..'. Both pulled index.d.ts, with its declare module
augmentations, into every consumer of livekit-client/core, so a room
built with [rpc] typed as if every extension were installed.

Import those types from their modules, give the extension objects and
the ConnectionCheck room explicit types, and compile a consumer probe
against emitted declarations in pnpm check:core. The core example's
tsconfig no longer includes all of src.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
getOrCreateParticipant() and simulateConnected() are private on
CoreRoom again and reachable through the context, and the byte stream
opener and video publisher live in one LocalParticipantSlots object the
room hands to LocalParticipant instead of two public fields. Only
installExtensions() stays @internal on CoreRoom.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The core rollup build had declaration: false, so its stripInternal had
nothing to act on and the entry's types came from the main build. It now
emits its own declarations to dist/core/types, and package.json points
the core entry (and its downlevel copy) there. The main entry keeps its
@internal members for the packages that use them.

stripInternal removes whatever is tagged, so symbols that public
signatures name lose their tag: ExtensionContext, installExtensions,
InternalRoomOptions, the RTCEngine, PCTransport, SignalClient and
OutgoingDataStreamManager classes, getLogger, getBrowser, VideoPublisher
and LocalParticipantSlots. BaseE2EEManager tags the same members as
E2EEManager, and rpc/index.ts no longer re-exports internal helpers.
pnpm check:core type-checks the stripped declarations with skipLibCheck
off, so a dangling reference fails the gate.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lukasIO
lukasIO marked this pull request as ready for review October 8, 2026 11:42
devin-ai-integration[bot]

This comment was marked as resolved.

… rechecks disposed

frameMetadata({ worker }) only fed the receive-side manager. The engine
worker lookup, the join request capability and publishTrack read
room.options.frameMetadata, so a configured extension now fills that
slice. connect() rechecks `disposed` after it acquired the disconnect
lock, because dispose() can run while a connect waits for a disconnect
to finish.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lukasIO lukasIO changed the title [very experimental] lite room [experimental] lite room Oct 8, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

lukasIO and others added 14 commits October 15, 2026 15:20
The explicit aliases were a workaround for the barrel import in the
emitted declarations; the core declaration program is rooted at core.ts
now, so inference is safe and shorter.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
src/room/Room.ts is the file that became CoreRoom.ts, with most of its
content unchanged. With the small full Room class at the same path, git
and GitHub cannot pair the two as a rename and show a 6,000-line diff;
with the full entry's class next to index.ts and core.ts, the diff is
the ~770 lines that actually changed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Loggers, symbols, presets, lookup maps and the default reconnect policy
are created at module load. The /* @__PURE__ */ annotation lets a
bundler drop them with the module when nothing imports them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Conflicts came from code that moved into extensions:
- Room.ts -> CoreRoom.ts: subscriberAllowPause is sent with the join
  request; simulateParticipants keeps its silent tracks accountable
  through ctx.acquireEmptyAudioStreamTrack(), so a disconnect releases
  them (#2029).
- LocalParticipant.publishAdditionalCodecForTrack -> video/publisher.ts:
  the backup codec request carries the processed track's dimensions and
  per-codec layers (#2137); its tests call the publisher.
- index.ts: releaseEmptyAudioStreamTrack is exported from exports.ts.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@lukasIO
lukasIO changed the base branch from main to pure-annotations October 16, 2026 09:11
@lukasIO
lukasIO added this pull request to stack #2154 October 16, 2026 09:12
lukasIO and others added 6 commits October 16, 2026 11:26
…e build

- loglevel is CommonJS; the core build leaves it external, so the
  namespace import threw in plain Node ESM. A default import works
  everywhere, and the build now imports both built entries in Node.
- Two test files imported paths that the Room move and the named
  LocalParticipant export changed.
- A Room subclass may override an extension method: the override stays
  and the extension's copy is not installed. Only core and other
  extensions collide.
- The resolver dedupes dependencies by key, not by instance, so two
  configured instances of one extension from two dependency lists no
  longer reach the room twice.
- An app-supplied E2EE manager gets this room's listeners removed on
  dispose instead of keeping them for the life of the manager.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… spaces works

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Base automatically changed from pure-annotations to main October 17, 2026 22:17
@lukasIO lukasIO changed the title [experimental] core room exports add experimental core room exports Oct 19, 2026
@lukasIO
lukasIO merged commit 4d5e532 into main Oct 19, 2026
8 checks passed
@lukasIO
lukasIO deleted the core branch October 19, 2026 09:28
@github-actions github-actions Bot mentioned this pull request Oct 19, 2026
rafaelhutter added a commit to rafaelhutter/client-sdk-js that referenced this pull request Oct 23, 2026
Resolve conflicts with the CoreRoom split (livekit#2141): take main's Room.ts and
apply the initial-connection restart handling to CoreRoom.ts, where
handleRestarting and handleSignalRestarted now live. Keep the new tests
from both sides.
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.

2 participants