Skip to content

Migrates Spaces to the new @ably/pubsub-* packages - #365

Open
ttypic wants to merge 2 commits into
mainfrom
integration/v2
Open

ttypic wants to merge 2 commits into
mainfrom
integration/v2

Conversation

@ttypic

@ttypic ttypic commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Context

Based on PDR-091, new major release to support new @ably/pubsub-* packages

Description

Ably peer dependency replaced by @ably/pubsub-core, but SDK users should choose between @ably/pubsub-server and @ably/pubsub-device instead.

For example the demo depends on @ably/pubsub-device and builds its client with createClient(), so traffic is attributed to a device. Device re-exports the whole core surface, so it needs no core dependency of its own.

ttypic and others added 2 commits September 17, 2026 12:08
ably-js v3 splits the `ably` package into a shared core plus a
per-runtime client. The Spaces SDK is a library, not an end-user client,
so it takes the core: `@ably/pubsub-core` replaces `ably` as the peer
dependency, pinned to the exact canary
3.0.0-canary.20260917T1031.521a3374 because canary tags move and no
semver range will resolve to a pre-release.

Every `ably` type import becomes `@ably/pubsub-core`, and the IIFE
bundle externalises the new specifier onto the same `Ably` global, so
the CDN build keeps working unchanged.

Two v3 renames reach the test harness:

  - `Rest` is now `Http`, so the vitest manual mock takes
    `Http.PresenceMessage` for the `fromValues` helper. The mock
    directory moves to `__mocks__/@ably/pubsub-core` to match the
    scoped specifier vitest now resolves.
  - `ClientOptions.environment` is gone, replaced by `endpoint` and its
    routing policies. The integration tests and the CDN bundle test
    therefore ask for `nonprod:sandbox`, and sandbox app provisioning
    moves to sandbox.realtime.ably-nonprod.net to match, which is what
    ably-js itself now does. Without both, a sandbox key is offered to
    production and every connection fails with a 40400.

The integration tests construct their clients with `createClient` from
`@ably/pubsub-device` rather than the now-deprecated `Realtime`
constructor, since they stand in for device-side consumers; it is a dev
dependency only and never reaches the published package.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The demo and the examples are the device side of the split: browser code
running under an end user's control. They take `@ably/pubsub-device`,
whose `createClient` is the `Realtime` constructor plus a declaration of
which side the connection is on — the thing that tells Ably a connection
belongs to a device rather than to one of your own backend services. The
React hooks come from the matching `@ably/pubsub-device/react` subpath.

Spaces composes with that declaration rather than overwriting it: its
own `spaces` agent is merged into `options.agents`, leaving the
`ably-pubsub-device` entry intact.

The demo's token endpoint is the exception. It runs on Netlify, not on a
device, and declaring it a device would inflate the account's monthly
active user count, so it keeps a side-less client: `@ably/pubsub-core`
and the `Http` constructor that replaced `Rest`. `@ably/pubsub-server`
would be the natural home for it, but that package has no canary at the
version the rest of this branch pins, and mixing canary timestamps would
pull in a second copy of the core.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant