@xnetjs/data-bridge
v0.0.2
Published
DataBridge abstraction for off-main-thread data access in xNet
Readme
@xnetjs/data-bridge
DataBridge abstractions for moving xNet data operations off the main thread.
Installation
pnpm add @xnetjs/data-bridgeWhat It Provides
MainThreadBridgefor direct NodeStore-backed accessWorkerBridgefor Web Worker execution via ComlinkcreateDataBridge()factory with automatic bridge selection- Shared bridge types (
DataBridge,QueryOptions,DataBridgeConfig) - Utilities for query caching, debouncing, and binary state transfer
Usage
import { createDataBridge } from '@xnetjs/data-bridge'
const bridge = await createDataBridge({
nodeStore,
config: {
authorDID,
signingKey,
dbName: 'xnet'
},
workerUrl: new URL('@xnetjs/data-bridge/worker', import.meta.url),
mode: 'auto'
})
const subscription = bridge.query(TaskSchema, {
where: { status: 'todo' },
orderBy: { createdAt: 'desc' }
})Exports
- Types:
DataBridge,QueryOptions,DataBridgeConfig,AcquiredDoc,SyncStatus - Implementations:
MainThreadBridge,WorkerBridge,NativeBridge - Factories:
createDataBridge,createMainThreadBridgeSync,createWorkerBridgeSync - Worker helpers:
isWorkerSupported,isNodeEnvironment
Testing
pnpm --filter @xnetjs/data-bridge test