Skip to content

Add rasterLayers module: ephemeral buffer-backed raster layers#133

Draft
claude[bot] wants to merge 1 commit into
mainfrom
custom-extensions-ephemeral-raster-layers
Draft

Add rasterLayers module: ephemeral buffer-backed raster layers#133
claude[bot] wants to merge 1 commit into
mainfrom
custom-extensions-ephemeral-raster-layers

Conversation

@claude

@claude claude Bot commented Jul 6, 2026

Copy link
Copy Markdown

Requested by Kevin · Slack thread

Companion to felt/felt#20737. Adds a rasterLayers controller so extensions can emit their own ephemeral, client-only raster layers backed by a typed array buffer and update the pixels as close to realtime as possible.

Before: the SDK could only add vector (GeoJSON) ephemeral layers. There was no way to push raw pixels onto the map.

After: an extension can create a client-only raster layer from an RGBA8 ArrayBuffer and repeatedly overwrite it to animate the raster in near-realtime (heatmaps, sensor fields, decoded video frames, simulation grids).

How it works

  • New module src/modules/rasterLayers/ (schema.ts + controller.ts + types.ts + index.ts) declaring four methods: createEphemeralRasterLayer, updateEphemeralRasterLayer, setEphemeralRasterLayerCoordinates, deleteEphemeralRasterLayer.
  • Wired into modules/main/schema.ts (allModules + AllModules), modules/main/controller.ts (makeController + FeltController), and the client.ts barrel export.
  • New methodWithTransfer helper in lib/interface.ts: posts the method message with the pixel ArrayBuffer in the postMessage transfer list (zero-copy) instead of structured-cloning it. This detaches the buffer in the caller, so animation loops should allocate a fresh buffer per frame (documented on the controller).
  • Added a minor changeset.

Notes for the felt/felt side

The extension bridge is schema-gated by this package (handler.ts's AllMessagesSchema rejects unknown method types), so felt/felt cannot dispatch these methods until this change is published and its pinned @feltmaps/js-sdk-next version is bumped.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L1J3UqXizsTiiYRa2Ja4Tx


Generated by Claude Code

Adds a new `rasterLayers` controller so extensions can create client-only
raster layers backed by a typed array (RGBA8) buffer and update the pixels as
close to realtime as possible:

- createEphemeralRasterLayer / updateEphemeralRasterLayer /
  setEphemeralRasterLayerCoordinates / deleteEphemeralRasterLayer
- schema (zod message definitions) + controller + types, wired into the main
  schema/controller aggregation and the client barrel export
- methodWithTransfer helper in lib/interface so the pixel ArrayBuffer is
  transferred (zero-copy) rather than structured-cloned

Companion to felt/felt's ephemeral buffer-raster layer support.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1J3UqXizsTiiYRa2Ja4Tx
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