korajs 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -17
- package/dist/chunk-WALHLVVF.js +683 -0
- package/dist/chunk-WALHLVVF.js.map +1 -0
- package/dist/index.cjs +1316 -347
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -37
- package/dist/index.d.ts +92 -37
- package/dist/index.js +687 -376
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +47 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +3 -0
- package/dist/react.d.ts +3 -0
- package/dist/react.js +24 -0
- package/dist/react.js.map +1 -0
- package/dist/svelte.cjs +71 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.cts +1 -0
- package/dist/svelte.d.ts +1 -0
- package/dist/svelte.js +48 -0
- package/dist/svelte.js.map +1 -0
- package/dist/testing.cjs +700 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +111 -0
- package/dist/testing.d.ts +111 -0
- package/dist/testing.js +13 -0
- package/dist/testing.js.map +1 -0
- package/dist/vue.cjs +57 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +1 -0
- package/dist/vue.d.ts +1 -0
- package/dist/vue.js +34 -0
- package/dist/vue.js.map +1 -0
- package/package.json +83 -7
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-app.ts","../src/adapter-resolver.ts","../src/merge-aware-sync-store.ts","../src/index.ts"],"sourcesContent":["import type { KoraEventEmitter, Operation, SchemaInput } from '@korajs/core'\nimport { buildScopeMap } from '@korajs/core'\nimport { SimpleEventEmitter } from '@korajs/core/internal'\nimport { Instrumenter } from '@korajs/devtools'\nimport { MergeEngine } from '@korajs/merge'\nimport { Store } from '@korajs/store'\nimport type { CollectionAccessor, StorageAdapter } from '@korajs/store'\nimport type { QueryBuilder } from '@korajs/store'\nimport {\n\tConnectionMonitor,\n\tReconnectionManager,\n\tSyncEngine,\n\tWebSocketTransport,\n} from '@korajs/sync'\nimport type { SyncStatusInfo } from '@korajs/sync'\nimport { createAdapter, detectAdapterType } from './adapter-resolver'\nimport { MergeAwareSyncStore } from './merge-aware-sync-store'\nimport type {\n\tKoraApp,\n\tKoraConfig,\n\tSequenceAccessor,\n\tSyncControl,\n\tTransactionProxy,\n\tTypedKoraApp,\n\tTypedKoraConfig,\n} from './types'\n\n/**\n * Creates a new Kora application instance.\n *\n * Wires together store, merge engine, event emitter, and optionally sync\n * into a single developer-facing `KoraApp` object. Collection accessors\n * (e.g. `app.todos`) are defined as properties for immediate use after `await app.ready`.\n *\n * @param config - Application configuration including schema and optional sync settings\n * @returns A KoraApp instance with reactive collections ready for use\n *\n * @example\n * ```typescript\n * const app = createApp({\n * schema: defineSchema({\n * version: 1,\n * collections: {\n * todos: {\n * fields: {\n * title: t.string(),\n * completed: t.boolean().default(false)\n * }\n * }\n * }\n * })\n * })\n *\n * await app.ready\n * const todo = await app.todos.insert({ title: 'Hello' })\n * ```\n */\n/**\n * Creates a new typed Kora application instance.\n * When the schema is created with `defineSchema()`, full type inference flows through\n * to collection accessors, providing autocomplete and type checking for all CRUD operations.\n */\nexport function createApp<const S extends SchemaInput>(config: TypedKoraConfig<S>): TypedKoraApp<S>\n/**\n * Creates a new Kora application instance (untyped fallback).\n */\nexport function createApp(config: KoraConfig): KoraApp\nexport function createApp(config: KoraConfig): KoraApp {\n\tconst emitter: KoraEventEmitter & { clear(): void } = new SimpleEventEmitter()\n\tconst mergeEngine = new MergeEngine()\n\n\tlet store: Store | null = null\n\tlet syncEngine: SyncEngine | null = null\n\tlet unsubscribeSync: (() => void) | null = null\n\tlet reconnectionManager: ReconnectionManager | null = null\n\tlet connectionMonitor: ConnectionMonitor | null = null\n\tlet instrumenter: Instrumenter | null = null\n\tlet intentionalDisconnect = false\n\tlet qualityInterval: ReturnType<typeof setInterval> | null = null\n\n\t// Wire DevTools instrumentation immediately (emitter exists synchronously)\n\tif (config.devtools) {\n\t\tinstrumenter = new Instrumenter(emitter, {\n\t\t\tbridgeEnabled: typeof globalThis !== 'undefined' && 'window' in globalThis,\n\t\t})\n\t}\n\n\t// Build the ready promise — resolves when the store is open and wired\n\tconst ready = initializeAsync(config, emitter, mergeEngine).then((result) => {\n\t\tstore = result.store\n\t\tsyncEngine = result.syncEngine\n\t\tunsubscribeSync = result.unsubscribeSync\n\n\t\t// Wire reconnection and connection quality after sync engine is ready\n\t\tif (config.sync && syncEngine) {\n\t\t\tconnectionMonitor = new ConnectionMonitor()\n\t\t\treconnectionManager = new ReconnectionManager({\n\t\t\t\tinitialDelay: config.sync.reconnectInterval,\n\t\t\t\tmaxDelay: config.sync.maxReconnectInterval,\n\t\t\t})\n\n\t\t\t// Track activity for connection quality\n\t\t\temitter.on('sync:sent', () => connectionMonitor?.recordActivity())\n\t\t\temitter.on('sync:received', () => connectionMonitor?.recordActivity())\n\t\t\temitter.on('sync:acknowledged', () => connectionMonitor?.recordActivity())\n\n\t\t\t// Emit quality on timer while connected\n\t\t\temitter.on('sync:connected', () => {\n\t\t\t\tif (qualityInterval !== null) clearInterval(qualityInterval)\n\t\t\t\tqualityInterval = setInterval(() => {\n\t\t\t\t\tif (connectionMonitor) {\n\t\t\t\t\t\temitter.emit({ type: 'connection:quality', quality: connectionMonitor.getQuality() })\n\t\t\t\t\t}\n\t\t\t\t}, 5000)\n\t\t\t})\n\n\t\t\t// Reset monitor and clear timer on disconnect\n\t\t\temitter.on('sync:disconnected', () => {\n\t\t\t\tconnectionMonitor?.reset()\n\t\t\t\tif (qualityInterval !== null) {\n\t\t\t\t\tclearInterval(qualityInterval)\n\t\t\t\t\tqualityInterval = null\n\t\t\t\t}\n\t\t\t})\n\n\t\t\t// Auto-reconnect on unexpected disconnect\n\t\t\tif (config.sync.autoReconnect !== false) {\n\t\t\t\tconst engine = syncEngine\n\t\t\t\temitter.on('sync:disconnected', () => {\n\t\t\t\t\tif (intentionalDisconnect) return\n\t\t\t\t\t// Ignore cascading disconnect events from failed reconnection attempts.\n\t\t\t\t\t// The reconnection manager is already retrying — don't restart it.\n\t\t\t\t\tif (reconnectionManager?.isRunning()) return\n\n\t\t\t\t\tengine.setReconnecting(true)\n\t\t\t\t\treconnectionManager?.stop()\n\t\t\t\t\treconnectionManager\n\t\t\t\t\t\t?.start(async () => {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait engine.start()\n\t\t\t\t\t\t\t\tengine.setReconnecting(false)\n\t\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.then(() => {\n\t\t\t\t\t\t\t// If reconnection exhausted max attempts without success, clear flag\n\t\t\t\t\t\t\tengine.setReconnecting(false)\n\t\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t})\n\n\t// Build sync control\n\tconst syncControl: SyncControl | null = config.sync\n\t\t? {\n\t\t\t\tasync connect(): Promise<void> {\n\t\t\t\t\tawait ready\n\t\t\t\t\tif (syncEngine) {\n\t\t\t\t\t\tintentionalDisconnect = false\n\t\t\t\t\t\treconnectionManager?.stop()\n\t\t\t\t\t\treconnectionManager?.reset()\n\t\t\t\t\t\tawait syncEngine.start()\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tasync disconnect(): Promise<void> {\n\t\t\t\t\tawait ready\n\t\t\t\t\tif (syncEngine) {\n\t\t\t\t\t\tintentionalDisconnect = true\n\t\t\t\t\t\treconnectionManager?.stop()\n\t\t\t\t\t\tawait syncEngine.stop()\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tgetStatus(): SyncStatusInfo {\n\t\t\t\t\tif (syncEngine) {\n\t\t\t\t\t\treturn syncEngine.getStatus()\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstatus: 'offline',\n\t\t\t\t\t\tpendingOperations: 0,\n\t\t\t\t\t\tlastSyncedAt: null,\n\t\t\t\t\t\tlastSuccessfulPush: null,\n\t\t\t\t\t\tlastSuccessfulPull: null,\n\t\t\t\t\t\tconflicts: 0,\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tasync retryNow(): Promise<void> {\n\t\t\t\t\tawait ready\n\t\t\t\t\tif (syncEngine) {\n\t\t\t\t\t\tawait syncEngine.retryNow()\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\texportDiagnostics() {\n\t\t\t\t\tif (syncEngine) {\n\t\t\t\t\t\treturn syncEngine.exportDiagnostics()\n\t\t\t\t\t}\n\t\t\t\t\treturn {\n\t\t\t\t\t\tstate: 'disconnected' as const,\n\t\t\t\t\t\tstatus: {\n\t\t\t\t\t\t\tstatus: 'offline' as const,\n\t\t\t\t\t\t\tpendingOperations: 0,\n\t\t\t\t\t\t\tlastSyncedAt: null,\n\t\t\t\t\t\t\tlastSuccessfulPush: null,\n\t\t\t\t\t\t\tlastSuccessfulPull: null,\n\t\t\t\t\t\t\tconflicts: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnodeId: '',\n\t\t\t\t\t\turl: config.sync?.url ?? '',\n\t\t\t\t\t\tschemaVersion: config.schema.version,\n\t\t\t\t\t\tlastSyncedAt: null,\n\t\t\t\t\t\tlastSuccessfulPush: null,\n\t\t\t\t\t\tlastSuccessfulPull: null,\n\t\t\t\t\t\tconflicts: 0,\n\t\t\t\t\t\tpendingOperations: 0,\n\t\t\t\t\t\thasInFlightBatch: false,\n\t\t\t\t\t\treconnecting: false,\n\t\t\t\t\t\ttimestamp: Date.now(),\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t}\n\t\t: null\n\n\t// Shared transaction executor for both transaction() and mutation()\n\tasync function executeTransaction(\n\t\tfn: (tx: TransactionProxy) => Promise<void>,\n\t\tmutationName?: string,\n\t): Promise<Operation[]> {\n\t\tawait ready\n\t\tif (!store) {\n\t\t\tthrow new Error('Store not initialized. Await app.ready before using transactions.')\n\t\t}\n\t\tconst txContext = store.createTransaction()\n\t\tif (mutationName !== undefined) {\n\t\t\ttxContext.setMutationName(mutationName)\n\t\t}\n\t\tconst collectionNames = Object.keys(config.schema.collections)\n\n\t\t// Build proxy with collection accessors as direct properties\n\t\tconst proxy: TransactionProxy = {} as TransactionProxy\n\t\tfor (const name of collectionNames) {\n\t\t\tObject.defineProperty(proxy, name, {\n\t\t\t\tget() {\n\t\t\t\t\treturn txContext.collection(name)\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: false,\n\t\t\t})\n\t\t}\n\n\t\ttry {\n\t\t\tawait fn(proxy)\n\t\t\tconst { operations } = await txContext.commit()\n\n\t\t\t// Notify subscriptions and emit events after commit\n\t\t\tfor (const op of operations) {\n\t\t\t\tstore.getSubscriptionManager().notify(op.collection, op)\n\t\t\t\temitter.emit({ type: 'operation:created', operation: op })\n\t\t\t}\n\n\t\t\treturn operations\n\t\t} catch (error) {\n\t\t\ttxContext.rollback()\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Build sequences accessor (delegates to SequenceManager after ready)\n\tconst sequences: SequenceAccessor = {\n\t\tasync next(name, config) {\n\t\t\tawait ready\n\t\t\tif (!store) throw new Error('Store not initialized. Await app.ready before using sequences.')\n\t\t\treturn store.getSequenceManager().next(name, config)\n\t\t},\n\t\tasync current(name, config) {\n\t\t\tawait ready\n\t\t\tif (!store) throw new Error('Store not initialized. Await app.ready before using sequences.')\n\t\t\treturn store.getSequenceManager().current(name, config)\n\t\t},\n\t\tasync reset(name, config) {\n\t\t\tawait ready\n\t\t\tif (!store) throw new Error('Store not initialized. Await app.ready before using sequences.')\n\t\t\treturn store.getSequenceManager().reset(name, config)\n\t\t},\n\t}\n\n\t// Build the KoraApp object\n\tconst app: KoraApp = {\n\t\tready,\n\t\tevents: emitter,\n\t\tsync: syncControl,\n\t\tsequences,\n\t\tgetStore(): Store {\n\t\t\tif (!store) {\n\t\t\t\tthrow new Error('Store not initialized. Await app.ready before accessing the store.')\n\t\t\t}\n\t\t\treturn store\n\t\t},\n\t\tgetSyncEngine(): SyncEngine | null {\n\t\t\treturn syncEngine\n\t\t},\n\t\tasync transaction(fn: (tx: TransactionProxy) => Promise<void>): Promise<Operation[]> {\n\t\t\treturn executeTransaction(fn)\n\t\t},\n\t\tasync mutation(\n\t\t\tname: string,\n\t\t\tfn: (tx: TransactionProxy) => Promise<void>,\n\t\t): Promise<Operation[]> {\n\t\t\treturn executeTransaction(fn, name)\n\t\t},\n\t\tasync close(): Promise<void> {\n\t\t\tawait ready\n\t\t\tintentionalDisconnect = true\n\t\t\tif (qualityInterval !== null) {\n\t\t\t\tclearInterval(qualityInterval)\n\t\t\t\tqualityInterval = null\n\t\t\t}\n\t\t\treconnectionManager?.stop()\n\t\t\tif (instrumenter) {\n\t\t\t\tinstrumenter.destroy()\n\t\t\t\tinstrumenter = null\n\t\t\t}\n\t\t\tif (unsubscribeSync) {\n\t\t\t\tunsubscribeSync()\n\t\t\t\tunsubscribeSync = null\n\t\t\t}\n\t\t\tif (syncEngine) {\n\t\t\t\tawait syncEngine.stop()\n\t\t\t\tsyncEngine = null\n\t\t\t}\n\t\t\tif (store) {\n\t\t\t\tawait store.close()\n\t\t\t\tstore = null\n\t\t\t}\n\t\t\temitter.clear()\n\t\t},\n\t}\n\n\t// Define collection accessors via Object.defineProperty.\n\t// Before ready resolves, query methods return empty results.\n\tfor (const collectionName of Object.keys(config.schema.collections)) {\n\t\tObject.defineProperty(app, collectionName, {\n\t\t\tget(): CollectionAccessor {\n\t\t\t\treturn createCollectionAccessor(collectionName, () => store)\n\t\t\t},\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t})\n\t}\n\n\treturn app\n}\n\n/**\n * Asynchronous initialization: create adapter, open store, wire sync.\n */\nasync function initializeAsync(\n\tconfig: KoraConfig,\n\temitter: KoraEventEmitter,\n\tmergeEngine: MergeEngine,\n): Promise<{\n\tstore: Store\n\tsyncEngine: SyncEngine | null\n\tunsubscribeSync: (() => void) | null\n}> {\n\t// Resolve adapter\n\tconst adapterType = config.store?.adapter ?? detectAdapterType()\n\tconst dbName = config.store?.name ?? 'kora-db'\n\tconst adapter: StorageAdapter = await createAdapter(adapterType, dbName, config.store?.workerUrl)\n\n\t// Create and open the store\n\tconst store = new Store({\n\t\tschema: config.schema,\n\t\tadapter,\n\t\temitter,\n\t})\n\tawait store.open()\n\n\t// Wire sync if configured\n\tlet syncEngine: SyncEngine | null = null\n\tlet unsubscribeSync: (() => void) | null = null\n\n\tif (config.sync) {\n\t\tconst transport = new WebSocketTransport()\n\t\tconst mergeAwareStore = new MergeAwareSyncStore(store, mergeEngine, emitter)\n\n\t\t// Build scope map from schema scope declarations + flat scope values\n\t\tconst scopeMap = config.sync.scope ? buildScopeMap(config.schema, config.sync.scope) : undefined\n\n\t\tsyncEngine = new SyncEngine({\n\t\t\ttransport,\n\t\t\tstore: mergeAwareStore,\n\t\t\tconfig: {\n\t\t\t\turl: config.sync.url,\n\t\t\t\ttransport: config.sync.transport,\n\t\t\t\tauth: config.sync.auth,\n\t\t\t\tbatchSize: config.sync.batchSize,\n\t\t\t\tschemaVersion: config.sync.schemaVersion ?? config.schema.version,\n\t\t\t\tscopeMap,\n\t\t\t},\n\t\t\temitter,\n\t\t})\n\n\t\t// Wire local mutations → sync outbound queue\n\t\tunsubscribeSync = emitter.on('operation:created', (event) => {\n\t\t\tif (syncEngine) {\n\t\t\t\tsyncEngine.pushOperation(event.operation)\n\t\t\t}\n\t\t})\n\t}\n\n\treturn { store, syncEngine, unsubscribeSync }\n}\n\nfunction createCollectionAccessor(\n\tcollectionName: string,\n\tgetStore: () => Store | null,\n): CollectionAccessor {\n\treturn {\n\t\tasync insert(data: Record<string, unknown>) {\n\t\t\tconst currentStore = getStore()\n\t\t\tif (!currentStore) {\n\t\t\t\tthrow new Error(`Cannot mutate collection \"${collectionName}\" before app.ready resolves.`)\n\t\t\t}\n\t\t\treturn currentStore.collection(collectionName).insert(data)\n\t\t},\n\t\tasync findById(id: string) {\n\t\t\tconst currentStore = getStore()\n\t\t\tif (!currentStore) return null\n\t\t\treturn currentStore.collection(collectionName).findById(id)\n\t\t},\n\t\tasync update(id: string, data: Record<string, unknown>) {\n\t\t\tconst currentStore = getStore()\n\t\t\tif (!currentStore) {\n\t\t\t\tthrow new Error(`Cannot mutate collection \"${collectionName}\" before app.ready resolves.`)\n\t\t\t}\n\t\t\treturn currentStore.collection(collectionName).update(id, data)\n\t\t},\n\t\tasync delete(id: string) {\n\t\t\tconst currentStore = getStore()\n\t\t\tif (!currentStore) {\n\t\t\t\tthrow new Error(`Cannot mutate collection \"${collectionName}\" before app.ready resolves.`)\n\t\t\t}\n\t\t\treturn currentStore.collection(collectionName).delete(id)\n\t\t},\n\t\twhere(conditions: Record<string, unknown>) {\n\t\t\tconst currentStore = getStore()\n\t\t\tif (!currentStore) {\n\t\t\t\treturn createPendingQueryBuilder(conditions)\n\t\t\t}\n\t\t\treturn currentStore.collection(collectionName).where(conditions)\n\t\t},\n\t}\n}\n\nfunction createPendingQueryBuilder(initialWhere: Record<string, unknown>): QueryBuilder {\n\tconst descriptor = {\n\t\tcollection: '__pending__',\n\t\twhere: { ...initialWhere },\n\t\torderBy: [] as Array<{ field: string; direction: 'asc' | 'desc' }>,\n\t\tlimit: undefined as number | undefined,\n\t\toffset: undefined as number | undefined,\n\t}\n\n\tconst builder = {\n\t\twhere(conditions: Record<string, unknown>) {\n\t\t\tdescriptor.where = { ...descriptor.where, ...conditions }\n\t\t\treturn this\n\t\t},\n\t\torderBy(field: string, direction: 'asc' | 'desc' = 'asc') {\n\t\t\tdescriptor.orderBy.push({ field, direction })\n\t\t\treturn this\n\t\t},\n\t\tlimit(n: number) {\n\t\t\tdescriptor.limit = n\n\t\t\treturn this\n\t\t},\n\t\toffset(n: number) {\n\t\t\tdescriptor.offset = n\n\t\t\treturn this\n\t\t},\n\t\tasync exec() {\n\t\t\treturn []\n\t\t},\n\t\tasync count() {\n\t\t\treturn 0\n\t\t},\n\t\tsubscribe(callback: (results: Array<Record<string, unknown>>) => void) {\n\t\t\tvoid callback([])\n\t\t\treturn () => {}\n\t\t},\n\t\tgetDescriptor() {\n\t\t\treturn { ...descriptor, where: { ...descriptor.where }, orderBy: [...descriptor.orderBy] }\n\t\t},\n\t}\n\n\treturn builder as unknown as QueryBuilder\n}\n","import type { StorageAdapter } from '@korajs/store'\nimport type { AdapterType } from './types'\n\n/**\n * Detect the best storage adapter for the current environment.\n *\n * - Tauri app: 'tauri-sqlite' (native SQLite via Tauri plugin)\n * - Node.js: 'better-sqlite3'\n * - Browser with OPFS: 'sqlite-wasm'\n * - Browser without OPFS: 'indexeddb'\n */\nexport function detectAdapterType(): AdapterType {\n\t// Tauri environment — detected via __TAURI_INTERNALS__ injected by the Tauri runtime\n\tif (\n\t\ttypeof globalThis !== 'undefined' &&\n\t\ttypeof (globalThis as Record<string, unknown>).__TAURI_INTERNALS__ !== 'undefined'\n\t) {\n\t\treturn 'tauri-sqlite'\n\t}\n\n\t// Node.js environment\n\tif (typeof process !== 'undefined' && process.versions?.node) {\n\t\treturn 'better-sqlite3'\n\t}\n\n\t// Browser environment\n\tif (typeof globalThis.navigator !== 'undefined') {\n\t\t// Check for OPFS support (FileSystemHandle indicates OPFS availability)\n\t\tif (typeof (globalThis as Record<string, unknown>).FileSystemHandle !== 'undefined') {\n\t\t\treturn 'sqlite-wasm'\n\t\t}\n\t\treturn 'indexeddb'\n\t}\n\n\t// Default fallback (e.g., Deno, Bun, or other runtimes)\n\treturn 'better-sqlite3'\n}\n\n/**\n * Create a StorageAdapter for the given adapter type.\n * Uses dynamic imports so unused adapters are not bundled.\n *\n * @param type - The adapter type to create\n * @param dbName - Database name (used by all adapters)\n * @returns A configured StorageAdapter instance\n */\nexport async function createAdapter(\n\ttype: AdapterType,\n\tdbName: string,\n\tworkerUrl?: string | URL,\n): Promise<StorageAdapter> {\n\tswitch (type) {\n\t\tcase 'tauri-sqlite': {\n\t\t\t// @korajs/tauri is only installed in Tauri projects (optional peer dep).\n\t\t\t// This code path only runs when __TAURI_INTERNALS__ is detected.\n\t\t\t// Using @vite-ignore so Vite doesn't statically analyze this import —\n\t\t\t// it will still resolve it at runtime through Vite's dev server.\n\t\t\tconst { TauriSqliteAdapter } = await import(/* @vite-ignore */ '@korajs/tauri')\n\t\t\treturn new TauriSqliteAdapter({ path: `${dbName}.db` })\n\t\t}\n\t\tcase 'better-sqlite3': {\n\t\t\tconst { BetterSqlite3Adapter } = await import(\n\t\t\t\t/* @vite-ignore */ '@korajs/store/better-sqlite3'\n\t\t\t)\n\t\t\treturn new BetterSqlite3Adapter(dbName)\n\t\t}\n\t\tcase 'sqlite-wasm': {\n\t\t\tconst { SqliteWasmAdapter } = await import('@korajs/store/sqlite-wasm')\n\t\t\treturn new SqliteWasmAdapter({ dbName, workerUrl })\n\t\t}\n\t\tcase 'indexeddb': {\n\t\t\tconst { IndexedDbAdapter } = await import('@korajs/store/indexeddb')\n\t\t\treturn new IndexedDbAdapter({ dbName, workerUrl })\n\t\t}\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = type\n\t\t\tthrow new Error(`Unknown adapter type: ${_exhaustive}`)\n\t\t}\n\t}\n}\n","import type { KoraEventEmitter, Operation, VersionVector } from '@korajs/core'\nimport type { MergeEngine, MergeInput } from '@korajs/merge'\nimport type { Store } from '@korajs/store'\nimport type { ApplyResult, SyncStore } from '@korajs/sync'\n\n/**\n * Wraps a Store to interpose merge resolution before applying remote operations.\n *\n * For inserts and deletes, delegates directly to the underlying Store.\n * For updates, checks whether the remote operation's previousData conflicts\n * with the current local state. If so, runs MergeEngine to resolve and\n * applies the merged result instead.\n *\n * This keeps MergeEngine integration out of Store and SyncEngine internals.\n */\nexport class MergeAwareSyncStore implements SyncStore {\n\tconstructor(\n\t\tprivate readonly store: Store,\n\t\tprivate readonly mergeEngine: MergeEngine,\n\t\tprivate readonly emitter: KoraEventEmitter | null,\n\t) {}\n\n\tgetVersionVector(): VersionVector {\n\t\treturn this.store.getVersionVector()\n\t}\n\n\tgetNodeId(): string {\n\t\treturn this.store.getNodeId()\n\t}\n\n\tasync getOperationRange(nodeId: string, fromSeq: number, toSeq: number): Promise<Operation[]> {\n\t\treturn this.store.getOperationRange(nodeId, fromSeq, toSeq)\n\t}\n\n\tasync applyRemoteOperation(op: Operation): Promise<ApplyResult> {\n\t\t// Only intercept updates that have previousData (needed for 3-way merge)\n\t\tif (op.type !== 'update' || !op.data || !op.previousData) {\n\t\t\treturn this.store.applyRemoteOperation(op)\n\t\t}\n\n\t\t// Look up current local record to detect conflicts\n\t\tconst schema = this.store.getSchema()\n\t\tconst collectionDef = schema.collections[op.collection]\n\t\tif (!collectionDef) {\n\t\t\treturn this.store.applyRemoteOperation(op)\n\t\t}\n\n\t\tconst accessor = this.store.collection(op.collection)\n\t\tconst currentRecord = await accessor.findById(op.recordId)\n\n\t\t// If record doesn't exist locally, delegate directly\n\t\tif (!currentRecord) {\n\t\t\treturn this.store.applyRemoteOperation(op)\n\t\t}\n\n\t\t// Check for conflicts: do any of the remote op's changed fields differ\n\t\t// from what the remote op expected them to be (previousData)?\n\t\tlet hasConflict = false\n\t\tfor (const field of Object.keys(op.data)) {\n\t\t\tconst expectedBase = op.previousData[field]\n\t\t\tconst currentLocal = currentRecord[field]\n\n\t\t\t// If the local state doesn't match what the remote expected,\n\t\t\t// it means the local side also changed this field — conflict.\n\t\t\tif (!deepEqual(expectedBase, currentLocal)) {\n\t\t\t\thasConflict = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// No conflict: safe to apply directly\n\t\tif (!hasConflict) {\n\t\t\treturn this.store.applyRemoteOperation(op)\n\t\t}\n\n\t\t// Conflict detected — run merge engine\n\t\t// Build a synthetic \"local operation\" representing the current local state changes\n\t\t// relative to the same base the remote operation used.\n\t\tthis.emitter?.emit({\n\t\t\ttype: 'merge:started',\n\t\t\toperationA: op,\n\t\t\toperationB: op,\n\t\t})\n\n\t\tconst baseState: Record<string, unknown> = { ...op.previousData }\n\t\tconst localOp: Operation = {\n\t\t\t...op,\n\t\t\t// The \"local\" operation's data is the diff between base and current local state\n\t\t\tdata: buildLocalDiff(op.previousData, currentRecord, Object.keys(op.data)),\n\t\t\tpreviousData: op.previousData,\n\t\t\tnodeId: this.store.getNodeId(),\n\t\t}\n\n\t\tconst input: MergeInput = {\n\t\t\tlocal: localOp,\n\t\t\tremote: op,\n\t\t\tbaseState,\n\t\t\tcollectionDef,\n\t\t}\n\n\t\tconst result = this.mergeEngine.mergeFields(input)\n\n\t\t// Emit merge traces\n\t\tfor (const trace of result.traces) {\n\t\t\tthis.emitter?.emit({ type: 'merge:conflict', trace })\n\t\t}\n\t\tconst firstTrace = result.traces[0]\n\t\tif (firstTrace) {\n\t\t\tthis.emitter?.emit({ type: 'merge:completed', trace: firstTrace })\n\t\t}\n\n\t\t// Create a modified operation with the merged data to apply\n\t\tconst mergedOp: Operation = {\n\t\t\t...op,\n\t\t\tdata: result.mergedData,\n\t\t}\n\n\t\treturn this.store.applyRemoteOperation(mergedOp)\n\t}\n}\n\n/**\n * Build the local diff: for each field the remote op changed,\n * extract the current local value (which may differ from both base and remote).\n */\nfunction buildLocalDiff(\n\tbaseState: Record<string, unknown>,\n\tcurrentRecord: Record<string, unknown>,\n\tfields: string[],\n): Record<string, unknown> {\n\tconst diff: Record<string, unknown> = {}\n\tfor (const field of fields) {\n\t\tdiff[field] = currentRecord[field]\n\t}\n\treturn diff\n}\n\n/**\n * Simple deep equality check for comparing field values.\n * Handles primitives, arrays, and plain objects.\n */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n\tif (a === b) return true\n\tif (a === null || b === null) return false\n\tif (a === undefined || b === undefined) return false\n\tif (typeof a !== typeof b) return false\n\n\tif (Array.isArray(a) && Array.isArray(b)) {\n\t\tif (a.length !== b.length) return false\n\t\treturn a.every((val, i) => deepEqual(val, b[i]))\n\t}\n\n\tif (typeof a === 'object' && typeof b === 'object') {\n\t\tconst keysA = Object.keys(a as Record<string, unknown>)\n\t\tconst keysB = Object.keys(b as Record<string, unknown>)\n\t\tif (keysA.length !== keysB.length) return false\n\t\treturn keysA.every((key) =>\n\t\t\tdeepEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key]),\n\t\t)\n\t}\n\n\treturn false\n}\n","// kora — meta-package re-exporting core, store, merge, sync\n// This is the primary entry point for `import { createApp, defineSchema, t } from 'korajs'`\n\n// === createApp factory ===\nexport { createApp } from './create-app'\n\n// === App types ===\nexport type {\n\tAdapterType,\n\tKoraApp,\n\tKoraConfig,\n\tStoreOptions,\n\tSyncControl,\n\tSyncOptions,\n\tSequenceAccessor,\n\tTransactionCollectionProxy,\n\tTransactionProxy,\n\tTypedCollectionAccessor,\n\tTypedKoraApp,\n\tTypedKoraConfig,\n} from './types'\n\n// === @korajs/core re-exports ===\nexport { defineSchema, migrate, t } from '@korajs/core'\nexport { HybridLogicalClock } from '@korajs/core'\nexport { generateUUIDv7 } from '@korajs/core'\nexport { createOperation } from '@korajs/core'\nexport { KoraError } from '@korajs/core'\nexport { op } from '@korajs/core'\nexport type {\n\tAtomicOp,\n\tAtomicOpType,\n\tCollectionDefinition,\n\tConnectionQuality,\n\tConstraint,\n\tFieldDescriptor,\n\tFieldKindToType,\n\tHLCTimestamp,\n\tInferFieldType,\n\tInferInsertInput,\n\tInferRecord,\n\tInferUpdateInput,\n\tKoraEvent,\n\tKoraEventEmitter,\n\tKoraEventListener,\n\tKoraEventType,\n\tMergeStrategy,\n\tMergeTrace,\n\tMigrationDefinition,\n\tMigrationStep,\n\tOperation,\n\tSchemaDefinition,\n\tSchemaInput,\n\tSequenceConfig,\n\tTypedSchemaDefinition,\n\tVersionVector,\n} from '@korajs/core'\n\n// === @korajs/store re-exports ===\nexport { SequenceManager, Store } from '@korajs/store'\nexport { TransactionContext } from '@korajs/store'\nexport type {\n\tCollectionAccessor,\n\tCollectionRecord,\n\tStorageAdapter,\n\tStoreConfig,\n\tTransactionCollectionAccessor,\n\tTransactionContextConfig,\n} from '@korajs/store'\n\n// === @korajs/merge re-exports ===\nexport { MergeEngine } from '@korajs/merge'\nexport type { MergeInput, MergeResult } from '@korajs/merge'\n\n// === @korajs/sync re-exports ===\nexport { SyncEngine, WebSocketTransport } from '@korajs/sync'\nexport type {\n\tSyncConfig,\n\tSyncDiagnostics,\n\tSyncState,\n\tSyncStatus,\n\tSyncStatusInfo,\n\tSyncStore,\n} from '@korajs/sync'\n"],"mappings":";AACA,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AAGtB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;;;ACFA,SAAS,oBAAiC;AAEhD,MACC,OAAO,eAAe,eACtB,OAAQ,WAAuC,wBAAwB,aACtE;AACD,WAAO;AAAA,EACR;AAGA,MAAI,OAAO,YAAY,eAAe,QAAQ,UAAU,MAAM;AAC7D,WAAO;AAAA,EACR;AAGA,MAAI,OAAO,WAAW,cAAc,aAAa;AAEhD,QAAI,OAAQ,WAAuC,qBAAqB,aAAa;AACpF,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR;AAGA,SAAO;AACR;AAUA,eAAsB,cACrB,MACA,QACA,WAC0B;AAC1B,UAAQ,MAAM;AAAA,IACb,KAAK,gBAAgB;AAKpB,YAAM,EAAE,mBAAmB,IAAI,MAAM;AAAA;AAAA,QAA0B;AAAA,MAAe;AAC9E,aAAO,IAAI,mBAAmB,EAAE,MAAM,GAAG,MAAM,MAAM,CAAC;AAAA,IACvD;AAAA,IACA,KAAK,kBAAkB;AACtB,YAAM,EAAE,qBAAqB,IAAI,MAAM;AAAA;AAAA,QACnB;AAAA,MACpB;AACA,aAAO,IAAI,qBAAqB,MAAM;AAAA,IACvC;AAAA,IACA,KAAK,eAAe;AACnB,YAAM,EAAE,kBAAkB,IAAI,MAAM,OAAO,2BAA2B;AACtE,aAAO,IAAI,kBA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,IACf;AAAA,IACA,gBAAgB;AACf,aAAO,EAAE,GAAG,YAAY,OAAO,EAAE,GAAG,WAAW,MAAM,GAAG,SAAS,CAAC,GAAG,WAAW,OAAO,EAAE;AAAA,IAC1F;AAAA,EACD;AAEA,SAAO;AACR;;;AG3dA,SAAS,cAAc,SAAS,SAAS;AACzC,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AA+BnB,SAAS,iBAAiB,SAAAC,cAAa;AACvC,SAAS,0BAA0B;AAWnC,SAAS,eAAAC,oBAAmB;AAI5B,SAAS,cAAAC,aAAY,sBAAAC,2BAA0B;","names":["op","op","config","Store","MergeEngine","SyncEngine","WebSocketTransport"]}
|
|
1
|
+
{"version":3,"sources":["../src/create-app.ts","../src/collection-accessor.ts","../src/initialize-app.ts","../src/adapter-resolver.ts","../src/audit-bridge.ts","../src/create-sync-transport.ts","../src/sync-query-bridge.ts","../src/sequences-accessor.ts","../src/setup-devtools.ts","../src/sync-control.ts","../src/auth-sync-coordinator.ts","../src/sync-status-bridge.ts","../src/sync-lifecycle.ts","../src/transaction-executor.ts","../src/validate-config.ts","../src/wire-sync-event-forwarding.ts","../src/index.ts"],"sourcesContent":["import type { SchemaInput } from '@korajs/core'\nimport { SimpleEventEmitter } from '@korajs/core/internal'\nimport { MergeEngine } from '@korajs/merge'\nimport type { Store } from '@korajs/store'\nimport { QueryStoreCache } from '@korajs/store'\nimport type { SyncEngine } from '@korajs/sync'\nimport { createCollectionAccessor } from './collection-accessor'\nimport { initializeApp } from './initialize-app'\nimport { createSequencesAccessor } from './sequences-accessor'\nimport { setupDevtools } from './setup-devtools'\nimport { createSyncControl } from './sync-control'\nimport { type SyncRuntimeState, teardownSyncLifecycle, wireSyncLifecycleAfterReady } from './sync-lifecycle'\nimport { createTransactionExecutor } from './transaction-executor'\nimport type { KoraApp, KoraConfig, TypedKoraApp, TypedKoraConfig } from './types'\nimport { validateCreateAppConfig } from './validate-config'\nimport { wireSyncEventForwarding } from './wire-sync-event-forwarding'\n\n/**\n * Creates a new Kora application instance.\n *\n * Wires together store, merge engine, event emitter, and optionally sync\n * into a single developer-facing `KoraApp` object. Collection accessors\n * (e.g. `app.todos`) are defined as properties for immediate use after `await app.ready`.\n */\nexport function createApp<const S extends SchemaInput>(config: TypedKoraConfig<S>): TypedKoraApp<S>\nexport function createApp(config: KoraConfig): KoraApp\nexport function createApp<const S extends SchemaInput>(\n\tconfig: TypedKoraConfig<S> | KoraConfig,\n): TypedKoraApp<S> | KoraApp {\n\tvalidateCreateAppConfig(config)\n\n\tconst emitter = new SimpleEventEmitter()\n\tconst mergeEngine = new MergeEngine()\n\n\tif (config.onSyncEvent) {\n\t\twireSyncEventForwarding(emitter, config.onSyncEvent)\n\t}\n\n\tlet store: Store | null = null\n\tlet unsubscribeSync: (() => void) | null = null\n\tlet unsubscribeAudit: (() => void) | null = null\n\n\tconst syncState: SyncRuntimeState = {\n\t\tsyncEngine: null,\n\t\tsyncStatusBridge: null,\n\t\tauthSyncCoordinator: null,\n\t\treconnectionManager: null,\n\t\tconnectionMonitor: null,\n\t\tqualityInterval: null,\n\t\tintentionalDisconnect: false,\n\t\tremoveOnlineListener: null,\n\t}\n\n\tconst devtools = setupDevtools(config, emitter)\n\tconst queryStoreCache = new QueryStoreCache(config.store?.name ?? 'kora-db')\n\n\tconst ready = initializeApp(config, emitter, mergeEngine).then((init) => {\n\t\tstore = init.store\n\t\tunsubscribeSync = init.unsubscribeSync\n\t\tunsubscribeAudit = init.unsubscribeAudit\n\t\twireSyncLifecycleAfterReady(config, emitter, syncState, init)\n\t})\n\n\tconst getStore = (): Store | null => store\n\tconst executeTransaction = createTransactionExecutor(config, ready, getStore)\n\n\tconst app: KoraApp = {\n\t\tready,\n\t\tevents: emitter,\n\t\tsync: createSyncControl({ config, ready, state: syncState }),\n\t\tsequences: createSequencesAccessor(ready, getStore),\n\t\tgetStore(): Store {\n\t\t\tif (!store) {\n\t\t\t\tthrow new Error('Store not initialized. Await app.ready before accessing the store.')\n\t\t\t}\n\t\t\treturn store\n\t\t},\n\t\tgetSyncEngine(): SyncEngine | null {\n\t\t\treturn syncState.syncEngine\n\t\t},\n\t\tgetQueryStoreCache(): QueryStoreCache {\n\t\t\treturn queryStoreCache\n\t\t},\n\t\ttransaction(fn) {\n\t\t\treturn executeTransaction(fn)\n\t\t},\n\t\tmutation(name, fn) {\n\t\t\treturn executeTransaction(fn, name)\n\t\t},\n\t\tasync close() {\n\t\t\tawait ready\n\t\t\tsyncState.intentionalDisconnect = true\n\t\t\tteardownSyncLifecycle(syncState)\n\t\t\tdevtools.destroyOverlay?.()\n\t\t\tdevtools.instrumenter?.destroy()\n\t\t\tif (unsubscribeSync) {\n\t\t\t\tunsubscribeSync()\n\t\t\t\tunsubscribeSync = null\n\t\t\t}\n\t\t\tif (unsubscribeAudit) {\n\t\t\t\tunsubscribeAudit()\n\t\t\t\tunsubscribeAudit = null\n\t\t\t}\n\t\t\tif (syncState.syncEngine) {\n\t\t\t\tawait syncState.syncEngine.stop()\n\t\t\t\tsyncState.syncEngine = null\n\t\t\t}\n\t\t\tqueryStoreCache.clear()\n\t\t\tif (store) {\n\t\t\t\tawait store.close()\n\t\t\t\tstore = null\n\t\t\t}\n\t\t\temitter.clear()\n\t\t},\n\t\tasync exportBackup(options) {\n\t\t\tawait ready\n\t\t\tif (!store) {\n\t\t\t\tthrow new Error('Store not initialized. Await app.ready before exporting backup.')\n\t\t\t}\n\t\t\treturn store.exportBackup(options)\n\t\t},\n\t\tasync importBackup(data, options) {\n\t\t\tawait ready\n\t\t\tif (!store) {\n\t\t\t\tthrow new Error('Store not initialized. Await app.ready before importing backup.')\n\t\t\t}\n\t\t\treturn store.importBackup(data, options)\n\t\t},\n\t\tasync replayTo(operationId) {\n\t\t\tawait ready\n\t\t\tif (!store) {\n\t\t\t\tthrow new Error('Store not initialized. Await app.ready before replaying operations.')\n\t\t\t}\n\t\t\treturn store.replayTo(operationId)\n\t\t},\n\t\tasync exportAudit(options) {\n\t\t\tawait ready\n\t\t\tif (!store) {\n\t\t\t\tthrow new Error('Store not initialized. Await app.ready before exporting audit data.')\n\t\t\t}\n\t\t\treturn store.exportAudit(options)\n\t\t},\n\t}\n\n\tfor (const collectionName of Object.keys(config.schema.collections)) {\n\t\tObject.defineProperty(app, collectionName, {\n\t\t\tget() {\n\t\t\t\treturn createCollectionAccessor(collectionName, getStore)\n\t\t\t},\n\t\t\tenumerable: true,\n\t\t\tconfigurable: false,\n\t\t})\n\t}\n\n\treturn app\n}\n","import { AppNotReadyError } from '@korajs/core'\nimport type { CollectionAccessor, QueryBuilder, Store } from '@korajs/store'\n\n/**\n * Builds a collection accessor that throws {@link AppNotReadyError} until the store opens.\n */\nexport function createCollectionAccessor(\n\tcollectionName: string,\n\tgetStore: () => Store | null,\n): CollectionAccessor {\n\tconst notReady = (action: string): AppNotReadyError =>\n\t\tnew AppNotReadyError(\n\t\t\t`Cannot ${action} on collection \"${collectionName}\" before app.ready. Await app.ready or use <KoraProvider app={app}>.`,\n\t\t)\n\n\treturn {\n\t\tasync insert(data: Record<string, unknown>) {\n\t\t\tconst currentStore = getStore()\n\t\t\tif (!currentStore) {\n\t\t\t\tthrow notReady('insert into')\n\t\t\t}\n\t\t\treturn currentStore.collection(collectionName).insert(data)\n\t\t},\n\t\tasync findById(id: string) {\n\t\t\tconst currentStore = getStore()\n\t\t\tif (!currentStore) return null\n\t\t\treturn currentStore.collection(collectionName).findById(id)\n\t\t},\n\t\tasync update(id: string, data: Record<string, unknown>) {\n\t\t\tconst currentStore = getStore()\n\t\t\tif (!currentStore) {\n\t\t\t\tthrow notReady('update')\n\t\t\t}\n\t\t\treturn currentStore.collection(collectionName).update(id, data)\n\t\t},\n\t\tasync delete(id: string) {\n\t\t\tconst currentStore = getStore()\n\t\t\tif (!currentStore) {\n\t\t\t\tthrow notReady('delete from')\n\t\t\t}\n\t\t\treturn currentStore.collection(collectionName).delete(id)\n\t\t},\n\t\twhere(conditions: Record<string, unknown>): QueryBuilder {\n\t\t\tconst currentStore = getStore()\n\t\t\tif (!currentStore) {\n\t\t\t\tthrow notReady('query')\n\t\t\t}\n\t\t\treturn currentStore.collection(collectionName).where(conditions)\n\t\t},\n\t}\n}\n","import type { KoraEventEmitter } from '@korajs/core'\nimport { buildScopeMap } from '@korajs/core'\nimport type { MergeEngine } from '@korajs/merge'\nimport { Store } from '@korajs/store'\nimport type { StorageAdapter } from '@korajs/store'\nimport { SyncEncryptor, SyncEngine } from '@korajs/sync'\nimport { createAdapter, detectAdapterType } from './adapter-resolver'\nimport { ApplyPipeline } from './apply-pipeline'\nimport { wireAuditPersistence } from './audit-bridge'\nimport { createSyncTransport } from './create-sync-transport'\nimport { MergeAwareSyncStore } from './merge-aware-sync-store'\nimport { StoreQueueStorage } from './store-queue-storage'\nimport { StoreSyncStatePersistence } from './store-sync-state'\nimport { createSyncQuerySubscriptionHook } from './sync-query-bridge'\nimport type { AuthSyncBinding, KoraConfig } from './types'\n\n/** Result of opening the local store and optionally constructing a sync engine. */\nexport interface InitializeAppResult {\n\tstore: Store\n\tsyncEngine: SyncEngine | null\n\tunsubscribeSync: (() => void) | null\n\tunsubscribeAudit: (() => void) | null\n\tauthBinding: AuthSyncBinding | null\n}\n\n/**\n * Opens the local store, wires apply/audit pipelines, and optionally constructs sync.\n */\nexport async function initializeApp(\n\tconfig: KoraConfig,\n\temitter: KoraEventEmitter,\n\tmergeEngine: MergeEngine,\n): Promise<InitializeAppResult> {\n\tconst adapterType = config.store?.adapter ?? detectAdapterType()\n\tconst dbName = config.store?.name ?? 'kora-db'\n\tconst adapter: StorageAdapter = await createAdapter(\n\t\tadapterType,\n\t\tdbName,\n\t\tconfig.store?.workerUrl,\n\t\temitter,\n\t\tconfig.store?.workerResponseTimeoutMs,\n\t\tconfig.store?.sharedWorkerUrl,\n\t)\n\n\tconst authBinding = config.sync?.authClient ?? null\n\tconst authNodeId = authBinding?.resolveNodeId ? await authBinding.resolveNodeId() : undefined\n\n\tlet syncEngine: SyncEngine | null = null\n\n\tconst store = new Store({\n\t\tschema: config.schema,\n\t\tadapter,\n\t\temitter,\n\t\tdbName,\n\t\tnodeId: authNodeId,\n\t\tisolation: authNodeId ? 'shared' : config.store?.isolation,\n\t\t...(config.sync ? { onQuerySubscribed: createSyncQuerySubscriptionHook(() => syncEngine) } : {}),\n\t})\n\tawait store.open()\n\n\tlet recordConflict: (() => void) | undefined\n\tconst applyPipeline = new ApplyPipeline({\n\t\tstore,\n\t\tmergeEngine,\n\t\temitter,\n\t\tonMergeConflict: () => recordConflict?.(),\n\t})\n\tstore.setLocalMutationHandler(applyPipeline)\n\tconst unsubscribeAudit = wireAuditPersistence(store, emitter)\n\n\tlet unsubscribeSync: (() => void) | null = null\n\n\tif (config.sync) {\n\t\tconst transport = createSyncTransport(config.sync)\n\t\tconst mergeAwareStore = new MergeAwareSyncStore(store, mergeEngine, emitter, {\n\t\t\tonMergeConflict: () => recordConflict?.(),\n\t\t})\n\n\t\tlet scopeMap = config.sync.scope ? buildScopeMap(config.schema, config.sync.scope) : undefined\n\t\tif (authBinding?.resolveScopeMap) {\n\t\t\tscopeMap = (await authBinding.resolveScopeMap()) ?? scopeMap\n\t\t}\n\n\t\tconst syncAuth = authBinding?.auth ?? config.sync.auth\n\n\t\tconst encryptor =\n\t\t\tconfig.sync.encryption?.enabled === true\n\t\t\t\t? await SyncEncryptor.create(config.sync.encryption)\n\t\t\t\t: undefined\n\n\t\tsyncEngine = new SyncEngine({\n\t\t\ttransport,\n\t\t\tstore: mergeAwareStore,\n\t\t\tconfig: {\n\t\t\t\turl: config.sync.url,\n\t\t\t\ttransport: config.sync.transport,\n\t\t\t\tauth: syncAuth,\n\t\t\t\tbatchSize: config.sync.batchSize,\n\t\t\t\tschemaVersion: config.sync.schemaVersion ?? config.schema.version,\n\t\t\t\tscopeMap,\n\t\t\t\tencryption: config.sync.encryption,\n\t\t\t\tstrictHandshake: config.sync.strictHandshake,\n\t\t\t\toperationTransforms: config.sync.operationTransforms,\n\t\t\t},\n\t\t\temitter,\n\t\t\tqueueStorage: new StoreQueueStorage(adapter),\n\t\t\tsyncState: new StoreSyncStatePersistence(store, scopeMap),\n\t\t\tencryptor,\n\t\t})\n\t\trecordConflict = () => syncEngine?.recordConflict()\n\n\t\tunsubscribeSync = emitter.on('operation:created', (event) => {\n\t\t\tif (syncEngine) {\n\t\t\t\tsyncEngine.pushOperation(event.operation)\n\t\t\t}\n\t\t})\n\t}\n\n\treturn {\n\t\tstore,\n\t\tsyncEngine,\n\t\tunsubscribeSync,\n\t\tunsubscribeAudit,\n\t\tauthBinding,\n\t}\n}\n","import type { KoraEventEmitter } from '@korajs/core'\nimport type { StorageAdapter } from '@korajs/store'\nimport type { AdapterType } from './types'\n\n/** Dynamic import that bundlers cannot statically analyze (optional peer packages). */\nfunction importOptionalPeer<T>(specifier: string): Promise<T> {\n\tconst dynamicImport = new Function('specifier', 'return import(specifier)') as (\n\t\ts: string,\n\t) => Promise<T>\n\treturn dynamicImport(specifier)\n}\n\n/**\n * Detect the best storage adapter for the current environment.\n *\n * - Tauri app: 'tauri-sqlite' (native SQLite via Tauri plugin)\n * - Node.js: 'better-sqlite3'\n * - Browser with OPFS: 'sqlite-wasm'\n * - Browser without OPFS: 'indexeddb'\n */\nexport function detectAdapterType(): AdapterType {\n\t// Tauri environment — detected via __TAURI_INTERNALS__ injected by the Tauri runtime\n\tif (\n\t\ttypeof globalThis !== 'undefined' &&\n\t\ttypeof (globalThis as Record<string, unknown>).__TAURI_INTERNALS__ !== 'undefined'\n\t) {\n\t\treturn 'tauri-sqlite'\n\t}\n\n\t// Node.js environment\n\tif (typeof process !== 'undefined' && process.versions?.node) {\n\t\treturn 'better-sqlite3'\n\t}\n\n\t// Browser environment\n\tif (typeof globalThis.navigator !== 'undefined') {\n\t\t// Check for OPFS support (FileSystemHandle indicates OPFS availability)\n\t\tif (typeof (globalThis as Record<string, unknown>).FileSystemHandle !== 'undefined') {\n\t\t\treturn 'sqlite-wasm'\n\t\t}\n\t\treturn 'indexeddb'\n\t}\n\n\t// Default fallback (e.g., Deno, Bun, or other runtimes)\n\treturn 'better-sqlite3'\n}\n\n/**\n * Create a StorageAdapter for the given adapter type.\n * Uses dynamic imports so unused adapters are not bundled.\n *\n * @param type - The adapter type to create\n * @param dbName - Database name (used by all adapters)\n * @returns A configured StorageAdapter instance\n */\nexport async function createAdapter(\n\ttype: AdapterType,\n\tdbName: string,\n\tworkerUrl?: string | URL,\n\temitter?: KoraEventEmitter,\n\tworkerResponseTimeoutMs?: number,\n\tsharedWorkerUrl?: string | URL,\n): Promise<StorageAdapter> {\n\tswitch (type) {\n\t\tcase 'tauri-sqlite': {\n\t\t\t// @korajs/tauri is only installed in Tauri projects (optional peer dep).\n\t\t\t// Runtime import via Function so Vite/Rollup do not pre-bundle or resolve the module.\n\t\t\tconst { TauriSqliteAdapter } = await importOptionalPeer<{\n\t\t\t\tTauriSqliteAdapter: new (options: { path: string }) => StorageAdapter\n\t\t\t}>('@korajs/tauri')\n\t\t\treturn new TauriSqliteAdapter({ path: `${dbName}.db` })\n\t\t}\n\t\tcase 'better-sqlite3': {\n\t\t\tconst { BetterSqlite3Adapter } = await import(\n\t\t\t\t/* @vite-ignore */ '@korajs/store/better-sqlite3'\n\t\t\t)\n\t\t\treturn new BetterSqlite3Adapter(dbName)\n\t\t}\n\t\tcase 'sqlite-wasm': {\n\t\t\tconst { SqliteWasmAdapter } = await import('@korajs/store/sqlite-wasm')\n\t\t\treturn new SqliteWasmAdapter({ dbName, workerUrl, sharedWorkerUrl, workerResponseTimeoutMs })\n\t\t}\n\t\tcase 'indexeddb': {\n\t\t\tconst { IndexedDbAdapter } = await import('@korajs/store/indexeddb')\n\t\t\treturn new IndexedDbAdapter({ dbName, workerUrl, emitter, workerResponseTimeoutMs })\n\t\t}\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = type\n\t\t\tthrow new Error(`Unknown adapter type: ${_exhaustive}`)\n\t\t}\n\t}\n}\n","import type { KoraEvent, KoraEventEmitter } from '@korajs/core'\nimport type { Store } from '@korajs/store'\nimport { persistedAuditTraceFromEvent } from '@korajs/store'\n\nconst AUDIT_EVENT_TYPES = ['merge:completed', 'merge:conflict', 'constraint:violated'] as const\n\ntype AuditEventType = (typeof AUDIT_EVENT_TYPES)[number]\n\nfunction isAuditEvent(event: KoraEvent): event is Extract<KoraEvent, { type: AuditEventType }> {\n\treturn (AUDIT_EVENT_TYPES as readonly string[]).includes(event.type)\n}\n\n/**\n * Persist merge and constraint traces from the event bus to `_kora_audit_traces`.\n */\nexport function wireAuditPersistence(store: Store, emitter: KoraEventEmitter): () => void {\n\tconst unsubscribers = AUDIT_EVENT_TYPES.map((eventType) =>\n\t\temitter.on(eventType, (event) => {\n\t\t\tif (!isAuditEvent(event)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst trace = persistedAuditTraceFromEvent(event)\n\t\t\tvoid store.appendAuditTrace(trace).catch(() => {\n\t\t\t\t// Audit persistence must not break mutations or sync.\n\t\t\t})\n\t\t}),\n\t)\n\n\treturn () => {\n\t\tfor (const unsub of unsubscribers) {\n\t\t\tunsub()\n\t\t}\n\t}\n}\n","import { HttpLongPollingTransport, WebSocketTransport } from '@korajs/sync'\nimport type { SyncTransport } from '@korajs/sync'\nimport type { KoraConfig } from './types'\n\n/**\n * Instantiates the sync transport matching {@link KoraConfig.sync} settings.\n */\nexport function createSyncTransport(sync: NonNullable<KoraConfig['sync']>): SyncTransport {\n\tif (sync.transport === 'http') {\n\t\treturn new HttpLongPollingTransport()\n\t}\n\treturn new WebSocketTransport()\n}\n","import type { QueryDescriptor } from '@korajs/store'\nimport type { SyncEngine, SyncQuerySubset } from '@korajs/sync'\n\n/**\n * Extract equality-only WHERE conditions for sync query subset registration.\n * Operator-based filters (e.g. `$gt`) are not representable as sync subsets yet.\n */\nexport function queryDescriptorToSyncSubset(descriptor: QueryDescriptor): SyncQuerySubset | null {\n\tconst where: Record<string, unknown> = {}\n\tconst skippedFields: string[] = []\n\n\tfor (const [field, value] of Object.entries(descriptor.where)) {\n\t\tif (value === null || value === undefined) {\n\t\t\twhere[field] = value\n\t\t\tcontinue\n\t\t}\n\t\tif (typeof value !== 'object' || Array.isArray(value)) {\n\t\t\twhere[field] = value\n\t\t\tcontinue\n\t\t}\n\t\tskippedFields.push(field)\n\t}\n\n\tif (skippedFields.length > 0 && typeof console !== 'undefined') {\n\t\tconsole.warn(\n\t\t\t`[Kora] Sync query subset omitted non-equality filters on ${descriptor.collection}: ${skippedFields.join(', ')}. ` +\n\t\t\t\t'Only plain equality WHERE clauses are registered for incremental sync.',\n\t\t)\n\t}\n\n\tif (Object.keys(where).length === 0) {\n\t\treturn null\n\t}\n\n\treturn {\n\t\tcollection: descriptor.collection,\n\t\twhere,\n\t}\n}\n\n/**\n * Creates a store hook that registers live query filters with the sync engine.\n */\nexport function createSyncQuerySubscriptionHook(\n\tgetSyncEngine: () => SyncEngine | null,\n): (descriptor: QueryDescriptor) => () => void {\n\treturn (descriptor) => {\n\t\tconst subset = queryDescriptorToSyncSubset(descriptor)\n\t\tif (!subset) {\n\t\t\treturn () => {}\n\t\t}\n\n\t\tconst engine = getSyncEngine()\n\t\tif (!engine) {\n\t\t\treturn () => {}\n\t\t}\n\n\t\treturn engine.registerQuerySubset(subset)\n\t}\n}\n","import type { Store } from '@korajs/store'\nimport type { SequenceAccessor } from './types'\n\n/**\n * Builds the offline-safe sequences accessor backed by the store sequence manager.\n */\nexport function createSequencesAccessor(\n\tready: Promise<void>,\n\tgetStore: () => Store | null,\n): SequenceAccessor {\n\tconst requireStore = async (): Promise<Store> => {\n\t\tawait ready\n\t\tconst store = getStore()\n\t\tif (!store) {\n\t\t\tthrow new Error('Store not initialized. Await app.ready before using sequences.')\n\t\t}\n\t\treturn store\n\t}\n\n\treturn {\n\t\tasync next(name, config) {\n\t\t\tconst store = await requireStore()\n\t\t\treturn store.getSequenceManager().next(name, config)\n\t\t},\n\t\tasync current(name, config) {\n\t\t\tconst store = await requireStore()\n\t\t\treturn store.getSequenceManager().current(name, config)\n\t\t},\n\t\tasync reset(name, config) {\n\t\t\tconst store = await requireStore()\n\t\t\treturn store.getSequenceManager().reset(name, config)\n\t\t},\n\t}\n}\n","import type { KoraEventEmitter } from '@korajs/core'\nimport { Instrumenter } from '@korajs/devtools'\nimport type { KoraConfig } from './types'\n\nexport interface DevtoolsSetup {\n\tinstrumenter: Instrumenter | null\n\tdestroyOverlay: (() => void) | null\n}\n\n/**\n * Enables DevTools instrumentation and optionally mounts the browser overlay.\n */\nexport function setupDevtools(config: KoraConfig, emitter: KoraEventEmitter): DevtoolsSetup {\n\tif (!config.devtools) {\n\t\treturn { instrumenter: null, destroyOverlay: null }\n\t}\n\n\tconst instrumenter = new Instrumenter(emitter, {\n\t\tbridgeEnabled: typeof globalThis !== 'undefined' && 'window' in globalThis,\n\t})\n\n\tlet destroyOverlay: (() => void) | null = null\n\n\tif (typeof globalThis !== 'undefined' && 'window' in globalThis) {\n\t\tvoid import('@korajs/devtools/overlay')\n\t\t\t.then(({ mountKoraDevtoolsOverlay }) => {\n\t\t\t\tdestroyOverlay = mountKoraDevtoolsOverlay(instrumenter)\n\t\t\t})\n\t\t\t.catch(() => {\n\t\t\t\t// Overlay is optional; extension bridge still works.\n\t\t\t})\n\t}\n\n\treturn { instrumenter, destroyOverlay: () => destroyOverlay?.() }\n}\n","import type { SyncStatusInfo } from '@korajs/sync'\nimport { OFFLINE_SYNC_STATUS } from '@korajs/sync'\nimport type { SyncRuntimeState } from './sync-lifecycle'\nimport type { KoraConfig, SyncControl } from './types'\n\nexport interface CreateSyncControlOptions {\n\tconfig: KoraConfig\n\tready: Promise<void>\n\tstate: SyncRuntimeState\n}\n\n/**\n * Builds the developer-facing `app.sync` control surface.\n */\nexport function createSyncControl(options: CreateSyncControlOptions): SyncControl | null {\n\tconst { config, ready, state } = options\n\n\tif (!config.sync) {\n\t\treturn null\n\t}\n\n\tconst offlineSyncStatus = (): SyncStatusInfo => OFFLINE_SYNC_STATUS\n\n\tconst bridgeStatus = (): SyncStatusInfo =>\n\t\tstate.syncStatusBridge?.status ?? offlineSyncStatus()\n\n\treturn {\n\t\tget status(): SyncStatusInfo {\n\t\t\treturn bridgeStatus()\n\t\t},\n\t\tsubscribeStatus(listener: (status: SyncStatusInfo) => void): () => void {\n\t\t\tif (state.syncStatusBridge) {\n\t\t\t\treturn state.syncStatusBridge.subscribe(listener)\n\t\t\t}\n\t\t\tlistener(offlineSyncStatus())\n\t\t\treturn () => {}\n\t\t},\n\t\tasync connect(): Promise<void> {\n\t\t\tawait ready\n\t\t\tif (state.syncEngine) {\n\t\t\t\tstate.intentionalDisconnect = false\n\t\t\t\tstate.reconnectionManager?.stop()\n\t\t\t\tstate.reconnectionManager?.reset()\n\t\t\t\tawait state.syncEngine.start()\n\t\t\t\tstate.syncStatusBridge?.refresh()\n\t\t\t}\n\t\t},\n\t\tasync disconnect(): Promise<void> {\n\t\t\tawait ready\n\t\t\tif (state.syncEngine) {\n\t\t\t\tstate.intentionalDisconnect = true\n\t\t\t\tstate.reconnectionManager?.stop()\n\t\t\t\tawait state.syncEngine.stop()\n\t\t\t\tstate.syncStatusBridge?.refresh()\n\t\t\t}\n\t\t},\n\t\tgetStatus(): SyncStatusInfo {\n\t\t\tif (state.syncEngine) {\n\t\t\t\treturn state.syncEngine.getStatus()\n\t\t\t}\n\t\t\treturn offlineSyncStatus()\n\t\t},\n\t\tasync retryNow(): Promise<void> {\n\t\t\tawait ready\n\t\t\tif (state.syncEngine) {\n\t\t\t\tawait state.syncEngine.retryNow()\n\t\t\t}\n\t\t},\n\t\tclearSchemaBlock(): void {\n\t\t\tstate.syncEngine?.clearSchemaBlock()\n\t\t},\n\t\texportDiagnostics() {\n\t\t\tif (state.syncEngine) {\n\t\t\t\treturn state.syncEngine.exportDiagnostics()\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstate: 'disconnected' as const,\n\t\t\t\tstatus: {\n\t\t\t\t\tstatus: 'offline' as const,\n\t\t\t\t\tpendingOperations: 0,\n\t\t\t\t\tlastSyncedAt: null,\n\t\t\t\t\tlastSuccessfulPush: null,\n\t\t\t\t\tlastSuccessfulPull: null,\n\t\t\t\t\tconflicts: 0,\n\t\t\t\t},\n\t\t\t\tnodeId: '',\n\t\t\t\turl: config.sync?.url ?? '',\n\t\t\t\tschemaVersion: config.schema.version,\n\t\t\t\tlastSyncedAt: null,\n\t\t\t\tlastSuccessfulPush: null,\n\t\t\t\tlastSuccessfulPull: null,\n\t\t\t\tconflicts: 0,\n\t\t\t\tpendingOperations: 0,\n\t\t\t\thasInFlightBatch: false,\n\t\t\t\treconnecting: false,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t}\n\t\t},\n\t}\n}\n","import type { SyncEngine } from '@korajs/sync'\nimport type { AuthSyncBinding } from './types'\n\n/**\n * Serializes auth-driven sync reconnects so overlapping token refresh events\n * do not stack concurrent stop/start cycles on the sync engine.\n */\nexport class AuthSyncCoordinator {\n\tprivate inFlight: Promise<void> | null = null\n\tprivate pending = false\n\tprivate disposed = false\n\n\tconstructor(\n\t\tprivate readonly getEngine: () => SyncEngine | null,\n\t\tprivate readonly authBinding: AuthSyncBinding,\n\t) {}\n\n\tscheduleReconnect(): void {\n\t\tif (this.disposed) {\n\t\t\treturn\n\t\t}\n\n\t\tif (this.inFlight) {\n\t\t\tthis.pending = true\n\t\t\treturn\n\t\t}\n\n\t\tthis.inFlight = this.run().finally(() => {\n\t\t\tthis.inFlight = null\n\t\t\tif (this.pending && !this.disposed) {\n\t\t\t\tthis.pending = false\n\t\t\t\tthis.scheduleReconnect()\n\t\t\t}\n\t\t})\n\t}\n\n\tdestroy(): void {\n\t\tthis.disposed = true\n\t\tthis.pending = false\n\t}\n\n\tprivate async run(): Promise<void> {\n\t\tconst engine = this.getEngine()\n\t\tif (!engine) {\n\t\t\treturn\n\t\t}\n\n\t\tconst headers = await this.authBinding.auth()\n\t\tif (!headers.token) {\n\t\t\tawait engine.stop()\n\t\t\treturn\n\t\t}\n\n\t\tif (this.authBinding.resolveScopeMap) {\n\t\t\tconst nextScope = await this.authBinding.resolveScopeMap()\n\t\t\tengine.updateScope(nextScope)\n\t\t}\n\n\t\tconst status = engine.getStatus().status\n\t\tif (status !== 'offline') {\n\t\t\tawait engine.stop()\n\t\t}\n\t\tawait engine.start()\n\t}\n}\n","import type { KoraEventEmitter } from '@korajs/core'\nimport { createSyncStatusController, type SyncStatusInfo } from '@korajs/sync'\n\n/**\n * Event-driven sync status snapshot for non-React consumers (`app.sync.status`).\n */\nexport interface SyncStatusBridge {\n\treadonly status: SyncStatusInfo\n\tsubscribe(listener: (status: SyncStatusInfo) => void): () => void\n\trefresh(): void\n\tdestroy(): void\n}\n\n/**\n * Subscribe to sync events and expose a reactive status snapshot.\n */\nexport function createSyncStatusBridge(\n\temitter: KoraEventEmitter,\n\tgetSyncEngine: () => { getStatus(): SyncStatusInfo } | null,\n): SyncStatusBridge {\n\tconst controller = createSyncStatusController({\n\t\tgetSyncEngine,\n\t\tsubscribeSyncStatus: null,\n\t\tevents: emitter,\n\t})\n\n\treturn {\n\t\tget status() {\n\t\t\treturn controller.getSnapshot()\n\t\t},\n\t\tsubscribe(listener: (status: SyncStatusInfo) => void): () => void {\n\t\t\treturn controller.subscribe(() => {\n\t\t\t\tlistener(controller.getSnapshot())\n\t\t\t})\n\t\t},\n\t\trefresh: () => controller.refresh(),\n\t\tdestroy: () => controller.destroy(),\n\t}\n}\n","import type { KoraEventEmitter } from '@korajs/core'\nimport { AuthSyncCoordinator } from './auth-sync-coordinator'\nimport type { InitializeAppResult } from './initialize-app'\nimport { createSyncStatusBridge, type SyncStatusBridge } from './sync-status-bridge'\nimport type { KoraConfig } from './types'\nimport {\n\tConnectionMonitor,\n\tReconnectionManager,\n\ttype SyncEngine,\n} from '@korajs/sync'\n\n/** Mutable sync runtime state owned by {@link createApp}. */\nexport interface SyncRuntimeState {\n\tsyncEngine: SyncEngine | null\n\tsyncStatusBridge: SyncStatusBridge | null\n\tauthSyncCoordinator: AuthSyncCoordinator | null\n\treconnectionManager: ReconnectionManager | null\n\tconnectionMonitor: ConnectionMonitor | null\n\tqualityInterval: ReturnType<typeof setInterval> | null\n\tintentionalDisconnect: boolean\n\t/** Removes the browser `online` listener registered in {@link wireSyncLifecycleAfterReady}. */\n\tremoveOnlineListener: (() => void) | null\n}\n\n/**\n * Wires sync status bridge, auth reconnect coordinator, reconnection, and quality monitoring\n * after {@link initializeApp} completes.\n */\nexport function wireSyncLifecycleAfterReady(\n\tconfig: KoraConfig,\n\temitter: KoraEventEmitter,\n\tstate: SyncRuntimeState,\n\tinit: InitializeAppResult,\n): void {\n\tstate.syncEngine = init.syncEngine\n\n\tif (!config.sync) {\n\t\treturn\n\t}\n\n\tstate.syncStatusBridge = createSyncStatusBridge(emitter, () => state.syncEngine)\n\tstate.syncStatusBridge.refresh()\n\n\tif (state.syncEngine && init.authBinding?.subscribe) {\n\t\tstate.authSyncCoordinator = new AuthSyncCoordinator(() => state.syncEngine, init.authBinding)\n\t\tinit.authBinding.subscribe(() => {\n\t\t\tstate.authSyncCoordinator?.scheduleReconnect()\n\t\t})\n\t}\n\n\tif (!state.syncEngine) {\n\t\treturn\n\t}\n\n\tconst syncEngine = state.syncEngine\n\tstate.connectionMonitor = new ConnectionMonitor()\n\tstate.reconnectionManager = new ReconnectionManager({\n\t\tinitialDelay: config.sync.reconnectInterval,\n\t\tmaxDelay: config.sync.maxReconnectInterval,\n\t})\n\n\temitter.on('sync:sent', () => state.connectionMonitor?.recordActivity())\n\temitter.on('sync:received', () => state.connectionMonitor?.recordActivity())\n\temitter.on('sync:acknowledged', () => state.connectionMonitor?.recordActivity())\n\n\temitter.on('sync:connected', () => {\n\t\tif (state.qualityInterval !== null) {\n\t\t\tclearInterval(state.qualityInterval)\n\t\t}\n\t\tstate.qualityInterval = setInterval(() => {\n\t\t\tif (state.connectionMonitor) {\n\t\t\t\temitter.emit({\n\t\t\t\t\ttype: 'connection:quality',\n\t\t\t\t\tquality: state.connectionMonitor.getQuality(),\n\t\t\t\t})\n\t\t\t}\n\t\t}, 5000)\n\t})\n\n\temitter.on('sync:disconnected', () => {\n\t\tstate.connectionMonitor?.reset()\n\t\tif (state.qualityInterval !== null) {\n\t\t\tclearInterval(state.qualityInterval)\n\t\t\tstate.qualityInterval = null\n\t\t}\n\t})\n\n\tconst browserGlobal = globalThis as typeof globalThis & {\n\t\taddEventListener?: (type: string, listener: () => void) => void\n\t\tremoveEventListener?: (type: string, listener: () => void) => void\n\t}\n\tif (typeof browserGlobal.addEventListener === 'function') {\n\t\tconst onOnline = (): void => {\n\t\t\tif (state.intentionalDisconnect || config.sync?.autoReconnect === false) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tstate.reconnectionManager?.wake()\n\t\t\tstate.reconnectionManager?.reset()\n\t\t\tvoid syncEngine.retryNow()\n\t\t}\n\t\tbrowserGlobal.addEventListener('online', onOnline)\n\t\tstate.removeOnlineListener = (): void => {\n\t\t\tbrowserGlobal.removeEventListener?.('online', onOnline)\n\t\t}\n\t}\n\n\temitter.on('sync:schema-mismatch', () => {\n\t\tstate.reconnectionManager?.stop()\n\t\tstate.intentionalDisconnect = true\n\t})\n\n\tif (config.sync.autoReconnect !== false) {\n\t\temitter.on('sync:disconnected', () => {\n\t\t\tif (state.intentionalDisconnect || syncEngine.isSchemaBlocked()) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (state.reconnectionManager?.isRunning()) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tsyncEngine.setReconnecting(true)\n\t\t\tstate.reconnectionManager?.stop()\n\t\t\tstate.reconnectionManager\n\t\t\t\t?.start(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait syncEngine.start()\n\t\t\t\t\t\tsyncEngine.setReconnecting(false)\n\t\t\t\t\t\treturn true\n\t\t\t\t\t} catch {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.then(() => {\n\t\t\t\t\tsyncEngine.setReconnecting(false)\n\t\t\t\t})\n\t\t})\n\t}\n\n\tif (config.sync.autoConnect === true) {\n\t\tvoid syncEngine.start().catch(() => {\n\t\t\t// Errors surface via sync:disconnected / sync events; avoid unhandled rejection.\n\t\t})\n\t}\n}\n\n/**\n * Stops timers and managers during {@link KoraApp.close}.\n */\nexport function teardownSyncLifecycle(state: SyncRuntimeState): void {\n\tif (state.qualityInterval !== null) {\n\t\tclearInterval(state.qualityInterval)\n\t\tstate.qualityInterval = null\n\t}\n\tstate.reconnectionManager?.stop()\n\tstate.syncStatusBridge?.destroy()\n\tstate.syncStatusBridge = null\n\tstate.authSyncCoordinator?.destroy()\n\tstate.authSyncCoordinator = null\n\tstate.removeOnlineListener?.()\n\tstate.removeOnlineListener = null\n}\n","import type { Operation } from '@korajs/core'\nimport type { Store } from '@korajs/store'\nimport type { KoraConfig, TransactionProxy } from './types'\n\nexport interface TransactionExecutor {\n\t(fn: (tx: TransactionProxy) => Promise<void>, mutationName?: string): Promise<Operation[]>\n}\n\n/**\n * Creates the shared executor used by {@link KoraApp.transaction} and {@link KoraApp.mutation}.\n */\nexport function createTransactionExecutor(\n\tconfig: KoraConfig,\n\tready: Promise<void>,\n\tgetStore: () => Store | null,\n): TransactionExecutor {\n\treturn async (fn, mutationName) => {\n\t\tawait ready\n\t\tconst store = getStore()\n\t\tif (!store) {\n\t\t\tthrow new Error('Store not initialized. Await app.ready before using transactions.')\n\t\t}\n\n\t\tconst collectionNames = Object.keys(config.schema.collections)\n\n\t\treturn store.transaction(async (tx) => {\n\t\t\tif (mutationName !== undefined) {\n\t\t\t\ttx.setMutationName(mutationName)\n\t\t\t}\n\n\t\t\tconst proxy: TransactionProxy = {} as TransactionProxy\n\t\t\tfor (const name of collectionNames) {\n\t\t\t\tObject.defineProperty(proxy, name, {\n\t\t\t\t\tget() {\n\t\t\t\t\t\treturn tx.collection(name)\n\t\t\t\t\t},\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: false,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tawait fn(proxy)\n\t\t})\n\t}\n}\n","import { KoraError, SchemaValidationError } from '@korajs/core'\nimport { detectAdapterType } from './adapter-resolver'\nimport type { KoraConfig } from './types'\n\n/**\n * Fail fast on invalid createApp configuration before opening storage or sync.\n */\nexport function validateCreateAppConfig(config: KoraConfig): void {\n\tif (!config.schema) {\n\t\tthrow new SchemaValidationError('createApp requires a schema.', {\n\t\t\tfix: 'Pass schema: defineSchema({ version: 1, collections: { ... } })',\n\t\t})\n\t}\n\n\tif (config.schema.version < 1) {\n\t\tthrow new SchemaValidationError('Schema version must be at least 1.', {\n\t\t\tversion: config.schema.version,\n\t\t})\n\t}\n\n\tconst collectionNames = Object.keys(config.schema.collections)\n\tif (collectionNames.length === 0) {\n\t\tthrow new SchemaValidationError('Schema must define at least one collection.', {\n\t\t\tfix: 'Add entries under collections in defineSchema().',\n\t\t})\n\t}\n\n\tif (config.sync) {\n\t\tvalidateSyncUrl(config.sync.url, config.sync.transport ?? 'websocket')\n\t}\n\n\tconst adapter = config.store?.adapter ?? detectAdapterType()\n\tconst isBrowser =\n\t\ttypeof globalThis !== 'undefined' &&\n\t\ttypeof (globalThis as Record<string, unknown>).window !== 'undefined'\n\n\tif (\n\t\tisBrowser &&\n\t\t(adapter === 'sqlite-wasm' || adapter === 'indexeddb') &&\n\t\t!config.store?.workerUrl\n\t) {\n\t\tthrow new KoraError(\n\t\t\t'Browser storage requires store.workerUrl pointing to the SQLite WASM worker script.',\n\t\t\t'MISSING_WORKER_URL',\n\t\t\t{\n\t\t\t\tadapter,\n\t\t\t\tfix: 'Add store: { workerUrl: \"/sqlite-wasm-worker.js\" } (see create-kora-app templates).',\n\t\t\t},\n\t\t)\n\t}\n}\n\nfunction validateSyncUrl(url: string, transport: 'websocket' | 'http'): void {\n\tif (!url || url.trim().length === 0) {\n\t\tthrow new KoraError('sync.url is required when sync is configured.', 'INVALID_SYNC_URL', {\n\t\t\tfix: 'Pass sync: { url: \"wss://your-server/kora\" }.',\n\t\t})\n\t}\n\n\ttry {\n\t\tconst parsed = new URL(url)\n\t\tif (transport === 'http') {\n\t\t\tif (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n\t\t\t\tthrow new Error('bad protocol')\n\t\t\t}\n\t\t} else if (parsed.protocol !== 'ws:' && parsed.protocol !== 'wss:') {\n\t\t\tthrow new Error('bad protocol')\n\t\t}\n\t} catch {\n\t\tthrow new KoraError(\n\t\t\t`Invalid sync URL \"${url}\" for transport \"${transport}\".`,\n\t\t\t'INVALID_SYNC_URL',\n\t\t\t{\n\t\t\t\turl,\n\t\t\t\ttransport,\n\t\t\t\tfix:\n\t\t\t\t\ttransport === 'http'\n\t\t\t\t\t\t? 'Use an absolute http:// or https:// URL.'\n\t\t\t\t\t\t: 'Use an absolute ws:// or wss:// URL.',\n\t\t\t},\n\t\t)\n\t}\n}\n","import type { KoraEventEmitter } from '@korajs/core'\nimport type { KoraSyncEvent } from './types'\n\nconst SYNC_EVENT_TYPES = [\n\t'sync:connected',\n\t'sync:disconnected',\n\t'sync:schema-mismatch',\n\t'sync:auth-failed',\n\t'sync:sent',\n\t'sync:received',\n\t'sync:acknowledged',\n\t'sync:apply-failed',\n\t'sync:diagnostics',\n\t'sync:bandwidth',\n\t'sync:initial-sync-progress',\n] as const\n\n/**\n * Forwards selected sync events from the app emitter to {@link KoraConfig.onSyncEvent}.\n */\nexport function wireSyncEventForwarding(\n\temitter: KoraEventEmitter,\n\thandler: (event: KoraSyncEvent) => void,\n): void {\n\tfor (const type of SYNC_EVENT_TYPES) {\n\t\temitter.on(type, (event) => {\n\t\t\thandler(event as KoraSyncEvent)\n\t\t})\n\t}\n}\n","// kora — meta-package re-exporting core, store, merge, sync\n// This is the primary entry point for `import { createApp, defineSchema, t } from 'korajs'`\n\n// === createApp factory ===\nexport { createApp } from './create-app'\n\n// === App types ===\nexport type {\n\tAdapterType,\n\tAuthSyncBinding,\n\tKoraApp,\n\tKoraConfig,\n\tStoreOptions,\n\tSyncControl,\n\tSyncOptions,\n\tSequenceAccessor,\n\tTransactionCollectionProxy,\n\tTransactionProxy,\n\tTypedCollectionAccessor,\n\tTypedKoraApp,\n\tTypedKoraConfig,\n} from './types'\n\nexport type { ReplaySnapshot } from '@korajs/store'\nexport type {\n\tAuditExportManifest,\n\tAuditExportOptions,\n\tAuditExportPayload,\n\tPersistedAuditTrace,\n} from '@korajs/store'\nexport {\n\tdecodeAuditExport,\n\treadAuditExportManifest,\n\tverifyAuditExportChecksum,\n} from '@korajs/store'\n\n// === @korajs/core re-exports ===\nexport { defineSchema, migrate, t } from '@korajs/core'\nexport { HybridLogicalClock } from '@korajs/core'\nexport { generateUUIDv7 } from '@korajs/core'\nexport { createOperation } from '@korajs/core'\nexport { KoraError, AppNotReadyError } from '@korajs/core'\nexport { op } from '@korajs/core'\nexport type {\n\tAtomicOp,\n\tAtomicOpType,\n\tCollectionDefinition,\n\tConnectionQuality,\n\tConstraint,\n\tFieldDescriptor,\n\tFieldKindToType,\n\tHLCTimestamp,\n\tInferFieldType,\n\tInferInsertInput,\n\tInferRecord,\n\tInferUpdateInput,\n\tKoraEvent,\n\tKoraEventEmitter,\n\tKoraEventListener,\n\tKoraEventType,\n\tMergeStrategy,\n\tMergeTrace,\n\tMigrationDefinition,\n\tMigrationStep,\n\tOperation,\n\tSchemaDefinition,\n\tSchemaInput,\n\tSequenceConfig,\n\tSyncRuleDefinition,\n\tTypedSchemaDefinition,\n\tVersionVector,\n} from '@korajs/core'\n\n// === @korajs/store re-exports ===\nexport { SequenceManager, Store } from '@korajs/store'\nexport { TransactionContext } from '@korajs/store'\nexport {\n\texportBackup,\n\treadBackupManifest,\n\trestoreBackup,\n\tverifyBackupChecksum,\n} from '@korajs/store'\nexport type {\n\tBackupManifest,\n\tBackupOptions,\n\tBackupProgress,\n\tCollectionAccessor,\n\tCollectionRecord,\n\tRestoreOptions,\n\tRestoreResult,\n\tStorageAdapter,\n\tStoreConfig,\n\tTransactionCollectionAccessor,\n\tTransactionContextConfig,\n} from '@korajs/store'\n\n// === @korajs/merge re-exports ===\nexport { MergeEngine } from '@korajs/merge'\nexport type { MergeInput, MergeResult } from '@korajs/merge'\n\n// === @korajs/sync re-exports ===\nexport { SyncEngine, WebSocketTransport } from '@korajs/sync'\nexport type {\n\tSyncConfig,\n\tSyncDiagnostics,\n\tSyncEncryptionConfig,\n\tSyncState,\n\tSyncStatus,\n\tSyncStatusInfo,\n\tSyncStore,\n} from '@korajs/sync'\n"],"mappings":";;;;;;;;AACA,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAE5B,SAAS,uBAAuB;;;ACJhC,SAAS,wBAAwB;AAM1B,SAAS,yBACf,gBACA,UACqB;AACrB,QAAM,WAAW,CAAC,WACjB,IAAI;AAAA,IACH,UAAU,MAAM,mBAAmB,cAAc;AAAA,EAClD;AAED,SAAO;AAAA,IACN,MAAM,OAAO,MAA+B;AAC3C,YAAM,eAAe,SAAS;AAC9B,UAAI,CAAC,cAAc;AAClB,cAAM,SAAS,aAAa;AAAA,MAC7B;AACA,aAAO,aAAa,WAAW,cAAc,EAAE,OAAO,IAAI;AAAA,IAC3D;AAAA,IACA,MAAM,SAAS,IAAY;AAC1B,YAAM,eAAe,SAAS;AAC9B,UAAI,CAAC,aAAc,QAAO;AAC1B,aAAO,aAAa,WAAW,cAAc,EAAE,SAAS,EAAE;AAAA,IAC3D;AAAA,IACA,MAAM,OAAO,IAAY,MAA+B;AACvD,YAAM,eAAe,SAAS;AAC9B,UAAI,CAAC,cAAc;AAClB,cAAM,SAAS,QAAQ;AAAA,MACxB;AACA,aAAO,aAAa,WAAW,cAAc,EAAE,OAAO,IAAI,IAAI;AAAA,IAC/D;AAAA,IACA,MAAM,OAAO,IAAY;AACxB,YAAM,eAAe,SAAS;AAC9B,UAAI,CAAC,cAAc;AAClB,cAAM,SAAS,aAAa;AAAA,MAC7B;AACA,aAAO,aAAa,WAAW,cAAc,EAAE,OAAO,EAAE;AAAA,IACzD;AAAA,IACA,MAA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cAAa;AACvC,SAAS,0BAA0B;AACnC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAgBP,SAAS,eAAAC,oBAAmB;AAI5B,SAAS,cAAAC,aAAY,sBAAAC,2BAA0B;","names":["KoraError","AppNotReadyError","Store","MergeEngine","SyncEngine","WebSocketTransport"]}
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/react.ts
|
|
21
|
+
var react_exports = {};
|
|
22
|
+
__export(react_exports, {
|
|
23
|
+
KoraProvider: () => import_react.KoraProvider,
|
|
24
|
+
useApp: () => import_react.useApp,
|
|
25
|
+
useCollaborators: () => import_react.useCollaborators,
|
|
26
|
+
useCollection: () => import_react.useCollection,
|
|
27
|
+
useMutation: () => import_react.useMutation,
|
|
28
|
+
usePresence: () => import_react.usePresence,
|
|
29
|
+
useQuery: () => import_react.useQuery,
|
|
30
|
+
useRichText: () => import_react.useRichText,
|
|
31
|
+
useSyncStatus: () => import_react.useSyncStatus
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(react_exports);
|
|
34
|
+
var import_react = require("@korajs/react");
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
KoraProvider,
|
|
38
|
+
useApp,
|
|
39
|
+
useCollaborators,
|
|
40
|
+
useCollection,
|
|
41
|
+
useMutation,
|
|
42
|
+
usePresence,
|
|
43
|
+
useQuery,
|
|
44
|
+
useRichText,
|
|
45
|
+
useSyncStatus
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["/**\n * React bindings — re-exported from `@korajs/react` for `import { ... } from 'korajs/react'`.\n */\nexport type {\n\tKoraAppLike,\n\tKoraContextValue,\n\tKoraProviderProps,\n\tUseMutationOptions,\n\tUseMutationResult,\n\tUseQueryOptions,\n\tUseRichTextResult,\n} from '@korajs/react'\n\nexport type { UseRichTextOptions } from '@korajs/react'\n\nexport {\n\tKoraProvider,\n\tuseApp,\n\tuseCollection,\n\tuseMutation,\n\tuseQuery,\n\tuseRichText,\n\tuseSyncStatus,\n\tusePresence,\n\tuseCollaborators,\n} from '@korajs/react'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,mBAUO;","names":[]}
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { KoraAppLike, KoraContextValue, KoraProvider, KoraProviderProps, UseMutationOptions, UseMutationResult, UseQueryOptions, UseRichTextOptions, UseRichTextResult, useApp, useCollaborators, useCollection, useMutation, usePresence, useQuery, useRichText, useSyncStatus } from '@korajs/react';
|
|
2
|
+
import '@korajs/svelte';
|
|
3
|
+
import '@korajs/vue';
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { KoraAppLike, KoraContextValue, KoraProvider, KoraProviderProps, UseMutationOptions, UseMutationResult, UseQueryOptions, UseRichTextOptions, UseRichTextResult, useApp, useCollaborators, useCollection, useMutation, usePresence, useQuery, useRichText, useSyncStatus } from '@korajs/react';
|
|
2
|
+
import '@korajs/svelte';
|
|
3
|
+
import '@korajs/vue';
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/react.ts
|
|
2
|
+
import {
|
|
3
|
+
KoraProvider,
|
|
4
|
+
useApp,
|
|
5
|
+
useCollection,
|
|
6
|
+
useMutation,
|
|
7
|
+
useQuery,
|
|
8
|
+
useRichText,
|
|
9
|
+
useSyncStatus,
|
|
10
|
+
usePresence,
|
|
11
|
+
useCollaborators
|
|
12
|
+
} from "@korajs/react";
|
|
13
|
+
export {
|
|
14
|
+
KoraProvider,
|
|
15
|
+
useApp,
|
|
16
|
+
useCollaborators,
|
|
17
|
+
useCollection,
|
|
18
|
+
useMutation,
|
|
19
|
+
usePresence,
|
|
20
|
+
useQuery,
|
|
21
|
+
useRichText,
|
|
22
|
+
useSyncStatus
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["/**\n * React bindings — re-exported from `@korajs/react` for `import { ... } from 'korajs/react'`.\n */\nexport type {\n\tKoraAppLike,\n\tKoraContextValue,\n\tKoraProviderProps,\n\tUseMutationOptions,\n\tUseMutationResult,\n\tUseQueryOptions,\n\tUseRichTextResult,\n} from '@korajs/react'\n\nexport type { UseRichTextOptions } from '@korajs/react'\n\nexport {\n\tKoraProvider,\n\tuseApp,\n\tuseCollection,\n\tuseMutation,\n\tuseQuery,\n\tuseRichText,\n\tuseSyncStatus,\n\tusePresence,\n\tuseCollaborators,\n} from '@korajs/react'\n"],"mappings":";AAeA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;","names":[]}
|
package/dist/svelte.cjs
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/svelte.ts
|
|
21
|
+
var svelte_exports = {};
|
|
22
|
+
__export(svelte_exports, {
|
|
23
|
+
applyPresence: () => import_svelte.applyPresence,
|
|
24
|
+
createCollaboratorsStore: () => import_svelte.createCollaboratorsStore,
|
|
25
|
+
createMutation: () => import_svelte.createMutation,
|
|
26
|
+
createQueryStore: () => import_svelte.createQueryStore,
|
|
27
|
+
createRichTextBinding: () => import_svelte.createRichTextBinding,
|
|
28
|
+
createSyncStatusStore: () => import_svelte.createSyncStatusStore,
|
|
29
|
+
getApp: () => import_svelte.getApp,
|
|
30
|
+
getCollection: () => import_svelte.getCollection,
|
|
31
|
+
getKoraApp: () => import_svelte.getKoraApp,
|
|
32
|
+
getKoraContext: () => import_svelte.getKoraContext,
|
|
33
|
+
initKoraProvider: () => import_svelte.initKoraProvider,
|
|
34
|
+
setKoraAppContext: () => import_svelte.setKoraAppContext,
|
|
35
|
+
setKoraContext: () => import_svelte.setKoraContext,
|
|
36
|
+
useApp: () => import_svelte.useApp,
|
|
37
|
+
useCollaborators: () => import_svelte.useCollaborators,
|
|
38
|
+
useCollection: () => import_svelte.useCollection,
|
|
39
|
+
useMutation: () => import_svelte.useMutation,
|
|
40
|
+
usePresence: () => import_svelte.usePresence,
|
|
41
|
+
useQuery: () => import_svelte.useQuery,
|
|
42
|
+
useRichText: () => import_svelte.useRichText,
|
|
43
|
+
useSyncStatus: () => import_svelte.useSyncStatus
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(svelte_exports);
|
|
46
|
+
var import_svelte = require("@korajs/svelte");
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
applyPresence,
|
|
50
|
+
createCollaboratorsStore,
|
|
51
|
+
createMutation,
|
|
52
|
+
createQueryStore,
|
|
53
|
+
createRichTextBinding,
|
|
54
|
+
createSyncStatusStore,
|
|
55
|
+
getApp,
|
|
56
|
+
getCollection,
|
|
57
|
+
getKoraApp,
|
|
58
|
+
getKoraContext,
|
|
59
|
+
initKoraProvider,
|
|
60
|
+
setKoraAppContext,
|
|
61
|
+
setKoraContext,
|
|
62
|
+
useApp,
|
|
63
|
+
useCollaborators,
|
|
64
|
+
useCollection,
|
|
65
|
+
useMutation,
|
|
66
|
+
usePresence,
|
|
67
|
+
useQuery,
|
|
68
|
+
useRichText,
|
|
69
|
+
useSyncStatus
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=svelte.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/svelte.ts"],"sourcesContent":["/**\n * Svelte bindings — re-exported from `@korajs/svelte` for `import { ... } from 'korajs/svelte'`.\n */\nexport type {\n\tKoraAppHandle,\n\tKoraAppLike,\n\tKoraContextValue,\n\tUseMutationOptions,\n\tUseMutationResult,\n\tUseQueryOptions,\n\tUseRichTextResult,\n} from '@korajs/svelte'\n\nexport type { UseRichTextOptions } from '@korajs/svelte'\n\nexport {\n\tcreateMutation,\n\tcreateQueryStore,\n\tcreateRichTextBinding,\n\tcreateSyncStatusStore,\n\tgetApp,\n\tgetCollection,\n\tgetKoraApp,\n\tgetKoraContext,\n\tinitKoraProvider,\n\tsetKoraAppContext,\n\tsetKoraContext,\n\tuseApp,\n\tuseCollection,\n\tuseMutation,\n\tuseQuery,\n\tuseRichText,\n\tuseSyncStatus,\n\tapplyPresence,\n\tusePresence,\n\tcreateCollaboratorsStore,\n\tuseCollaborators,\n} from '@korajs/svelte'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,oBAsBO;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { KoraAppHandle, KoraAppLike, KoraContextValue, UseMutationOptions, UseMutationResult, UseQueryOptions, UseRichTextOptions, UseRichTextResult, applyPresence, createCollaboratorsStore, createMutation, createQueryStore, createRichTextBinding, createSyncStatusStore, getApp, getCollection, getKoraApp, getKoraContext, initKoraProvider, setKoraAppContext, setKoraContext, useApp, useCollaborators, useCollection, useMutation, usePresence, useQuery, useRichText, useSyncStatus } from '@korajs/svelte';
|
package/dist/svelte.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { KoraAppHandle, KoraAppLike, KoraContextValue, UseMutationOptions, UseMutationResult, UseQueryOptions, UseRichTextOptions, UseRichTextResult, applyPresence, createCollaboratorsStore, createMutation, createQueryStore, createRichTextBinding, createSyncStatusStore, getApp, getCollection, getKoraApp, getKoraContext, initKoraProvider, setKoraAppContext, setKoraContext, useApp, useCollaborators, useCollection, useMutation, usePresence, useQuery, useRichText, useSyncStatus } from '@korajs/svelte';
|
package/dist/svelte.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/svelte.ts
|
|
2
|
+
import {
|
|
3
|
+
createMutation,
|
|
4
|
+
createQueryStore,
|
|
5
|
+
createRichTextBinding,
|
|
6
|
+
createSyncStatusStore,
|
|
7
|
+
getApp,
|
|
8
|
+
getCollection,
|
|
9
|
+
getKoraApp,
|
|
10
|
+
getKoraContext,
|
|
11
|
+
initKoraProvider,
|
|
12
|
+
setKoraAppContext,
|
|
13
|
+
setKoraContext,
|
|
14
|
+
useApp,
|
|
15
|
+
useCollection,
|
|
16
|
+
useMutation,
|
|
17
|
+
useQuery,
|
|
18
|
+
useRichText,
|
|
19
|
+
useSyncStatus,
|
|
20
|
+
applyPresence,
|
|
21
|
+
usePresence,
|
|
22
|
+
createCollaboratorsStore,
|
|
23
|
+
useCollaborators
|
|
24
|
+
} from "@korajs/svelte";
|
|
25
|
+
export {
|
|
26
|
+
applyPresence,
|
|
27
|
+
createCollaboratorsStore,
|
|
28
|
+
createMutation,
|
|
29
|
+
createQueryStore,
|
|
30
|
+
createRichTextBinding,
|
|
31
|
+
createSyncStatusStore,
|
|
32
|
+
getApp,
|
|
33
|
+
getCollection,
|
|
34
|
+
getKoraApp,
|
|
35
|
+
getKoraContext,
|
|
36
|
+
initKoraProvider,
|
|
37
|
+
setKoraAppContext,
|
|
38
|
+
setKoraContext,
|
|
39
|
+
useApp,
|
|
40
|
+
useCollaborators,
|
|
41
|
+
useCollection,
|
|
42
|
+
useMutation,
|
|
43
|
+
usePresence,
|
|
44
|
+
useQuery,
|
|
45
|
+
useRichText,
|
|
46
|
+
useSyncStatus
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=svelte.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/svelte.ts"],"sourcesContent":["/**\n * Svelte bindings — re-exported from `@korajs/svelte` for `import { ... } from 'korajs/svelte'`.\n */\nexport type {\n\tKoraAppHandle,\n\tKoraAppLike,\n\tKoraContextValue,\n\tUseMutationOptions,\n\tUseMutationResult,\n\tUseQueryOptions,\n\tUseRichTextResult,\n} from '@korajs/svelte'\n\nexport type { UseRichTextOptions } from '@korajs/svelte'\n\nexport {\n\tcreateMutation,\n\tcreateQueryStore,\n\tcreateRichTextBinding,\n\tcreateSyncStatusStore,\n\tgetApp,\n\tgetCollection,\n\tgetKoraApp,\n\tgetKoraContext,\n\tinitKoraProvider,\n\tsetKoraAppContext,\n\tsetKoraContext,\n\tuseApp,\n\tuseCollection,\n\tuseMutation,\n\tuseQuery,\n\tuseRichText,\n\tuseSyncStatus,\n\tapplyPresence,\n\tusePresence,\n\tcreateCollaboratorsStore,\n\tuseCollaborators,\n} from '@korajs/svelte'\n"],"mappings":";AAeA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;","names":[]}
|