Skip to content

refactor(workspace): materializer async-compat, transport origins, and API surface cleanup#1655

Open
braden-w wants to merge 7 commits intomainfrom
refactor/workspace-materializers-and-origins
Open

refactor(workspace): materializer async-compat, transport origins, and API surface cleanup#1655
braden-w wants to merge 7 commits intomainfrom
refactor/workspace-materializers-and-origins

Conversation

@braden-w
Copy link
Copy Markdown
Member

Summary

Workspace internals cleanup across materializers, sync transport, and public API surface. No app-level behavior changes.

  • Materializer rename: createMaterializercreateMarkdownMaterializer (was ambiguous now that SQLite materializer exists)
  • SQLite materializer async-compat: Accept Awaitable<T> in materializer callbacks so consumers can use async SQLite drivers without wrapper hacks
  • Transport origins extracted: Shared SYNC_ORIGIN / BROADCAST_ORIGIN constants moved to origins.ts instead of being redefined in each sync provider
  • Dead export removed: DOCUMENTS_ORIGIN was exported but unused by any consumer
  • File rename: create-document.tscreate-documents.ts to match its plural export name
  • Barrel trimmed: Removed re-exports from workspace/index.ts that duplicated subpath exports

Why

The materializer naming was confusing after adding the SQLite materializer—both were "createMaterializer" with different signatures. The transport origins were copy-pasted across broadcast-channel and websocket providers. The barrel exports had accumulated dead re-exports that created false import paths.

Files changed

packages/workspace/ only (+ playground e2e configs that import workspace)

…ializer

With two materializers (markdown + SQLite), the generic name was ambiguous.
Updated the barrel export and both playground consumers.
… both materializers

- Add shared MaterializerExtension type (whenReady + dispose) both
  materializers satisfy
- Replace stale markdownMaterializer example with createMarkdownMaterializer
  builder pattern
- Replace 'honest note' (SQLite not exported) with full SQLite materializer
  section—it IS exported
- Fix exports table to list both materializers as public
…ble<T>

MirrorDatabase/MirrorStatement now return Awaitable<T> so both sync
drivers (bun:sqlite) and async WASM drivers (@tursodatabase/database-wasm)
satisfy the same interface. The materializer awaits every DB call—a no-op
for sync returns, natural for async. Zero adapter needed for either driver.

Also destructured ctx/config in the factory signature per project
conventions and inlined the debounceMs default.
Remove resolveSchema, quoteIdentifier, and serializeValue from the
barrel—no external consumers, and they leak implementation details.
Fix module doc to show destructured signature instead of stale ctx param.
Update README exports table to match.
Move BC_ORIGIN and SYNC_ORIGIN into extensions/sync/origins.ts as the
single source of truth for transport origin sentinels. Documents the
Symbol convention (all transports use Symbols; local edits use
non-Symbol origins) in one place so new transports know where to
register.

broadcast-channel.ts re-exports BC_ORIGIN for backward compatibility.
websocket.ts now imports both origins from origins.ts instead of
defining SYNC_ORIGIN locally and importing BC_ORIGIN from
broadcast-channel.ts.
…ch export

The file exports createDocuments (plural) but was named create-document
(singular). Every other file in workspace/ follows the convention:
create-table.ts → createTable, create-tables.ts → createTables,
create-workspace.ts → createWorkspace. Fix the only outlier.
DOCUMENTS_ORIGIN was re-exported from @epicenter/workspace but no app
code ever imported it. It remains exported from create-documents.ts
for internal test use but is no longer part of the public surface.
Can always be re-added if consumers need it.
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.

1 participant