clone

a deno framework for local-first web apps that open instantly, work offline and sync when users choose

feat/184-task-notice-migration
lofi / package / runtime / mod.ts
mod.ts 7.5K
1/**2 * Build local-first browser applications with durable storage, reactive tables,3 * optional Jazz sync, recoverable accounts, and an installable PWA lifecycle.4 *5 * Application code composes these APIs; storage, identity, sync, PWA, and6 * lifecycle implementations remain versioned package code.7 *8 * Start with {@link defineLofiApp} and {@link bootLofi}. Use9 * {@link LofiRuntime.store} to bind declared Jazz tables to application UI, and10 * add account backup only after managed sync is configured.11 *12 * Every mutation returns a {@link WriteHandle}: `await` it for local13 * durability (`saved`), observe `synced`/`rejected` for the store's verdict,14 * and read the reload-safe pending set through {@link getWriteLedger} or the15 * `usePendingWrites` hook. Status UI reads {@link RuntimeDiagnostics} (via16 * {@link getRuntimeDiagnostics}), the schema gate through17 * {@link getSchemaCompatState} — `data-ahead` means this device is read-only18 * until {@link applyPwaUpdate} lands a newer bundle — and install/update19 * state through {@link getPwaState}.20 *21 * Shared encrypted fields span three entry points: declaring an encrypted22 * column lives in `@nzip/lofi/schema`, group policy and key lifecycle live in23 * `@nzip/lofi/access`, and pin remediation lives here — a `peer-key-changed`24 * alert in {@link RuntimeDiagnostics.sharedFieldAlerts} is resolved with25 * {@link trustPeerKey} after out-of-band verification.26 *27 * @module28 */2930export {31 defineLofiApp,32 isLofiConfigurationError,33 type LofiAppConfig,34 LofiConfigurationError,35} from "./app.ts";36export {37 type AuthCapability,38 type AuthDependencies,39 authenticateAndDerivePrfSecret,40 authenticateDeviceCredential,41 type AuthenticateOptions,42 AuthError,43 classifyCredentialOrigin,44 type CredentialOriginReport,45 decryptAtRest,46 deriveAtRestKey,47 derivePrfSecret,48 type DeviceCredential,49 encryptAtRest,50 enrollDeviceCredential,51 type EnrollOptions,52 getAuthCapability,53 type PrfSupport,54} from "./auth.ts";55export { bootLofi } from "./boot.ts";56export {57 type BootProgress,58 type BootProgressPhase,59 type BootProgressTracker,60 type BootProgressTrackerDependencies,61 createBootProgressTracker,62 type EngineAssetReference,63 getBootProgress,64 subscribeBootProgress,65} from "./boot-progress.ts";66export {67 clearProvisionCapability,68 heldProvisionCapability,69 holdProvisionCapability,70 lockProvisionCapability,71 type ProvisionCapabilityStatus,72 provisionCapabilityStatus,73 type SealOutcome,74 sealProvisionCapability,75 unlockProvisionCapability,76} from "./provision.ts";77export {78 assertDurableBrowser,79 type DeviceCapabilityReport,80 type DurableCapabilityReport,81 durableCapabilityReport,82 DurableStorageUnsupportedError,83 isDurableStorageUnsupportedError,84 readDeviceCapabilityReport,85 requestPersistentStorage,86} from "./device-capabilities.ts";87export { type DeviceKeyStore, EnvelopeError, isEnvelopeError } from "./envelope.ts";88export {89 applyPwaUpdate,90 checkPwaUpdate,91 createPwaController,92 getPwaState,93 type InstallEnvironment,94 type InstallPromptEvent,95 type PwaController,96 pwaController,97 type PwaControllerDependencies,98 type PwaFailureCode,99 pwaFailureMessage,100 type PwaInstallState,101 type PwaState,102 type PwaUpdateState,103 type PwaWorkerState,104 requestPwaInstall,105 subscribePwaState,106} from "./pwa.ts";107export {108 type RuntimeDiagnostics,109 type SharedFieldAlert,110 type SyncOwnerDiagnostic,111} from "./diagnostics.ts";112export {113 createSchemaCompatGate,114 describeSchemaCompat,115 getSchemaCompatState,116 isSchemaCompatibilityError,117 type SchemaCompatGate,118 type SchemaCompatGateDependencies,119 SchemaCompatibilityError,120 type SchemaCompatReason,121 type SchemaCompatState,122 type SchemaCompatUpdateSurface,123 subscribeSchemaCompat,124} from "./schema-compat.ts";125export {126 createStorageForkGuard,127 describeStorageFork,128 dismissStorageFork,129 getStorageForkState,130 type StorageForkDiagnostics,131 type StorageForkDiagnosticsSurface,132 type StorageForkGuard,133 storageForkGuard,134 type StorageForkGuardDependencies,135 type StorageForkState,136 subscribeStorageFork,137} from "./storage-fork.ts";138export {139 acquireLiveQuery,140 type LiveQueryEnvironment,141 type LiveQueryLease,142 type LiveQuerySnapshot,143 type LiveQueryStore,144} from "./live-query-store.ts";145export {146 getRuntime,147 getRuntimeDiagnostics,148 getRuntimePrincipal,149 type LofiRuntime,150 recreateRuntime,151 reloadBrowserRuntime,152 runtimeRecreatedEvent,153 shutdownRuntime,154 subscribeRuntimeDiagnostics,155} from "./runtime.ts";156export {157 isRuntimeStartupError,158 reloadAfterRuntimeStartupFailure,159 RuntimeStartupError,160 type RuntimeStartupFailure,161 type RuntimeStartupFailureCode,162} from "./startup-recovery.ts";163export { describeStoreStatus, type RuntimeStoreStatus } from "./store-status.ts";164export {165 acquireTableMutations,166 type TableMutationEnvironment,167 type TableMutationLease,168 type TableMutationSnapshot,169 type TableMutationStore,170} from "./table-mutations.ts";171export {172 AccountReplacementError,173 type AccountReplacementOptions,174 confirmPhraseAccess,175 createBackupPasskey,176 createRecoverablePasskeyBackup,177 enableSyncBackup,178 enrollSyncTicket,179 type EnrollSyncTicketOptions,180 isAccountReplacementError,181 isAuthError,182 isRecoverablePasskeyError,183 isRecoveryError,184 isSyncEnrollmentError,185 type PasskeyBackupReceipt,186 readAccountSession,187 readSession,188 restoreFromPasskey,189 restoreFromRecoveryPhrase,190 revealRecoveryPhrase,191 type Session,192 type SessionSink,193 stopSyncBackup,194 SyncEnrollmentError,195 type SyncEnrollmentFailureCode,196} from "./session.ts";197export { isSyncOwnerError, SyncOwnerError } from "./sync-owner.ts";198export {199 clearDeclaredSink,200 type DataSinkDeclaration,201 DataSinkError,202 declareDataSink,203 isDataSinkError,204 parseSyncTicket,205 readDeclaredSink,206 readSinkRestoreOutcome,207 restoreDeclaredSink,208 type SinkRestoreOutcome,209 type SyncTicket,210} from "./data-sink.ts";211export { RecoveryError } from "./recovery.ts";212export { RecoverablePasskeyError, type RecoverablePasskeyErrorCode } from "./passkey-recovery.ts";213export {214 type RowOf,215 type TableHandle,216 type TableRow,217 type TableSnapshot,218 type TableStore,219 type TableStoreOptions,220 type WriteDurability,221} from "./table-store.ts";222export { settleUiMutation } from "./ui-mutation.ts";223export { classifyMutationError, type MutationErrorClass } from "./mutation-taxonomy.ts";224export {225 isWriteRejectedError,226 WriteHandle,227 WriteRejectedError,228 type WriteRejection,229 type WriteStage,230} from "./write-handle.ts";231export {232 armWriteLedger,233 dismissAllNotices,234 dismissNotice,235 getNoticeQueue,236 getWriteLedger,237 type LedgerWriteOptions,238 type LedgerWriteRequest,239 listNotices,240 type PendingWritesSnapshot,241 type PendingWriteSummary,242 type ProbeTable,243 type RowSyncStatus,244 subscribeNotices,245 WriteLedger,246 type WriteLedgerEnvironment,247} from "./write-ledger.ts";248export {249 type NoticeEnqueueInput,250 type NoticeEntry,251 NoticeQueue,252 type NoticeTone,253} from "./notice-queue.ts";254export {255 createDefaultJournalStorage,256 createMemoryJournalStorage,257 type JournalDocument,258 type JournalEffectState,259 type JournalEffectStatus,260 journalIdFor,261 type JournalStorage,262 type JournalWriteRecord,263 type JournalWriteStage,264} from "./write-journal.ts";265export type { EffectDebugEvent, EffectLogEntry, EffectTraceEntry } from "./diagnostics.ts";266export { pinnedFingerprint, trustPeerKey, verifyAndPinFingerprint } from "./shared-field-keys.ts";267export type {268 EffectContext,269 EffectHandlers,270 EffectRow,271 EffectUnit,272 MutationDescriptor,273 MutationOp,274 MutationOpKind,275} from "../schema/effects.ts";