@korajs/vue 0.6.1 → 1.0.0-beta.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/LICENSE +21 -0
- package/dist/index.cjs +11 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dr. Obed Ehoneah
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -57,11 +57,10 @@ function useKoraContext() {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// src/components/kora-provider.ts
|
|
60
|
-
var
|
|
60
|
+
var import_store = require("@korajs/store");
|
|
61
61
|
var import_vue2 = require("vue");
|
|
62
62
|
|
|
63
63
|
// src/resolve-query-store-cache.ts
|
|
64
|
-
var import_store = require("@korajs/store");
|
|
65
64
|
function resolveQueryStoreCache(app, fallback) {
|
|
66
65
|
if (app && typeof app.getQueryStoreCache === "function") {
|
|
67
66
|
return app.getQueryStoreCache();
|
|
@@ -95,7 +94,7 @@ var KoraProvider = (0, import_vue2.defineComponent)({
|
|
|
95
94
|
const resolvedSync = (0, import_vue2.ref)(null);
|
|
96
95
|
const ready = (0, import_vue2.ref)(!props.app && Boolean(props.store));
|
|
97
96
|
const initError = (0, import_vue2.ref)(null);
|
|
98
|
-
const fallbackQueryStoreCache = new
|
|
97
|
+
const fallbackQueryStoreCache = new import_store.QueryStoreCache();
|
|
99
98
|
const contextRef = (0, import_vue2.shallowRef)(null);
|
|
100
99
|
(0, import_vue2.provide)(koraContextKey, contextRef);
|
|
101
100
|
if (props.app) {
|
|
@@ -168,11 +167,10 @@ var KoraProvider = (0, import_vue2.defineComponent)({
|
|
|
168
167
|
});
|
|
169
168
|
return () => {
|
|
170
169
|
if (initError.value) {
|
|
171
|
-
return (0, import_vue2.h)(
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
);
|
|
170
|
+
return (0, import_vue2.h)("div", { style: { color: "red", padding: "1rem", fontFamily: "monospace" } }, [
|
|
171
|
+
(0, import_vue2.h)("strong", null, "Kora initialization error: "),
|
|
172
|
+
initError.value.message
|
|
173
|
+
]);
|
|
176
174
|
}
|
|
177
175
|
if (!ready.value) {
|
|
178
176
|
return props.fallback ?? null;
|
|
@@ -188,7 +186,7 @@ var KoraProvider = (0, import_vue2.defineComponent)({
|
|
|
188
186
|
});
|
|
189
187
|
|
|
190
188
|
// src/composables/use-query.ts
|
|
191
|
-
var
|
|
189
|
+
var import_store2 = require("@korajs/store");
|
|
192
190
|
var import_vue3 = require("vue");
|
|
193
191
|
var EMPTY_ARRAY = Object.freeze([]);
|
|
194
192
|
function useQuery(query, options) {
|
|
@@ -202,7 +200,7 @@ function useQuery(query, options) {
|
|
|
202
200
|
snapshot.value = EMPTY_ARRAY;
|
|
203
201
|
return;
|
|
204
202
|
}
|
|
205
|
-
(0,
|
|
203
|
+
(0, import_store2.assertQueryReady)(query);
|
|
206
204
|
const queryStore = queryStoreCache.getOrCreate(query);
|
|
207
205
|
const unsubscribe = queryStore.subscribe(() => {
|
|
208
206
|
snapshot.value = queryStore.getSnapshot();
|
|
@@ -297,7 +295,7 @@ function useCollection(name) {
|
|
|
297
295
|
}
|
|
298
296
|
|
|
299
297
|
// src/composables/use-rich-text.ts
|
|
300
|
-
var
|
|
298
|
+
var import_store3 = require("@korajs/store");
|
|
301
299
|
var import_vue6 = require("vue");
|
|
302
300
|
function useRichText(collectionName, recordId, fieldName, options) {
|
|
303
301
|
const { store, syncEngine } = useKoraContext();
|
|
@@ -313,13 +311,13 @@ function useRichText(collectionName, recordId, fieldName, options) {
|
|
|
313
311
|
() => [collectionName, recordId, fieldName, options?.useDocChannel],
|
|
314
312
|
([name, id, field, useDocChannel], _previous, onCleanup) => {
|
|
315
313
|
controllerRef.value?.destroy();
|
|
316
|
-
const controller2 = (0,
|
|
314
|
+
const controller2 = (0, import_store3.createRichTextController)({
|
|
317
315
|
collection: store.collection(name),
|
|
318
316
|
collectionName: name,
|
|
319
317
|
recordId: id,
|
|
320
318
|
fieldName: field,
|
|
321
319
|
store,
|
|
322
|
-
syncEngine: (0,
|
|
320
|
+
syncEngine: (0, import_store3.asRichTextSyncEngine)(syncEngine),
|
|
323
321
|
useDocChannel,
|
|
324
322
|
user: options?.user
|
|
325
323
|
});
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/context.ts","../src/components/kora-provider.ts","../src/resolve-query-store-cache.ts","../src/composables/use-query.ts","../src/composables/use-mutation.ts","../src/composables/use-sync-status.ts","../src/composables/use-app.ts","../src/composables/use-collection.ts","../src/composables/use-rich-text.ts","../src/composables/use-presence.ts"],"sourcesContent":["import { KoraError } from '@korajs/core'\nimport { type App, inject } from 'vue'\nimport { koraAppInjectionKey } from './context'\nimport type { KoraAppLike } from './types'\n\nexport type { KoraAppHandle, KoraAppLike, KoraContextValue, KoraProviderProps } from './types'\nexport type { UseMutationOptions, UseMutationResult, UseQueryOptions, UseRichTextResult } from './types'\n\nexport { koraAppInjectionKey, koraContextKey, useKoraContext } from './context'\nexport { KoraProvider } from './components/kora-provider'\nexport { useQuery } from './composables/use-query'\nexport { useMutation } from './composables/use-mutation'\nexport { useSyncStatus } from './composables/use-sync-status'\nexport { useApp } from './composables/use-app'\nexport { useCollection } from './composables/use-collection'\nexport { useRichText } from './composables/use-rich-text'\nexport type { UseRichTextOptions } from './composables/use-rich-text'\nexport { usePresence, useCollaborators } from './composables/use-presence'\n\n/**\n * Register a Kora app on a Vue application instance.\n *\n * @deprecated Prefer {@link KoraProvider} — `installKora` does not provide reactive\n * hook context (`useQuery`, `useSyncStatus`, etc.) until you migrate to `KoraProvider`.\n */\nexport function installKora(vueApp: App, koraApp: KoraAppLike): void {\n\tvueApp.provide(koraAppInjectionKey, koraApp)\n}\n\n/**\n * Access the Kora app from a component when using {@link installKora} only.\n * For reactive hooks, use {@link useApp} inside {@link KoraProvider}.\n */\nexport function useKoraApp(): KoraAppLike {\n\tconst app = inject(koraAppInjectionKey)\n\tif (!app) {\n\t\tthrow new KoraError(\n\t\t\t'useKoraApp() requires installKora(vueApp, koraApp) or <KoraProvider :app=\"app\">.',\n\t\t\t'KORA_NOT_PROVIDED',\n\t\t\t{ fix: 'Use <KoraProvider :app=\"app\"> and useApp() for full bindings.' },\n\t\t)\n\t}\n\treturn app\n}\n","import { KoraError } from '@korajs/core'\nimport { type InjectionKey, inject, type ShallowRef } from 'vue'\nimport type { KoraAppLike, KoraContextValue } from './types'\n\nexport const koraContextKey: InjectionKey<ShallowRef<KoraContextValue | null>> =\n\tSymbol('korajs-context')\n\n/** @deprecated Use {@link koraContextKey} with {@link KoraProvider}. */\nexport const koraAppInjectionKey: InjectionKey<KoraAppLike> = Symbol('korajs-app')\n\nexport function useKoraContext(): KoraContextValue {\n\tconst contextRef = inject(koraContextKey)\n\tif (!contextRef?.value) {\n\t\tthrow new KoraError(\n\t\t\t'useKoraContext() requires <KoraProvider>. Wrap your app root with KoraProvider.',\n\t\t\t'KORA_NOT_PROVIDED',\n\t\t\t{ fix: '<KoraProvider :app=\"app\"><App /></KoraProvider>' },\n\t\t)\n\t}\n\treturn contextRef.value\n}\n","import { QueryStoreCache } from '@korajs/store'\nimport type { Store } from '@korajs/store'\nimport type { SyncEngine } from '@korajs/sync'\nimport {\n\ttype PropType,\n\ttype VNode,\n\tdefineComponent,\n\th,\n\tonScopeDispose,\n\tprovide,\n\tref,\n\tshallowRef,\n\twatch,\n} from 'vue'\nimport { koraContextKey, koraAppInjectionKey } from '../context'\nimport type { KoraAppLike, KoraContextValue } from '../types'\nimport { resolveQueryStoreCache } from '../resolve-query-store-cache'\n\nexport const KoraProvider = defineComponent({\n\tname: 'KoraProvider',\n\tprops: {\n\t\tapp: {\n\t\t\ttype: Object as PropType<KoraAppLike>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tstore: {\n\t\t\ttype: Object as PropType<Store>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tsyncEngine: {\n\t\t\ttype: Object as PropType<SyncEngine | null>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: [Object, String] as PropType<VNode | string | null>,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\tsetup(props, { slots }) {\n\t\tconst resolvedStore = ref<Store | null>(null)\n\t\tconst resolvedSync = ref<SyncEngine | null>(null)\n\t\tconst ready = ref(!props.app && Boolean(props.store))\n\t\tconst initError = ref<Error | null>(null)\n\t\tconst fallbackQueryStoreCache = new QueryStoreCache()\n\t\tconst contextRef = shallowRef<KoraContextValue | null>(null)\n\n\t\tprovide(koraContextKey, contextRef)\n\t\tif (props.app) {\n\t\t\tprovide(koraAppInjectionKey, props.app)\n\t\t}\n\n\t\twatch(\n\t\t\t() => props.app,\n\t\t\t(app, _previous, onCleanup) => {\n\t\t\t\tif (!app) {\n\t\t\t\t\tif (props.store) {\n\t\t\t\t\t\tresolvedStore.value = props.store as Store\n\t\t\t\t\t\tresolvedSync.value = (props.syncEngine ?? null) as SyncEngine | null\n\t\t\t\t\t\tready.value = true\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tready.value = false\n\t\t\t\tinitError.value = null\n\t\t\t\tlet cancelled = false\n\n\t\t\t\tapp.ready\n\t\t\t\t\t.then(() => {\n\t\t\t\t\t\tif (cancelled) return\n\t\t\t\t\t\tresolvedStore.value = app.getStore() as Store\n\t\t\t\t\t\tresolvedSync.value = app.getSyncEngine() as SyncEngine | null\n\t\t\t\t\t\tready.value = true\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\t\tif (cancelled) return\n\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error))\n\t\t\t\t\t\tconsole.error('[Kora] Initialization failed:', err)\n\t\t\t\t\t\tinitError.value = err\n\t\t\t\t\t})\n\n\t\t\t\tonCleanup(() => {\n\t\t\t\t\tcancelled = true\n\t\t\t\t})\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\twatch(\n\t\t\t() => props.store,\n\t\t\t(store) => {\n\t\t\t\tif (store && !props.app) {\n\t\t\t\t\tresolvedStore.value = store as Store\n\t\t\t\t\tresolvedSync.value = (props.syncEngine ?? null) as SyncEngine | null\n\t\t\t\t\tready.value = true\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\twatch(\n\t\t\t() => [resolvedStore.value, resolvedSync.value, props.app] as const,\n\t\t\t([store, syncEngine, app]) => {\n\t\t\t\tif (!store) {\n\t\t\t\t\tcontextRef.value = null\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tcontextRef.value = {\n\t\t\t\t\tstore: store as Store,\n\t\t\t\t\tsyncEngine: (syncEngine ?? null) as SyncEngine | null,\n\t\t\t\t\tapp: app ?? null,\n\t\t\t\t\tevents: app?.events ?? null,\n\t\t\t\t\tsubscribeSyncStatus: app?.sync?.subscribeStatus ?? null,\n\t\t\t\t\tqueryStoreCache: resolveQueryStoreCache(app, fallbackQueryStoreCache),\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\tonScopeDispose(() => {\n\t\t\tif (!props.app) {\n\t\t\t\tfallbackQueryStoreCache.clear()\n\t\t\t}\n\t\t})\n\n\t\treturn () => {\n\t\t\tif (initError.value) {\n\t\t\t\treturn h(\n\t\t\t\t\t'div',\n\t\t\t\t\t{ style: { color: 'red', padding: '1rem', fontFamily: 'monospace' } },\n\t\t\t\t\t[h('strong', null, 'Kora initialization error: '), initError.value.message],\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tif (!ready.value) {\n\t\t\t\treturn props.fallback ?? null\n\t\t\t}\n\n\t\t\tif (!resolvedStore.value) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'KoraProvider requires either an \"app\" or \"store\" prop. Pass createApp() or a Store instance.',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn slots.default?.()\n\t\t}\n\t},\n})\n","import { QueryStoreCache } from '@korajs/store'\nimport type { KoraAppLike } from '../types'\n\n/**\n * Resolves the per-app query cache when available, otherwise a provider-local fallback.\n */\nexport function resolveQueryStoreCache(\n\tapp: KoraAppLike | null | undefined,\n\tfallback: QueryStoreCache,\n): QueryStoreCache {\n\tif (app && typeof app.getQueryStoreCache === 'function') {\n\t\treturn app.getQueryStoreCache()\n\t}\n\treturn fallback\n}\n","import type { CollectionRecord, QueryBuilder } from '@korajs/store'\nimport { assertQueryReady } from '@korajs/store'\nimport { type DeepReadonly, readonly, shallowRef, watch } from 'vue'\nimport { useKoraContext } from '../context'\nimport type { UseQueryOptions } from '../types'\n\nconst EMPTY_ARRAY: readonly unknown[] = Object.freeze([])\n\n/**\n * Reactive query composable backed by the local Kora store.\n */\nexport function useQuery<T = CollectionRecord>(\n\tquery: QueryBuilder<T>,\n\toptions?: UseQueryOptions,\n): DeepReadonly<ReturnType<typeof shallowRef<readonly T[]>>> {\n\tconst { queryStoreCache } = useKoraContext()\n\tconst enabled = options?.enabled !== false\n\tconst snapshot = shallowRef<readonly T[]>(EMPTY_ARRAY as readonly T[])\n\n\twatch(\n\t\t() => (enabled ? JSON.stringify(query.getDescriptor()) : null),\n\t\t(key, _previous, onCleanup) => {\n\t\t\tif (!key) {\n\t\t\t\tsnapshot.value = EMPTY_ARRAY as readonly T[]\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tassertQueryReady(query as QueryBuilder<unknown>)\n\t\t\tconst queryStore = queryStoreCache.getOrCreate(query)\n\t\t\tconst unsubscribe = queryStore.subscribe(() => {\n\t\t\t\tsnapshot.value = queryStore.getSnapshot()\n\t\t\t})\n\t\t\tsnapshot.value = queryStore.getSnapshot()\n\n\t\t\tonCleanup(() => {\n\t\t\t\tunsubscribe()\n\t\t\t\tqueryStoreCache.release(query as QueryBuilder<unknown>)\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n\n\treturn readonly(snapshot)\n}\n","import { createMutationController } from '@korajs/core/bindings'\nimport { onScopeDispose, ref, shallowReadonly } from 'vue'\nimport type { UseMutationOptions, UseMutationResult } from '../types'\n\n/**\n * Mutation composable with optional optimistic update and rollback hooks.\n */\nexport function useMutation<TData, TArgs extends unknown[], TContext = void>(\n\tmutationFn: (...args: TArgs) => Promise<TData>,\n\toptions?: UseMutationOptions<TData, TArgs, TContext>,\n): UseMutationResult<TData, TArgs> {\n\tconst fnRef = { current: mutationFn }\n\tfnRef.current = mutationFn\n\n\tconst optionsRef = { current: options }\n\toptionsRef.current = options\n\n\tconst isLoading = ref(false)\n\tconst error = ref<Error | null>(null)\n\tlet mounted = true\n\n\tonScopeDispose(() => {\n\t\tmounted = false\n\t})\n\n\tconst controller = createMutationController<TData, TArgs, TContext>({\n\t\tmutationFn: (...args) => fnRef.current(...args),\n\t\tresolveOptions: () => optionsRef.current,\n\t\tonStateChange: (state) => {\n\t\t\tif (!mounted) return\n\t\t\tisLoading.value = state.isLoading\n\t\t\terror.value = state.error\n\t\t},\n\t})\n\n\tisLoading.value = controller.getSnapshot().isLoading\n\terror.value = controller.getSnapshot().error\n\n\tonScopeDispose(() => {\n\t\tcontroller.destroy()\n\t})\n\n\treturn {\n\t\tmutate: (...args: TArgs) => controller.mutate(...args),\n\t\tmutateAsync: (...args: TArgs) => controller.mutateAsync(...args),\n\t\tisLoading: shallowReadonly(isLoading),\n\t\terror: shallowReadonly(error),\n\t\treset: () => controller.reset(),\n\t}\n}\n","import { OFFLINE_SYNC_STATUS, createSyncStatusController } from '@korajs/sync'\nimport { onScopeDispose, readonly, shallowRef, watchEffect } from 'vue'\nimport { useKoraContext } from '../context'\n\n/**\n * Reactive sync engine status. Updates only when status payload changes.\n */\nexport function useSyncStatus() {\n\tconst { syncEngine, subscribeSyncStatus, events } = useKoraContext()\n\tconst status = shallowRef(OFFLINE_SYNC_STATUS)\n\n\twatchEffect((onCleanup) => {\n\t\tconst controller = createSyncStatusController({\n\t\t\tsyncEngine,\n\t\t\tsubscribeSyncStatus,\n\t\t\tevents: subscribeSyncStatus ? null : events,\n\t\t})\n\t\tstatus.value = controller.getSnapshot()\n\t\tconst unsubscribe = controller.subscribe(() => {\n\t\t\tstatus.value = controller.getSnapshot()\n\t\t})\n\t\tonCleanup(() => {\n\t\t\tunsubscribe()\n\t\t\tcontroller.destroy()\n\t\t})\n\t})\n\n\treturn readonly(status)\n}\n","import { useKoraContext } from '../context'\nimport type { KoraAppLike } from '../types'\n\n/**\n * Returns the typed Kora app from {@link KoraProvider}'s `app` prop.\n */\nexport function useApp<T extends KoraAppLike = KoraAppLike>(): T {\n\tconst { app } = useKoraContext()\n\tif (!app) {\n\t\tthrow new Error(\n\t\t\t'useApp() requires <KoraProvider :app=\"app\">. Pass your createApp() result to the provider.',\n\t\t)\n\t}\n\treturn app as T\n}\n","import type { CollectionAccessor } from '@korajs/store'\nimport { useKoraContext } from '../context'\n\n/**\n * Returns a collection accessor for the given schema collection name.\n */\nexport function useCollection(name: string): CollectionAccessor {\n\tconst { store } = useKoraContext()\n\treturn store.collection(name)\n}\n","import { asRichTextSyncEngine, createRichTextController } from '@korajs/store'\nimport type { AwarenessUser } from '@korajs/sync'\nimport { reactive, shallowRef, watch } from 'vue'\nimport { useKoraContext } from '../context'\nimport type { UseRichTextResult } from '../types'\n\nexport interface UseRichTextOptions {\n\tuser?: AwarenessUser\n\tuseDocChannel?: boolean\n}\n\n/**\n * Binds a richtext field to a shared Yjs document for editor integration.\n */\nexport function useRichText(\n\tcollectionName: string,\n\trecordId: string,\n\tfieldName: string,\n\toptions?: UseRichTextOptions,\n): UseRichTextResult {\n\tconst { store, syncEngine } = useKoraContext()\n\tconst controllerRef = shallowRef<ReturnType<typeof createRichTextController> | null>(null)\n\n\tconst state = reactive({\n\t\tready: false,\n\t\terror: null as Error | null,\n\t\tcanUndo: false,\n\t\tcanRedo: false,\n\t\tcursors: [] as UseRichTextResult['cursors'],\n\t})\n\n\twatch(\n\t\t() => [collectionName, recordId, fieldName, options?.useDocChannel] as const,\n\t\t([name, id, field, useDocChannel], _previous, onCleanup) => {\n\t\t\tcontrollerRef.value?.destroy()\n\n\t\t\tconst controller = createRichTextController({\n\t\t\t\tcollection: store.collection(name),\n\t\t\t\tcollectionName: name,\n\t\t\t\trecordId: id,\n\t\t\t\tfieldName: field,\n\t\t\t\tstore,\n\t\t\t\tsyncEngine: asRichTextSyncEngine(syncEngine),\n\t\t\t\tuseDocChannel,\n\t\t\t\tuser: options?.user,\n\t\t\t})\n\n\t\t\tconst syncState = (): void => {\n\t\t\t\tconst snapshot = controller.getSnapshot()\n\t\t\t\tstate.ready = snapshot.ready\n\t\t\t\tstate.error = snapshot.error\n\t\t\t\tstate.canUndo = snapshot.canUndo\n\t\t\t\tstate.canRedo = snapshot.canRedo\n\t\t\t\tstate.cursors = [...snapshot.cursors]\n\t\t\t}\n\n\t\t\tsyncState()\n\t\t\tconst unsubscribe = controller.subscribe(syncState)\n\t\t\tcontrollerRef.value = controller\n\n\t\t\tonCleanup(() => {\n\t\t\t\tunsubscribe()\n\t\t\t\tcontroller.destroy()\n\t\t\t\tif (controllerRef.value === controller) {\n\t\t\t\t\tcontrollerRef.value = null\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n\n\twatch(\n\t\t() => options?.user,\n\t\t(user) => {\n\t\t\tcontrollerRef.value?.setUser(user)\n\t\t},\n\t)\n\n\tconst controller = (): NonNullable<typeof controllerRef.value> => {\n\t\tif (!controllerRef.value) {\n\t\t\tthrow new Error('useRichText controller is not initialized')\n\t\t}\n\t\treturn controllerRef.value\n\t}\n\n\treturn {\n\t\tget doc() {\n\t\t\treturn controller().doc\n\t\t},\n\t\tget text() {\n\t\t\treturn controller().text\n\t\t},\n\t\tundo: () => controller().undo(),\n\t\tredo: () => controller().redo(),\n\t\tget ready() {\n\t\t\treturn state.ready\n\t\t},\n\t\tget error() {\n\t\t\treturn state.error\n\t\t},\n\t\tget canUndo() {\n\t\t\treturn state.canUndo\n\t\t},\n\t\tget canRedo() {\n\t\t\treturn state.canRedo\n\t\t},\n\t\tget cursors() {\n\t\t\treturn state.cursors\n\t\t},\n\t\tsetCursor: (anchor: number, head: number) => controller().setCursor(anchor, head),\n\t\tclearCursor: () => controller().clearCursor(),\n\t}\n}\n","import type { AwarenessState } from '@korajs/sync'\nimport { subscribeRemoteAwarenessStates } from '@korajs/sync'\nimport { onScopeDispose, shallowRef, watch, watchEffect, type ShallowRef } from 'vue'\nimport { useKoraContext } from '../context'\n\n/**\n * Sets the local user's collaborative presence state.\n */\nexport function usePresence(user: { name: string; color: string; avatar?: string } | null): void {\n\tconst { syncEngine } = useKoraContext()\n\n\twatch(\n\t\t() => [syncEngine, user?.name, user?.color, user?.avatar] as const,\n\t\t([engine, name, color, avatar], _prev, onCleanup) => {\n\t\t\tif (!engine || !name || !color) return\n\n\t\t\tconst awareness = engine.getAwarenessManager()\n\t\t\tawareness.setLocalState({\n\t\t\t\tuser: {\n\t\t\t\t\tname,\n\t\t\t\t\tcolor,\n\t\t\t\t\tavatar,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tonCleanup(() => {\n\t\t\t\tawareness.setLocalState(null)\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n}\n\n/**\n * Reactive list of remote collaborators' awareness states.\n */\nexport function useCollaborators(): ShallowRef<AwarenessState[]> {\n\tconst { syncEngine } = useKoraContext()\n\tconst collaborators = shallowRef<AwarenessState[]>([])\n\n\twatchEffect((onCleanup) => {\n\t\tif (!syncEngine) {\n\t\t\tcollaborators.value = []\n\t\t\treturn\n\t\t}\n\n\t\tconst awareness = syncEngine.getAwarenessManager()\n\t\tconst unsubscribe = subscribeRemoteAwarenessStates(awareness, (states) => {\n\t\t\tcollaborators.value = states\n\t\t})\n\t\tonCleanup(unsubscribe)\n\t})\n\n\tonScopeDispose(() => {\n\t\tcollaborators.value = []\n\t})\n\n\treturn collaborators\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAA0B;AAC1B,IAAAC,cAAiC;;;ACDjC,kBAA0B;AAC1B,iBAA2D;AAGpD,IAAM,iBACZ,uBAAO,gBAAgB;AAGjB,IAAM,sBAAiD,uBAAO,YAAY;AAE1E,SAAS,iBAAmC;AAClD,QAAM,iBAAa,mBAAO,cAAc;AACxC,MAAI,CAAC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C,cAAgF;AAMzE,SAAS,YAAY,MAAqE;AAChG,QAAM,EAAE,WAAW,IAAI,eAAe;AAEtC;AAAA,IACC,MAAM,CAAC,YAAY,MAAM,MAAM,MAAM,OAAO,MAAM,MAAM;AAAA,IACxD,CAAC,CAAC,QAAQ,MAAM,OAAO,MAAM,GAAG,OAAO,cAAc;AACpD,UAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAO;AAEhC,YAAM,YAAY,OAAO,oBAAoB;AAC7C,gBAAU,cAAc;AAAA,QACvB,MAAM;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAAA,MACD,CAAC;AAED,gBAAU,MAAM;AACf,kBAAU,cAAc,IAAI;AAAA,MAC7B,CAAC;AAAA,IACF;AAAA,IACA,EAAE,WAAW,KAAK;AAAA,EACnB;AACD;AAKO,SAAS,mBAAiD;AAChE,QAAM,EAAE,WAAW,IAAI,eAAe;AACtC,QAAM,oBAAgB,wBAA6B,CAAC,CAAC;AAErD,+BAAY,CAAC,cAAc;AAC1B,QAAI,CAAC,YAAY;AAChB,oBAAc,QAAQ,CAAC;AACvB;AAAA,IACD;AAEA,UAAM,YAAY,WAAW,oBAAoB;AACjD,UAAM,kBAAc,6CAA+B,WAAW,CAAC,WAAW;AACzE,oBAAc,QAAQ;AAAA,IACvB,CAAC;AACD,cAAU,WAAW;AAAA,EACtB,CAAC;AAED,kCAAe,MAAM;AACpB,kBAAc,QAAQ,CAAC;AAAA,EACxB,CAAC;AAED,SAAO;AACR;;;AVjCO,SAAS,YAAY,QAAa,SAA4B;AACpE,SAAO,QAAQ,qBAAqB,OAAO;AAC5C;AAMO,SAAS,aAA0B;AACzC,QAAM,UAAM,oBAAO,mBAAmB;AACtC,MAAI,CAAC,KAAK;AACT,UAAM,IAAI;AAAA,MACT;AAAA,MACA;AAAA,MACA,EAAE,KAAK,gEAAgE;AAAA,IACxE;AAAA,EACD;AACA,SAAO;AACR;","names":["import_core","import_vue","import_store","import_vue","import_store","import_vue","import_vue","import_vue","import_store","import_vue","controller","import_sync","import_vue"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/context.ts","../src/components/kora-provider.ts","../src/resolve-query-store-cache.ts","../src/composables/use-query.ts","../src/composables/use-mutation.ts","../src/composables/use-sync-status.ts","../src/composables/use-app.ts","../src/composables/use-collection.ts","../src/composables/use-rich-text.ts","../src/composables/use-presence.ts"],"sourcesContent":["import { KoraError } from '@korajs/core'\nimport { type App, inject } from 'vue'\nimport { koraAppInjectionKey } from './context'\nimport type { KoraAppLike } from './types'\n\nexport type { KoraAppHandle, KoraAppLike, KoraContextValue, KoraProviderProps } from './types'\nexport type {\n\tUseMutationOptions,\n\tUseMutationResult,\n\tUseQueryOptions,\n\tUseRichTextResult,\n} from './types'\n\nexport { koraAppInjectionKey, koraContextKey, useKoraContext } from './context'\nexport { KoraProvider } from './components/kora-provider'\nexport { useQuery } from './composables/use-query'\nexport { useMutation } from './composables/use-mutation'\nexport { useSyncStatus } from './composables/use-sync-status'\nexport { useApp } from './composables/use-app'\nexport { useCollection } from './composables/use-collection'\nexport { useRichText } from './composables/use-rich-text'\nexport type { UseRichTextOptions } from './composables/use-rich-text'\nexport { usePresence, useCollaborators } from './composables/use-presence'\n\n/**\n * Register a Kora app on a Vue application instance.\n *\n * @deprecated Prefer {@link KoraProvider} — `installKora` does not provide reactive\n * hook context (`useQuery`, `useSyncStatus`, etc.) until you migrate to `KoraProvider`.\n */\nexport function installKora(vueApp: App, koraApp: KoraAppLike): void {\n\tvueApp.provide(koraAppInjectionKey, koraApp)\n}\n\n/**\n * Access the Kora app from a component when using {@link installKora} only.\n * For reactive hooks, use {@link useApp} inside {@link KoraProvider}.\n */\nexport function useKoraApp(): KoraAppLike {\n\tconst app = inject(koraAppInjectionKey)\n\tif (!app) {\n\t\tthrow new KoraError(\n\t\t\t'useKoraApp() requires installKora(vueApp, koraApp) or <KoraProvider :app=\"app\">.',\n\t\t\t'KORA_NOT_PROVIDED',\n\t\t\t{ fix: 'Use <KoraProvider :app=\"app\"> and useApp() for full bindings.' },\n\t\t)\n\t}\n\treturn app\n}\n","import { KoraError } from '@korajs/core'\nimport { type InjectionKey, type ShallowRef, inject } from 'vue'\nimport type { KoraAppLike, KoraContextValue } from './types'\n\nexport const koraContextKey: InjectionKey<ShallowRef<KoraContextValue | null>> =\n\tSymbol('korajs-context')\n\n/** @deprecated Use {@link koraContextKey} with {@link KoraProvider}. */\nexport const koraAppInjectionKey: InjectionKey<KoraAppLike> = Symbol('korajs-app')\n\nexport function useKoraContext(): KoraContextValue {\n\tconst contextRef = inject(koraContextKey)\n\tif (!contextRef?.value) {\n\t\tthrow new KoraError(\n\t\t\t'useKoraContext() requires <KoraProvider>. Wrap your app root with KoraProvider.',\n\t\t\t'KORA_NOT_PROVIDED',\n\t\t\t{ fix: '<KoraProvider :app=\"app\"><App /></KoraProvider>' },\n\t\t)\n\t}\n\treturn contextRef.value\n}\n","import { QueryStoreCache } from '@korajs/store'\nimport type { Store } from '@korajs/store'\nimport type { SyncEngine } from '@korajs/sync'\nimport {\n\ttype PropType,\n\ttype VNode,\n\tdefineComponent,\n\th,\n\tonScopeDispose,\n\tprovide,\n\tref,\n\tshallowRef,\n\twatch,\n} from 'vue'\nimport { koraAppInjectionKey, koraContextKey } from '../context'\nimport { resolveQueryStoreCache } from '../resolve-query-store-cache'\nimport type { KoraAppLike, KoraContextValue } from '../types'\n\nexport const KoraProvider = defineComponent({\n\tname: 'KoraProvider',\n\tprops: {\n\t\tapp: {\n\t\t\ttype: Object as PropType<KoraAppLike>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tstore: {\n\t\t\ttype: Object as PropType<Store>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tsyncEngine: {\n\t\t\ttype: Object as PropType<SyncEngine | null>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: [Object, String] as PropType<VNode | string | null>,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\tsetup(props, { slots }) {\n\t\tconst resolvedStore = ref<Store | null>(null)\n\t\tconst resolvedSync = ref<SyncEngine | null>(null)\n\t\tconst ready = ref(!props.app && Boolean(props.store))\n\t\tconst initError = ref<Error | null>(null)\n\t\tconst fallbackQueryStoreCache = new QueryStoreCache()\n\t\tconst contextRef = shallowRef<KoraContextValue | null>(null)\n\n\t\tprovide(koraContextKey, contextRef)\n\t\tif (props.app) {\n\t\t\tprovide(koraAppInjectionKey, props.app)\n\t\t}\n\n\t\twatch(\n\t\t\t() => props.app,\n\t\t\t(app, _previous, onCleanup) => {\n\t\t\t\tif (!app) {\n\t\t\t\t\tif (props.store) {\n\t\t\t\t\t\tresolvedStore.value = props.store as Store\n\t\t\t\t\t\tresolvedSync.value = (props.syncEngine ?? null) as SyncEngine | null\n\t\t\t\t\t\tready.value = true\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tready.value = false\n\t\t\t\tinitError.value = null\n\t\t\t\tlet cancelled = false\n\n\t\t\t\tapp.ready\n\t\t\t\t\t.then(() => {\n\t\t\t\t\t\tif (cancelled) return\n\t\t\t\t\t\tresolvedStore.value = app.getStore() as Store\n\t\t\t\t\t\tresolvedSync.value = app.getSyncEngine() as SyncEngine | null\n\t\t\t\t\t\tready.value = true\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\t\tif (cancelled) return\n\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error))\n\t\t\t\t\t\tconsole.error('[Kora] Initialization failed:', err)\n\t\t\t\t\t\tinitError.value = err\n\t\t\t\t\t})\n\n\t\t\t\tonCleanup(() => {\n\t\t\t\t\tcancelled = true\n\t\t\t\t})\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\twatch(\n\t\t\t() => props.store,\n\t\t\t(store) => {\n\t\t\t\tif (store && !props.app) {\n\t\t\t\t\tresolvedStore.value = store as Store\n\t\t\t\t\tresolvedSync.value = (props.syncEngine ?? null) as SyncEngine | null\n\t\t\t\t\tready.value = true\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\twatch(\n\t\t\t() => [resolvedStore.value, resolvedSync.value, props.app] as const,\n\t\t\t([store, syncEngine, app]) => {\n\t\t\t\tif (!store) {\n\t\t\t\t\tcontextRef.value = null\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tcontextRef.value = {\n\t\t\t\t\tstore: store as Store,\n\t\t\t\t\tsyncEngine: (syncEngine ?? null) as SyncEngine | null,\n\t\t\t\t\tapp: app ?? null,\n\t\t\t\t\tevents: app?.events ?? null,\n\t\t\t\t\tsubscribeSyncStatus: app?.sync?.subscribeStatus ?? null,\n\t\t\t\t\tqueryStoreCache: resolveQueryStoreCache(app, fallbackQueryStoreCache),\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\tonScopeDispose(() => {\n\t\t\tif (!props.app) {\n\t\t\t\tfallbackQueryStoreCache.clear()\n\t\t\t}\n\t\t})\n\n\t\treturn () => {\n\t\t\tif (initError.value) {\n\t\t\t\treturn h('div', { style: { color: 'red', padding: '1rem', fontFamily: 'monospace' } }, [\n\t\t\t\t\th('strong', null, 'Kora initialization error: '),\n\t\t\t\t\tinitError.value.message,\n\t\t\t\t])\n\t\t\t}\n\n\t\t\tif (!ready.value) {\n\t\t\t\treturn props.fallback ?? null\n\t\t\t}\n\n\t\t\tif (!resolvedStore.value) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'KoraProvider requires either an \"app\" or \"store\" prop. Pass createApp() or a Store instance.',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn slots.default?.()\n\t\t}\n\t},\n})\n","import type { QueryStoreCache } from '@korajs/store'\nimport type { KoraAppLike } from './types'\n\n/**\n * Resolves the per-app query cache when available, otherwise a provider-local fallback.\n */\nexport function resolveQueryStoreCache(\n\tapp: KoraAppLike | null | undefined,\n\tfallback: QueryStoreCache,\n): QueryStoreCache {\n\tif (app && typeof app.getQueryStoreCache === 'function') {\n\t\treturn app.getQueryStoreCache()\n\t}\n\treturn fallback\n}\n","import type { CollectionRecord, QueryBuilder } from '@korajs/store'\nimport { assertQueryReady } from '@korajs/store'\nimport { type DeepReadonly, type ShallowRef, readonly, shallowRef, watch } from 'vue'\nimport { useKoraContext } from '../context'\nimport type { UseQueryOptions } from '../types'\n\nconst EMPTY_ARRAY: readonly unknown[] = Object.freeze([])\n\n/**\n * Reactive query composable backed by the local Kora store.\n */\nexport function useQuery<T = CollectionRecord>(\n\tquery: QueryBuilder<T>,\n\toptions?: UseQueryOptions,\n): DeepReadonly<ShallowRef<readonly T[]>> {\n\tconst { queryStoreCache } = useKoraContext()\n\tconst enabled = options?.enabled !== false\n\tconst snapshot = shallowRef<readonly T[]>(EMPTY_ARRAY as readonly T[])\n\n\twatch(\n\t\t() => (enabled ? JSON.stringify(query.getDescriptor()) : null),\n\t\t(key, _previous, onCleanup) => {\n\t\t\tif (!key) {\n\t\t\t\tsnapshot.value = EMPTY_ARRAY as readonly T[]\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tassertQueryReady(query as QueryBuilder<unknown>)\n\t\t\tconst queryStore = queryStoreCache.getOrCreate(query)\n\t\t\tconst unsubscribe = queryStore.subscribe(() => {\n\t\t\t\tsnapshot.value = queryStore.getSnapshot()\n\t\t\t})\n\t\t\tsnapshot.value = queryStore.getSnapshot()\n\n\t\t\tonCleanup(() => {\n\t\t\t\tunsubscribe()\n\t\t\t\tqueryStoreCache.release(query as QueryBuilder<unknown>)\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n\n\treturn readonly(snapshot)\n}\n","import { createMutationController } from '@korajs/core/bindings'\nimport { onScopeDispose, ref, shallowReadonly } from 'vue'\nimport type { UseMutationOptions, UseMutationResult } from '../types'\n\n/**\n * Mutation composable with optional optimistic update and rollback hooks.\n */\nexport function useMutation<TData, TArgs extends unknown[], TContext = void>(\n\tmutationFn: (...args: TArgs) => Promise<TData>,\n\toptions?: UseMutationOptions<TData, TArgs, TContext>,\n): UseMutationResult<TData, TArgs> {\n\tconst fnRef = { current: mutationFn }\n\tfnRef.current = mutationFn\n\n\tconst optionsRef = { current: options }\n\toptionsRef.current = options\n\n\tconst isLoading = ref(false)\n\tconst error = ref<Error | null>(null)\n\tlet mounted = true\n\n\tonScopeDispose(() => {\n\t\tmounted = false\n\t})\n\n\tconst controller = createMutationController<TData, TArgs, TContext>({\n\t\tmutationFn: (...args) => fnRef.current(...args),\n\t\tresolveOptions: () => optionsRef.current,\n\t\tonStateChange: (state) => {\n\t\t\tif (!mounted) return\n\t\t\tisLoading.value = state.isLoading\n\t\t\terror.value = state.error\n\t\t},\n\t})\n\n\tisLoading.value = controller.getSnapshot().isLoading\n\terror.value = controller.getSnapshot().error\n\n\tonScopeDispose(() => {\n\t\tcontroller.destroy()\n\t})\n\n\treturn {\n\t\tmutate: (...args: TArgs) => controller.mutate(...args),\n\t\tmutateAsync: (...args: TArgs) => controller.mutateAsync(...args),\n\t\tisLoading: shallowReadonly(isLoading),\n\t\terror: shallowReadonly(error),\n\t\treset: () => controller.reset(),\n\t}\n}\n","import { OFFLINE_SYNC_STATUS, createSyncStatusController } from '@korajs/sync'\nimport { onScopeDispose, readonly, shallowRef, watchEffect } from 'vue'\nimport { useKoraContext } from '../context'\n\n/**\n * Reactive sync engine status. Updates only when status payload changes.\n */\nexport function useSyncStatus() {\n\tconst { syncEngine, subscribeSyncStatus, events } = useKoraContext()\n\tconst status = shallowRef(OFFLINE_SYNC_STATUS)\n\n\twatchEffect((onCleanup) => {\n\t\tconst controller = createSyncStatusController({\n\t\t\tsyncEngine,\n\t\t\tsubscribeSyncStatus,\n\t\t\tevents: subscribeSyncStatus ? null : events,\n\t\t})\n\t\tstatus.value = controller.getSnapshot()\n\t\tconst unsubscribe = controller.subscribe(() => {\n\t\t\tstatus.value = controller.getSnapshot()\n\t\t})\n\t\tonCleanup(() => {\n\t\t\tunsubscribe()\n\t\t\tcontroller.destroy()\n\t\t})\n\t})\n\n\treturn readonly(status)\n}\n","import { useKoraContext } from '../context'\nimport type { KoraAppLike } from '../types'\n\n/**\n * Returns the typed Kora app from {@link KoraProvider}'s `app` prop.\n */\nexport function useApp<T extends KoraAppLike = KoraAppLike>(): T {\n\tconst { app } = useKoraContext()\n\tif (!app) {\n\t\tthrow new Error(\n\t\t\t'useApp() requires <KoraProvider :app=\"app\">. Pass your createApp() result to the provider.',\n\t\t)\n\t}\n\treturn app as T\n}\n","import type { CollectionAccessor } from '@korajs/store'\nimport { useKoraContext } from '../context'\n\n/**\n * Returns a collection accessor for the given schema collection name.\n */\nexport function useCollection(name: string): CollectionAccessor {\n\tconst { store } = useKoraContext()\n\treturn store.collection(name)\n}\n","import { asRichTextSyncEngine, createRichTextController } from '@korajs/store'\nimport type { AwarenessUser } from '@korajs/sync'\nimport { reactive, shallowRef, watch } from 'vue'\nimport { useKoraContext } from '../context'\nimport type { UseRichTextResult } from '../types'\n\nexport interface UseRichTextOptions {\n\tuser?: AwarenessUser\n\tuseDocChannel?: boolean\n}\n\n/**\n * Binds a richtext field to a shared Yjs document for editor integration.\n */\nexport function useRichText(\n\tcollectionName: string,\n\trecordId: string,\n\tfieldName: string,\n\toptions?: UseRichTextOptions,\n): UseRichTextResult {\n\tconst { store, syncEngine } = useKoraContext()\n\tconst controllerRef = shallowRef<ReturnType<typeof createRichTextController> | null>(null)\n\n\tconst state = reactive({\n\t\tready: false,\n\t\terror: null as Error | null,\n\t\tcanUndo: false,\n\t\tcanRedo: false,\n\t\tcursors: [] as UseRichTextResult['cursors'],\n\t})\n\n\twatch(\n\t\t() => [collectionName, recordId, fieldName, options?.useDocChannel] as const,\n\t\t([name, id, field, useDocChannel], _previous, onCleanup) => {\n\t\t\tcontrollerRef.value?.destroy()\n\n\t\t\tconst controller = createRichTextController({\n\t\t\t\tcollection: store.collection(name),\n\t\t\t\tcollectionName: name,\n\t\t\t\trecordId: id,\n\t\t\t\tfieldName: field,\n\t\t\t\tstore,\n\t\t\t\tsyncEngine: asRichTextSyncEngine(syncEngine),\n\t\t\t\tuseDocChannel,\n\t\t\t\tuser: options?.user,\n\t\t\t})\n\n\t\t\tconst syncState = (): void => {\n\t\t\t\tconst snapshot = controller.getSnapshot()\n\t\t\t\tstate.ready = snapshot.ready\n\t\t\t\tstate.error = snapshot.error\n\t\t\t\tstate.canUndo = snapshot.canUndo\n\t\t\t\tstate.canRedo = snapshot.canRedo\n\t\t\t\tstate.cursors = [...snapshot.cursors]\n\t\t\t}\n\n\t\t\tsyncState()\n\t\t\tconst unsubscribe = controller.subscribe(syncState)\n\t\t\tcontrollerRef.value = controller\n\n\t\t\tonCleanup(() => {\n\t\t\t\tunsubscribe()\n\t\t\t\tcontroller.destroy()\n\t\t\t\tif (controllerRef.value === controller) {\n\t\t\t\t\tcontrollerRef.value = null\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n\n\twatch(\n\t\t() => options?.user,\n\t\t(user) => {\n\t\t\tcontrollerRef.value?.setUser(user)\n\t\t},\n\t)\n\n\tconst controller = (): NonNullable<typeof controllerRef.value> => {\n\t\tif (!controllerRef.value) {\n\t\t\tthrow new Error('useRichText controller is not initialized')\n\t\t}\n\t\treturn controllerRef.value\n\t}\n\n\treturn {\n\t\tget doc() {\n\t\t\treturn controller().doc\n\t\t},\n\t\tget text() {\n\t\t\treturn controller().text\n\t\t},\n\t\tundo: () => controller().undo(),\n\t\tredo: () => controller().redo(),\n\t\tget ready() {\n\t\t\treturn state.ready\n\t\t},\n\t\tget error() {\n\t\t\treturn state.error\n\t\t},\n\t\tget canUndo() {\n\t\t\treturn state.canUndo\n\t\t},\n\t\tget canRedo() {\n\t\t\treturn state.canRedo\n\t\t},\n\t\tget cursors() {\n\t\t\treturn state.cursors\n\t\t},\n\t\tsetCursor: (anchor: number, head: number) => controller().setCursor(anchor, head),\n\t\tclearCursor: () => controller().clearCursor(),\n\t}\n}\n","import type { AwarenessState } from '@korajs/sync'\nimport { subscribeRemoteAwarenessStates } from '@korajs/sync'\nimport { type ShallowRef, onScopeDispose, shallowRef, watch, watchEffect } from 'vue'\nimport { useKoraContext } from '../context'\n\n/**\n * Sets the local user's collaborative presence state.\n */\nexport function usePresence(user: { name: string; color: string; avatar?: string } | null): void {\n\tconst { syncEngine } = useKoraContext()\n\n\twatch(\n\t\t() => [syncEngine, user?.name, user?.color, user?.avatar] as const,\n\t\t([engine, name, color, avatar], _prev, onCleanup) => {\n\t\t\tif (!engine || !name || !color) return\n\n\t\t\tconst awareness = engine.getAwarenessManager()\n\t\t\tawareness.setLocalState({\n\t\t\t\tuser: {\n\t\t\t\t\tname,\n\t\t\t\t\tcolor,\n\t\t\t\t\tavatar,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tonCleanup(() => {\n\t\t\t\tawareness.setLocalState(null)\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n}\n\n/**\n * Reactive list of remote collaborators' awareness states.\n */\nexport function useCollaborators(): ShallowRef<AwarenessState[]> {\n\tconst { syncEngine } = useKoraContext()\n\tconst collaborators = shallowRef<AwarenessState[]>([])\n\n\twatchEffect((onCleanup) => {\n\t\tif (!syncEngine) {\n\t\t\tcollaborators.value = []\n\t\t\treturn\n\t\t}\n\n\t\tconst awareness = syncEngine.getAwarenessManager()\n\t\tconst unsubscribe = subscribeRemoteAwarenessStates(awareness, (states) => {\n\t\t\tcollaborators.value = states\n\t\t})\n\t\tonCleanup(unsubscribe)\n\t})\n\n\tonScopeDispose(() => {\n\t\tcollaborators.value = []\n\t})\n\n\treturn collaborators\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAA0B;AAC1B,IAAAC,cAAiC;;;ACDjC,kBAA0B;AAC1B,iBAA2D;AAGpD,IAAM,iBACZ,uBAAO,g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AAgE;AAAA,IACxE;AAAA,EACD;AACA,SAAO;AACR;","names":["import_core","import_vue","import_vue","import_store","import_vue","import_vue","import_vue","import_store","import_vue","controller","import_sync","import_vue"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { VNode, InjectionKey, ShallowRef, PropType, DeepReadonly,
|
|
2
|
+
import { VNode, InjectionKey, ShallowRef, PropType, DeepReadonly, App } from 'vue';
|
|
3
3
|
import { KoraAppLike as KoraAppLike$1, KoraContextValue as KoraContextValue$1, UseMutationOptions as UseMutationOptions$1, UseMutationResultBase, UseQueryOptions as UseQueryOptions$1 } from '@korajs/core/bindings';
|
|
4
4
|
import { Store, QueryStoreCache, CollectionRecord, QueryBuilder, CollectionAccessor } from '@korajs/store';
|
|
5
5
|
import * as _korajs_sync from '@korajs/sync';
|
|
@@ -95,7 +95,7 @@ declare const KoraProvider: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
95
95
|
/**
|
|
96
96
|
* Reactive query composable backed by the local Kora store.
|
|
97
97
|
*/
|
|
98
|
-
declare function useQuery<T = CollectionRecord>(query: QueryBuilder<T>, options?: UseQueryOptions): DeepReadonly<
|
|
98
|
+
declare function useQuery<T = CollectionRecord>(query: QueryBuilder<T>, options?: UseQueryOptions): DeepReadonly<ShallowRef<readonly T[]>>;
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* Mutation composable with optional optimistic update and rollback hooks.
|
|
@@ -112,6 +112,7 @@ declare function useSyncStatus(): Readonly<vue.Ref<{
|
|
|
112
112
|
readonly lastSuccessfulPush: number | null;
|
|
113
113
|
readonly lastSuccessfulPull: number | null;
|
|
114
114
|
readonly conflicts: number;
|
|
115
|
+
readonly clockSkewMs: number | null;
|
|
115
116
|
}, {
|
|
116
117
|
readonly status: _korajs_sync.SyncStatus;
|
|
117
118
|
readonly pendingOperations: number;
|
|
@@ -119,6 +120,7 @@ declare function useSyncStatus(): Readonly<vue.Ref<{
|
|
|
119
120
|
readonly lastSuccessfulPush: number | null;
|
|
120
121
|
readonly lastSuccessfulPull: number | null;
|
|
121
122
|
readonly conflicts: number;
|
|
123
|
+
readonly clockSkewMs: number | null;
|
|
122
124
|
}>>;
|
|
123
125
|
|
|
124
126
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { VNode, InjectionKey, ShallowRef, PropType, DeepReadonly,
|
|
2
|
+
import { VNode, InjectionKey, ShallowRef, PropType, DeepReadonly, App } from 'vue';
|
|
3
3
|
import { KoraAppLike as KoraAppLike$1, KoraContextValue as KoraContextValue$1, UseMutationOptions as UseMutationOptions$1, UseMutationResultBase, UseQueryOptions as UseQueryOptions$1 } from '@korajs/core/bindings';
|
|
4
4
|
import { Store, QueryStoreCache, CollectionRecord, QueryBuilder, CollectionAccessor } from '@korajs/store';
|
|
5
5
|
import * as _korajs_sync from '@korajs/sync';
|
|
@@ -95,7 +95,7 @@ declare const KoraProvider: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
|
95
95
|
/**
|
|
96
96
|
* Reactive query composable backed by the local Kora store.
|
|
97
97
|
*/
|
|
98
|
-
declare function useQuery<T = CollectionRecord>(query: QueryBuilder<T>, options?: UseQueryOptions): DeepReadonly<
|
|
98
|
+
declare function useQuery<T = CollectionRecord>(query: QueryBuilder<T>, options?: UseQueryOptions): DeepReadonly<ShallowRef<readonly T[]>>;
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* Mutation composable with optional optimistic update and rollback hooks.
|
|
@@ -112,6 +112,7 @@ declare function useSyncStatus(): Readonly<vue.Ref<{
|
|
|
112
112
|
readonly lastSuccessfulPush: number | null;
|
|
113
113
|
readonly lastSuccessfulPull: number | null;
|
|
114
114
|
readonly conflicts: number;
|
|
115
|
+
readonly clockSkewMs: number | null;
|
|
115
116
|
}, {
|
|
116
117
|
readonly status: _korajs_sync.SyncStatus;
|
|
117
118
|
readonly pendingOperations: number;
|
|
@@ -119,6 +120,7 @@ declare function useSyncStatus(): Readonly<vue.Ref<{
|
|
|
119
120
|
readonly lastSuccessfulPush: number | null;
|
|
120
121
|
readonly lastSuccessfulPull: number | null;
|
|
121
122
|
readonly conflicts: number;
|
|
123
|
+
readonly clockSkewMs: number | null;
|
|
122
124
|
}>>;
|
|
123
125
|
|
|
124
126
|
/**
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ function useKoraContext() {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// src/components/kora-provider.ts
|
|
23
|
-
import { QueryStoreCache
|
|
23
|
+
import { QueryStoreCache } from "@korajs/store";
|
|
24
24
|
import {
|
|
25
25
|
defineComponent,
|
|
26
26
|
h,
|
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
} from "vue";
|
|
33
33
|
|
|
34
34
|
// src/resolve-query-store-cache.ts
|
|
35
|
-
import "@korajs/store";
|
|
36
35
|
function resolveQueryStoreCache(app, fallback) {
|
|
37
36
|
if (app && typeof app.getQueryStoreCache === "function") {
|
|
38
37
|
return app.getQueryStoreCache();
|
|
@@ -66,7 +65,7 @@ var KoraProvider = defineComponent({
|
|
|
66
65
|
const resolvedSync = ref(null);
|
|
67
66
|
const ready = ref(!props.app && Boolean(props.store));
|
|
68
67
|
const initError = ref(null);
|
|
69
|
-
const fallbackQueryStoreCache = new
|
|
68
|
+
const fallbackQueryStoreCache = new QueryStoreCache();
|
|
70
69
|
const contextRef = shallowRef(null);
|
|
71
70
|
provide(koraContextKey, contextRef);
|
|
72
71
|
if (props.app) {
|
|
@@ -139,11 +138,10 @@ var KoraProvider = defineComponent({
|
|
|
139
138
|
});
|
|
140
139
|
return () => {
|
|
141
140
|
if (initError.value) {
|
|
142
|
-
return h(
|
|
143
|
-
"
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
);
|
|
141
|
+
return h("div", { style: { color: "red", padding: "1rem", fontFamily: "monospace" } }, [
|
|
142
|
+
h("strong", null, "Kora initialization error: "),
|
|
143
|
+
initError.value.message
|
|
144
|
+
]);
|
|
147
145
|
}
|
|
148
146
|
if (!ready.value) {
|
|
149
147
|
return props.fallback ?? null;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/context.ts","../src/components/kora-provider.ts","../src/resolve-query-store-cache.ts","../src/composables/use-query.ts","../src/composables/use-mutation.ts","../src/composables/use-sync-status.ts","../src/composables/use-app.ts","../src/composables/use-collection.ts","../src/composables/use-rich-text.ts","../src/composables/use-presence.ts"],"sourcesContent":["import { KoraError } from '@korajs/core'\nimport { type App, inject } from 'vue'\nimport { koraAppInjectionKey } from './context'\nimport type { KoraAppLike } from './types'\n\nexport type { KoraAppHandle, KoraAppLike, KoraContextValue, KoraProviderProps } from './types'\nexport type { UseMutationOptions, UseMutationResult, UseQueryOptions, UseRichTextResult } from './types'\n\nexport { koraAppInjectionKey, koraContextKey, useKoraContext } from './context'\nexport { KoraProvider } from './components/kora-provider'\nexport { useQuery } from './composables/use-query'\nexport { useMutation } from './composables/use-mutation'\nexport { useSyncStatus } from './composables/use-sync-status'\nexport { useApp } from './composables/use-app'\nexport { useCollection } from './composables/use-collection'\nexport { useRichText } from './composables/use-rich-text'\nexport type { UseRichTextOptions } from './composables/use-rich-text'\nexport { usePresence, useCollaborators } from './composables/use-presence'\n\n/**\n * Register a Kora app on a Vue application instance.\n *\n * @deprecated Prefer {@link KoraProvider} — `installKora` does not provide reactive\n * hook context (`useQuery`, `useSyncStatus`, etc.) until you migrate to `KoraProvider`.\n */\nexport function installKora(vueApp: App, koraApp: KoraAppLike): void {\n\tvueApp.provide(koraAppInjectionKey, koraApp)\n}\n\n/**\n * Access the Kora app from a component when using {@link installKora} only.\n * For reactive hooks, use {@link useApp} inside {@link KoraProvider}.\n */\nexport function useKoraApp(): KoraAppLike {\n\tconst app = inject(koraAppInjectionKey)\n\tif (!app) {\n\t\tthrow new KoraError(\n\t\t\t'useKoraApp() requires installKora(vueApp, koraApp) or <KoraProvider :app=\"app\">.',\n\t\t\t'KORA_NOT_PROVIDED',\n\t\t\t{ fix: 'Use <KoraProvider :app=\"app\"> and useApp() for full bindings.' },\n\t\t)\n\t}\n\treturn app\n}\n","import { KoraError } from '@korajs/core'\nimport { type InjectionKey, inject, type ShallowRef } from 'vue'\nimport type { KoraAppLike, KoraContextValue } from './types'\n\nexport const koraContextKey: InjectionKey<ShallowRef<KoraContextValue | null>> =\n\tSymbol('korajs-context')\n\n/** @deprecated Use {@link koraContextKey} with {@link KoraProvider}. */\nexport const koraAppInjectionKey: InjectionKey<KoraAppLike> = Symbol('korajs-app')\n\nexport function useKoraContext(): KoraContextValue {\n\tconst contextRef = inject(koraContextKey)\n\tif (!contextRef?.value) {\n\t\tthrow new KoraError(\n\t\t\t'useKoraContext() requires <KoraProvider>. Wrap your app root with KoraProvider.',\n\t\t\t'KORA_NOT_PROVIDED',\n\t\t\t{ fix: '<KoraProvider :app=\"app\"><App /></KoraProvider>' },\n\t\t)\n\t}\n\treturn contextRef.value\n}\n","import { QueryStoreCache } from '@korajs/store'\nimport type { Store } from '@korajs/store'\nimport type { SyncEngine } from '@korajs/sync'\nimport {\n\ttype PropType,\n\ttype VNode,\n\tdefineComponent,\n\th,\n\tonScopeDispose,\n\tprovide,\n\tref,\n\tshallowRef,\n\twatch,\n} from 'vue'\nimport { koraContextKey, koraAppInjectionKey } from '../context'\nimport type { KoraAppLike, KoraContextValue } from '../types'\nimport { resolveQueryStoreCache } from '../resolve-query-store-cache'\n\nexport const KoraProvider = defineComponent({\n\tname: 'KoraProvider',\n\tprops: {\n\t\tapp: {\n\t\t\ttype: Object as PropType<KoraAppLike>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tstore: {\n\t\t\ttype: Object as PropType<Store>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tsyncEngine: {\n\t\t\ttype: Object as PropType<SyncEngine | null>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: [Object, String] as PropType<VNode | string | null>,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\tsetup(props, { slots }) {\n\t\tconst resolvedStore = ref<Store | null>(null)\n\t\tconst resolvedSync = ref<SyncEngine | null>(null)\n\t\tconst ready = ref(!props.app && Boolean(props.store))\n\t\tconst initError = ref<Error | null>(null)\n\t\tconst fallbackQueryStoreCache = new QueryStoreCache()\n\t\tconst contextRef = shallowRef<KoraContextValue | null>(null)\n\n\t\tprovide(koraContextKey, contextRef)\n\t\tif (props.app) {\n\t\t\tprovide(koraAppInjectionKey, props.app)\n\t\t}\n\n\t\twatch(\n\t\t\t() => props.app,\n\t\t\t(app, _previous, onCleanup) => {\n\t\t\t\tif (!app) {\n\t\t\t\t\tif (props.store) {\n\t\t\t\t\t\tresolvedStore.value = props.store as Store\n\t\t\t\t\t\tresolvedSync.value = (props.syncEngine ?? null) as SyncEngine | null\n\t\t\t\t\t\tready.value = true\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tready.value = false\n\t\t\t\tinitError.value = null\n\t\t\t\tlet cancelled = false\n\n\t\t\t\tapp.ready\n\t\t\t\t\t.then(() => {\n\t\t\t\t\t\tif (cancelled) return\n\t\t\t\t\t\tresolvedStore.value = app.getStore() as Store\n\t\t\t\t\t\tresolvedSync.value = app.getSyncEngine() as SyncEngine | null\n\t\t\t\t\t\tready.value = true\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\t\tif (cancelled) return\n\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error))\n\t\t\t\t\t\tconsole.error('[Kora] Initialization failed:', err)\n\t\t\t\t\t\tinitError.value = err\n\t\t\t\t\t})\n\n\t\t\t\tonCleanup(() => {\n\t\t\t\t\tcancelled = true\n\t\t\t\t})\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\twatch(\n\t\t\t() => props.store,\n\t\t\t(store) => {\n\t\t\t\tif (store && !props.app) {\n\t\t\t\t\tresolvedStore.value = store as Store\n\t\t\t\t\tresolvedSync.value = (props.syncEngine ?? null) as SyncEngine | null\n\t\t\t\t\tready.value = true\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\twatch(\n\t\t\t() => [resolvedStore.value, resolvedSync.value, props.app] as const,\n\t\t\t([store, syncEngine, app]) => {\n\t\t\t\tif (!store) {\n\t\t\t\t\tcontextRef.value = null\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tcontextRef.value = {\n\t\t\t\t\tstore: store as Store,\n\t\t\t\t\tsyncEngine: (syncEngine ?? null) as SyncEngine | null,\n\t\t\t\t\tapp: app ?? null,\n\t\t\t\t\tevents: app?.events ?? null,\n\t\t\t\t\tsubscribeSyncStatus: app?.sync?.subscribeStatus ?? null,\n\t\t\t\t\tqueryStoreCache: resolveQueryStoreCache(app, fallbackQueryStoreCache),\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\tonScopeDispose(() => {\n\t\t\tif (!props.app) {\n\t\t\t\tfallbackQueryStoreCache.clear()\n\t\t\t}\n\t\t})\n\n\t\treturn () => {\n\t\t\tif (initError.value) {\n\t\t\t\treturn h(\n\t\t\t\t\t'div',\n\t\t\t\t\t{ style: { color: 'red', padding: '1rem', fontFamily: 'monospace' } },\n\t\t\t\t\t[h('strong', null, 'Kora initialization error: '), initError.value.message],\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tif (!ready.value) {\n\t\t\t\treturn props.fallback ?? null\n\t\t\t}\n\n\t\t\tif (!resolvedStore.value) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'KoraProvider requires either an \"app\" or \"store\" prop. Pass createApp() or a Store instance.',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn slots.default?.()\n\t\t}\n\t},\n})\n","import { QueryStoreCache } from '@korajs/store'\nimport type { KoraAppLike } from '../types'\n\n/**\n * Resolves the per-app query cache when available, otherwise a provider-local fallback.\n */\nexport function resolveQueryStoreCache(\n\tapp: KoraAppLike | null | undefined,\n\tfallback: QueryStoreCache,\n): QueryStoreCache {\n\tif (app && typeof app.getQueryStoreCache === 'function') {\n\t\treturn app.getQueryStoreCache()\n\t}\n\treturn fallback\n}\n","import type { CollectionRecord, QueryBuilder } from '@korajs/store'\nimport { assertQueryReady } from '@korajs/store'\nimport { type DeepReadonly, readonly, shallowRef, watch } from 'vue'\nimport { useKoraContext } from '../context'\nimport type { UseQueryOptions } from '../types'\n\nconst EMPTY_ARRAY: readonly unknown[] = Object.freeze([])\n\n/**\n * Reactive query composable backed by the local Kora store.\n */\nexport function useQuery<T = CollectionRecord>(\n\tquery: QueryBuilder<T>,\n\toptions?: UseQueryOptions,\n): DeepReadonly<ReturnType<typeof shallowRef<readonly T[]>>> {\n\tconst { queryStoreCache } = useKoraContext()\n\tconst enabled = options?.enabled !== false\n\tconst snapshot = shallowRef<readonly T[]>(EMPTY_ARRAY as readonly T[])\n\n\twatch(\n\t\t() => (enabled ? JSON.stringify(query.getDescriptor()) : null),\n\t\t(key, _previous, onCleanup) => {\n\t\t\tif (!key) {\n\t\t\t\tsnapshot.value = EMPTY_ARRAY as readonly T[]\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tassertQueryReady(query as QueryBuilder<unknown>)\n\t\t\tconst queryStore = queryStoreCache.getOrCreate(query)\n\t\t\tconst unsubscribe = queryStore.subscribe(() => {\n\t\t\t\tsnapshot.value = queryStore.getSnapshot()\n\t\t\t})\n\t\t\tsnapshot.value = queryStore.getSnapshot()\n\n\t\t\tonCleanup(() => {\n\t\t\t\tunsubscribe()\n\t\t\t\tqueryStoreCache.release(query as QueryBuilder<unknown>)\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n\n\treturn readonly(snapshot)\n}\n","import { createMutationController } from '@korajs/core/bindings'\nimport { onScopeDispose, ref, shallowReadonly } from 'vue'\nimport type { UseMutationOptions, UseMutationResult } from '../types'\n\n/**\n * Mutation composable with optional optimistic update and rollback hooks.\n */\nexport function useMutation<TData, TArgs extends unknown[], TContext = void>(\n\tmutationFn: (...args: TArgs) => Promise<TData>,\n\toptions?: UseMutationOptions<TData, TArgs, TContext>,\n): UseMutationResult<TData, TArgs> {\n\tconst fnRef = { current: mutationFn }\n\tfnRef.current = mutationFn\n\n\tconst optionsRef = { current: options }\n\toptionsRef.current = options\n\n\tconst isLoading = ref(false)\n\tconst error = ref<Error | null>(null)\n\tlet mounted = true\n\n\tonScopeDispose(() => {\n\t\tmounted = false\n\t})\n\n\tconst controller = createMutationController<TData, TArgs, TContext>({\n\t\tmutationFn: (...args) => fnRef.current(...args),\n\t\tresolveOptions: () => optionsRef.current,\n\t\tonStateChange: (state) => {\n\t\t\tif (!mounted) return\n\t\t\tisLoading.value = state.isLoading\n\t\t\terror.value = state.error\n\t\t},\n\t})\n\n\tisLoading.value = controller.getSnapshot().isLoading\n\terror.value = controller.getSnapshot().error\n\n\tonScopeDispose(() => {\n\t\tcontroller.destroy()\n\t})\n\n\treturn {\n\t\tmutate: (...args: TArgs) => controller.mutate(...args),\n\t\tmutateAsync: (...args: TArgs) => controller.mutateAsync(...args),\n\t\tisLoading: shallowReadonly(isLoading),\n\t\terror: shallowReadonly(error),\n\t\treset: () => controller.reset(),\n\t}\n}\n","import { OFFLINE_SYNC_STATUS, createSyncStatusController } from '@korajs/sync'\nimport { onScopeDispose, readonly, shallowRef, watchEffect } from 'vue'\nimport { useKoraContext } from '../context'\n\n/**\n * Reactive sync engine status. Updates only when status payload changes.\n */\nexport function useSyncStatus() {\n\tconst { syncEngine, subscribeSyncStatus, events } = useKoraContext()\n\tconst status = shallowRef(OFFLINE_SYNC_STATUS)\n\n\twatchEffect((onCleanup) => {\n\t\tconst controller = createSyncStatusController({\n\t\t\tsyncEngine,\n\t\t\tsubscribeSyncStatus,\n\t\t\tevents: subscribeSyncStatus ? null : events,\n\t\t})\n\t\tstatus.value = controller.getSnapshot()\n\t\tconst unsubscribe = controller.subscribe(() => {\n\t\t\tstatus.value = controller.getSnapshot()\n\t\t})\n\t\tonCleanup(() => {\n\t\t\tunsubscribe()\n\t\t\tcontroller.destroy()\n\t\t})\n\t})\n\n\treturn readonly(status)\n}\n","import { useKoraContext } from '../context'\nimport type { KoraAppLike } from '../types'\n\n/**\n * Returns the typed Kora app from {@link KoraProvider}'s `app` prop.\n */\nexport function useApp<T extends KoraAppLike = KoraAppLike>(): T {\n\tconst { app } = useKoraContext()\n\tif (!app) {\n\t\tthrow new Error(\n\t\t\t'useApp() requires <KoraProvider :app=\"app\">. Pass your createApp() result to the provider.',\n\t\t)\n\t}\n\treturn app as T\n}\n","import type { CollectionAccessor } from '@korajs/store'\nimport { useKoraContext } from '../context'\n\n/**\n * Returns a collection accessor for the given schema collection name.\n */\nexport function useCollection(name: string): CollectionAccessor {\n\tconst { store } = useKoraContext()\n\treturn store.collection(name)\n}\n","import { asRichTextSyncEngine, createRichTextController } from '@korajs/store'\nimport type { AwarenessUser } from '@korajs/sync'\nimport { reactive, shallowRef, watch } from 'vue'\nimport { useKoraContext } from '../context'\nimport type { UseRichTextResult } from '../types'\n\nexport interface UseRichTextOptions {\n\tuser?: AwarenessUser\n\tuseDocChannel?: boolean\n}\n\n/**\n * Binds a richtext field to a shared Yjs document for editor integration.\n */\nexport function useRichText(\n\tcollectionName: string,\n\trecordId: string,\n\tfieldName: string,\n\toptions?: UseRichTextOptions,\n): UseRichTextResult {\n\tconst { store, syncEngine } = useKoraContext()\n\tconst controllerRef = shallowRef<ReturnType<typeof createRichTextController> | null>(null)\n\n\tconst state = reactive({\n\t\tready: false,\n\t\terror: null as Error | null,\n\t\tcanUndo: false,\n\t\tcanRedo: false,\n\t\tcursors: [] as UseRichTextResult['cursors'],\n\t})\n\n\twatch(\n\t\t() => [collectionName, recordId, fieldName, options?.useDocChannel] as const,\n\t\t([name, id, field, useDocChannel], _previous, onCleanup) => {\n\t\t\tcontrollerRef.value?.destroy()\n\n\t\t\tconst controller = createRichTextController({\n\t\t\t\tcollection: store.collection(name),\n\t\t\t\tcollectionName: name,\n\t\t\t\trecordId: id,\n\t\t\t\tfieldName: field,\n\t\t\t\tstore,\n\t\t\t\tsyncEngine: asRichTextSyncEngine(syncEngine),\n\t\t\t\tuseDocChannel,\n\t\t\t\tuser: options?.user,\n\t\t\t})\n\n\t\t\tconst syncState = (): void => {\n\t\t\t\tconst snapshot = controller.getSnapshot()\n\t\t\t\tstate.ready = snapshot.ready\n\t\t\t\tstate.error = snapshot.error\n\t\t\t\tstate.canUndo = snapshot.canUndo\n\t\t\t\tstate.canRedo = snapshot.canRedo\n\t\t\t\tstate.cursors = [...snapshot.cursors]\n\t\t\t}\n\n\t\t\tsyncState()\n\t\t\tconst unsubscribe = controller.subscribe(syncState)\n\t\t\tcontrollerRef.value = controller\n\n\t\t\tonCleanup(() => {\n\t\t\t\tunsubscribe()\n\t\t\t\tcontroller.destroy()\n\t\t\t\tif (controllerRef.value === controller) {\n\t\t\t\t\tcontrollerRef.value = null\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n\n\twatch(\n\t\t() => options?.user,\n\t\t(user) => {\n\t\t\tcontrollerRef.value?.setUser(user)\n\t\t},\n\t)\n\n\tconst controller = (): NonNullable<typeof controllerRef.value> => {\n\t\tif (!controllerRef.value) {\n\t\t\tthrow new Error('useRichText controller is not initialized')\n\t\t}\n\t\treturn controllerRef.value\n\t}\n\n\treturn {\n\t\tget doc() {\n\t\t\treturn controller().doc\n\t\t},\n\t\tget text() {\n\t\t\treturn controller().text\n\t\t},\n\t\tundo: () => controller().undo(),\n\t\tredo: () => controller().redo(),\n\t\tget ready() {\n\t\t\treturn state.ready\n\t\t},\n\t\tget error() {\n\t\t\treturn state.error\n\t\t},\n\t\tget canUndo() {\n\t\t\treturn state.canUndo\n\t\t},\n\t\tget canRedo() {\n\t\t\treturn state.canRedo\n\t\t},\n\t\tget cursors() {\n\t\t\treturn state.cursors\n\t\t},\n\t\tsetCursor: (anchor: number, head: number) => controller().setCursor(anchor, head),\n\t\tclearCursor: () => controller().clearCursor(),\n\t}\n}\n","import type { AwarenessState } from '@korajs/sync'\nimport { subscribeRemoteAwarenessStates } from '@korajs/sync'\nimport { onScopeDispose, shallowRef, watch, watchEffect, type ShallowRef } from 'vue'\nimport { useKoraContext } from '../context'\n\n/**\n * Sets the local user's collaborative presence state.\n */\nexport function usePresence(user: { name: string; color: string; avatar?: string } | null): void {\n\tconst { syncEngine } = useKoraContext()\n\n\twatch(\n\t\t() => [syncEngine, user?.name, user?.color, user?.avatar] as const,\n\t\t([engine, name, color, avatar], _prev, onCleanup) => {\n\t\t\tif (!engine || !name || !color) return\n\n\t\t\tconst awareness = engine.getAwarenessManager()\n\t\t\tawareness.setLocalState({\n\t\t\t\tuser: {\n\t\t\t\t\tname,\n\t\t\t\t\tcolor,\n\t\t\t\t\tavatar,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tonCleanup(() => {\n\t\t\t\tawareness.setLocalState(null)\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n}\n\n/**\n * Reactive list of remote collaborators' awareness states.\n */\nexport function useCollaborators(): ShallowRef<AwarenessState[]> {\n\tconst { syncEngine } = useKoraContext()\n\tconst collaborators = shallowRef<AwarenessState[]>([])\n\n\twatchEffect((onCleanup) => {\n\t\tif (!syncEngine) {\n\t\t\tcollaborators.value = []\n\t\t\treturn\n\t\t}\n\n\t\tconst awareness = syncEngine.getAwarenessManager()\n\t\tconst unsubscribe = subscribeRemoteAwarenessStates(awareness, (states) => {\n\t\t\tcollaborators.value = states\n\t\t})\n\t\tonCleanup(unsubscribe)\n\t})\n\n\tonScopeDispose(() => {\n\t\tcollaborators.value = []\n\t})\n\n\treturn collaborators\n}\n"],"mappings":";AAAA,SAAS,aAAAA,kBAAiB;AAC1B,SAAmB,UAAAC,eAAc;;;ACDjC,SAAS,iBAAiB;AAC1B,SAA4B,cAA+B;AAGp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vB,CAAC;AACD,cAAU,WAAW;AAAA,EACtB,CAAC;AAED,EAAAC,gBAAe,MAAM;AACpB,kBAAc,QAAQ,CAAC;AAAA,EACxB,CAAC;AAED,SAAO;AACR;;;AVjCO,SAAS,YAAY,QAAa,SAA4B;AACpE,SAAO,QAAQ,qBAAqB,OAAO;AAC5C;AAMO,SAAS,aAA0B;AACzC,QAAM,MAAMC,QAAO,mBAAmB;AACtC,MAAI,CAAC,KAAK;AACT,UAAM,IAAIC;AAAA,MACT;AAAA,MACA;AAAA,MACA,EAAE,KAAK,gEAAgE;AAAA,IACxE;AAAA,EACD;AACA,SAAO;AACR;","names":["KoraError","inject","QueryStoreCache","QueryStoreCache","shallowRef","watch","shallowRef","watch","onScopeDispose","ref","readonly","shallowRef","shallowRef","readonly","shallowRef","watch","shallowRef","watch","controller","onScopeDispose","shallowRef","watch","watchEffect","watch","shallowRef","watchEffect","onScopeDispose","inject","KoraError"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/context.ts","../src/components/kora-provider.ts","../src/resolve-query-store-cache.ts","../src/composables/use-query.ts","../src/composables/use-mutation.ts","../src/composables/use-sync-status.ts","../src/composables/use-app.ts","../src/composables/use-collection.ts","../src/composables/use-rich-text.ts","../src/composables/use-presence.ts"],"sourcesContent":["import { KoraError } from '@korajs/core'\nimport { type App, inject } from 'vue'\nimport { koraAppInjectionKey } from './context'\nimport type { KoraAppLike } from './types'\n\nexport type { KoraAppHandle, KoraAppLike, KoraContextValue, KoraProviderProps } from './types'\nexport type {\n\tUseMutationOptions,\n\tUseMutationResult,\n\tUseQueryOptions,\n\tUseRichTextResult,\n} from './types'\n\nexport { koraAppInjectionKey, koraContextKey, useKoraContext } from './context'\nexport { KoraProvider } from './components/kora-provider'\nexport { useQuery } from './composables/use-query'\nexport { useMutation } from './composables/use-mutation'\nexport { useSyncStatus } from './composables/use-sync-status'\nexport { useApp } from './composables/use-app'\nexport { useCollection } from './composables/use-collection'\nexport { useRichText } from './composables/use-rich-text'\nexport type { UseRichTextOptions } from './composables/use-rich-text'\nexport { usePresence, useCollaborators } from './composables/use-presence'\n\n/**\n * Register a Kora app on a Vue application instance.\n *\n * @deprecated Prefer {@link KoraProvider} — `installKora` does not provide reactive\n * hook context (`useQuery`, `useSyncStatus`, etc.) until you migrate to `KoraProvider`.\n */\nexport function installKora(vueApp: App, koraApp: KoraAppLike): void {\n\tvueApp.provide(koraAppInjectionKey, koraApp)\n}\n\n/**\n * Access the Kora app from a component when using {@link installKora} only.\n * For reactive hooks, use {@link useApp} inside {@link KoraProvider}.\n */\nexport function useKoraApp(): KoraAppLike {\n\tconst app = inject(koraAppInjectionKey)\n\tif (!app) {\n\t\tthrow new KoraError(\n\t\t\t'useKoraApp() requires installKora(vueApp, koraApp) or <KoraProvider :app=\"app\">.',\n\t\t\t'KORA_NOT_PROVIDED',\n\t\t\t{ fix: 'Use <KoraProvider :app=\"app\"> and useApp() for full bindings.' },\n\t\t)\n\t}\n\treturn app\n}\n","import { KoraError } from '@korajs/core'\nimport { type InjectionKey, type ShallowRef, inject } from 'vue'\nimport type { KoraAppLike, KoraContextValue } from './types'\n\nexport const koraContextKey: InjectionKey<ShallowRef<KoraContextValue | null>> =\n\tSymbol('korajs-context')\n\n/** @deprecated Use {@link koraContextKey} with {@link KoraProvider}. */\nexport const koraAppInjectionKey: InjectionKey<KoraAppLike> = Symbol('korajs-app')\n\nexport function useKoraContext(): KoraContextValue {\n\tconst contextRef = inject(koraContextKey)\n\tif (!contextRef?.value) {\n\t\tthrow new KoraError(\n\t\t\t'useKoraContext() requires <KoraProvider>. Wrap your app root with KoraProvider.',\n\t\t\t'KORA_NOT_PROVIDED',\n\t\t\t{ fix: '<KoraProvider :app=\"app\"><App /></KoraProvider>' },\n\t\t)\n\t}\n\treturn contextRef.value\n}\n","import { QueryStoreCache } from '@korajs/store'\nimport type { Store } from '@korajs/store'\nimport type { SyncEngine } from '@korajs/sync'\nimport {\n\ttype PropType,\n\ttype VNode,\n\tdefineComponent,\n\th,\n\tonScopeDispose,\n\tprovide,\n\tref,\n\tshallowRef,\n\twatch,\n} from 'vue'\nimport { koraAppInjectionKey, koraContextKey } from '../context'\nimport { resolveQueryStoreCache } from '../resolve-query-store-cache'\nimport type { KoraAppLike, KoraContextValue } from '../types'\n\nexport const KoraProvider = defineComponent({\n\tname: 'KoraProvider',\n\tprops: {\n\t\tapp: {\n\t\t\ttype: Object as PropType<KoraAppLike>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tstore: {\n\t\t\ttype: Object as PropType<Store>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tsyncEngine: {\n\t\t\ttype: Object as PropType<SyncEngine | null>,\n\t\t\tdefault: undefined,\n\t\t},\n\t\tfallback: {\n\t\t\ttype: [Object, String] as PropType<VNode | string | null>,\n\t\t\tdefault: null,\n\t\t},\n\t},\n\tsetup(props, { slots }) {\n\t\tconst resolvedStore = ref<Store | null>(null)\n\t\tconst resolvedSync = ref<SyncEngine | null>(null)\n\t\tconst ready = ref(!props.app && Boolean(props.store))\n\t\tconst initError = ref<Error | null>(null)\n\t\tconst fallbackQueryStoreCache = new QueryStoreCache()\n\t\tconst contextRef = shallowRef<KoraContextValue | null>(null)\n\n\t\tprovide(koraContextKey, contextRef)\n\t\tif (props.app) {\n\t\t\tprovide(koraAppInjectionKey, props.app)\n\t\t}\n\n\t\twatch(\n\t\t\t() => props.app,\n\t\t\t(app, _previous, onCleanup) => {\n\t\t\t\tif (!app) {\n\t\t\t\t\tif (props.store) {\n\t\t\t\t\t\tresolvedStore.value = props.store as Store\n\t\t\t\t\t\tresolvedSync.value = (props.syncEngine ?? null) as SyncEngine | null\n\t\t\t\t\t\tready.value = true\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tready.value = false\n\t\t\t\tinitError.value = null\n\t\t\t\tlet cancelled = false\n\n\t\t\t\tapp.ready\n\t\t\t\t\t.then(() => {\n\t\t\t\t\t\tif (cancelled) return\n\t\t\t\t\t\tresolvedStore.value = app.getStore() as Store\n\t\t\t\t\t\tresolvedSync.value = app.getSyncEngine() as SyncEngine | null\n\t\t\t\t\t\tready.value = true\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\t\tif (cancelled) return\n\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error))\n\t\t\t\t\t\tconsole.error('[Kora] Initialization failed:', err)\n\t\t\t\t\t\tinitError.value = err\n\t\t\t\t\t})\n\n\t\t\t\tonCleanup(() => {\n\t\t\t\t\tcancelled = true\n\t\t\t\t})\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\twatch(\n\t\t\t() => props.store,\n\t\t\t(store) => {\n\t\t\t\tif (store && !props.app) {\n\t\t\t\t\tresolvedStore.value = store as Store\n\t\t\t\t\tresolvedSync.value = (props.syncEngine ?? null) as SyncEngine | null\n\t\t\t\t\tready.value = true\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\twatch(\n\t\t\t() => [resolvedStore.value, resolvedSync.value, props.app] as const,\n\t\t\t([store, syncEngine, app]) => {\n\t\t\t\tif (!store) {\n\t\t\t\t\tcontextRef.value = null\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tcontextRef.value = {\n\t\t\t\t\tstore: store as Store,\n\t\t\t\t\tsyncEngine: (syncEngine ?? null) as SyncEngine | null,\n\t\t\t\t\tapp: app ?? null,\n\t\t\t\t\tevents: app?.events ?? null,\n\t\t\t\t\tsubscribeSyncStatus: app?.sync?.subscribeStatus ?? null,\n\t\t\t\t\tqueryStoreCache: resolveQueryStoreCache(app, fallbackQueryStoreCache),\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ immediate: true },\n\t\t)\n\n\t\tonScopeDispose(() => {\n\t\t\tif (!props.app) {\n\t\t\t\tfallbackQueryStoreCache.clear()\n\t\t\t}\n\t\t})\n\n\t\treturn () => {\n\t\t\tif (initError.value) {\n\t\t\t\treturn h('div', { style: { color: 'red', padding: '1rem', fontFamily: 'monospace' } }, [\n\t\t\t\t\th('strong', null, 'Kora initialization error: '),\n\t\t\t\t\tinitError.value.message,\n\t\t\t\t])\n\t\t\t}\n\n\t\t\tif (!ready.value) {\n\t\t\t\treturn props.fallback ?? null\n\t\t\t}\n\n\t\t\tif (!resolvedStore.value) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'KoraProvider requires either an \"app\" or \"store\" prop. Pass createApp() or a Store instance.',\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn slots.default?.()\n\t\t}\n\t},\n})\n","import type { QueryStoreCache } from '@korajs/store'\nimport type { KoraAppLike } from './types'\n\n/**\n * Resolves the per-app query cache when available, otherwise a provider-local fallback.\n */\nexport function resolveQueryStoreCache(\n\tapp: KoraAppLike | null | undefined,\n\tfallback: QueryStoreCache,\n): QueryStoreCache {\n\tif (app && typeof app.getQueryStoreCache === 'function') {\n\t\treturn app.getQueryStoreCache()\n\t}\n\treturn fallback\n}\n","import type { CollectionRecord, QueryBuilder } from '@korajs/store'\nimport { assertQueryReady } from '@korajs/store'\nimport { type DeepReadonly, type ShallowRef, readonly, shallowRef, watch } from 'vue'\nimport { useKoraContext } from '../context'\nimport type { UseQueryOptions } from '../types'\n\nconst EMPTY_ARRAY: readonly unknown[] = Object.freeze([])\n\n/**\n * Reactive query composable backed by the local Kora store.\n */\nexport function useQuery<T = CollectionRecord>(\n\tquery: QueryBuilder<T>,\n\toptions?: UseQueryOptions,\n): DeepReadonly<ShallowRef<readonly T[]>> {\n\tconst { queryStoreCache } = useKoraContext()\n\tconst enabled = options?.enabled !== false\n\tconst snapshot = shallowRef<readonly T[]>(EMPTY_ARRAY as readonly T[])\n\n\twatch(\n\t\t() => (enabled ? JSON.stringify(query.getDescriptor()) : null),\n\t\t(key, _previous, onCleanup) => {\n\t\t\tif (!key) {\n\t\t\t\tsnapshot.value = EMPTY_ARRAY as readonly T[]\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tassertQueryReady(query as QueryBuilder<unknown>)\n\t\t\tconst queryStore = queryStoreCache.getOrCreate(query)\n\t\t\tconst unsubscribe = queryStore.subscribe(() => {\n\t\t\t\tsnapshot.value = queryStore.getSnapshot()\n\t\t\t})\n\t\t\tsnapshot.value = queryStore.getSnapshot()\n\n\t\t\tonCleanup(() => {\n\t\t\t\tunsubscribe()\n\t\t\t\tqueryStoreCache.release(query as QueryBuilder<unknown>)\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n\n\treturn readonly(snapshot)\n}\n","import { createMutationController } from '@korajs/core/bindings'\nimport { onScopeDispose, ref, shallowReadonly } from 'vue'\nimport type { UseMutationOptions, UseMutationResult } from '../types'\n\n/**\n * Mutation composable with optional optimistic update and rollback hooks.\n */\nexport function useMutation<TData, TArgs extends unknown[], TContext = void>(\n\tmutationFn: (...args: TArgs) => Promise<TData>,\n\toptions?: UseMutationOptions<TData, TArgs, TContext>,\n): UseMutationResult<TData, TArgs> {\n\tconst fnRef = { current: mutationFn }\n\tfnRef.current = mutationFn\n\n\tconst optionsRef = { current: options }\n\toptionsRef.current = options\n\n\tconst isLoading = ref(false)\n\tconst error = ref<Error | null>(null)\n\tlet mounted = true\n\n\tonScopeDispose(() => {\n\t\tmounted = false\n\t})\n\n\tconst controller = createMutationController<TData, TArgs, TContext>({\n\t\tmutationFn: (...args) => fnRef.current(...args),\n\t\tresolveOptions: () => optionsRef.current,\n\t\tonStateChange: (state) => {\n\t\t\tif (!mounted) return\n\t\t\tisLoading.value = state.isLoading\n\t\t\terror.value = state.error\n\t\t},\n\t})\n\n\tisLoading.value = controller.getSnapshot().isLoading\n\terror.value = controller.getSnapshot().error\n\n\tonScopeDispose(() => {\n\t\tcontroller.destroy()\n\t})\n\n\treturn {\n\t\tmutate: (...args: TArgs) => controller.mutate(...args),\n\t\tmutateAsync: (...args: TArgs) => controller.mutateAsync(...args),\n\t\tisLoading: shallowReadonly(isLoading),\n\t\terror: shallowReadonly(error),\n\t\treset: () => controller.reset(),\n\t}\n}\n","import { OFFLINE_SYNC_STATUS, createSyncStatusController } from '@korajs/sync'\nimport { onScopeDispose, readonly, shallowRef, watchEffect } from 'vue'\nimport { useKoraContext } from '../context'\n\n/**\n * Reactive sync engine status. Updates only when status payload changes.\n */\nexport function useSyncStatus() {\n\tconst { syncEngine, subscribeSyncStatus, events } = useKoraContext()\n\tconst status = shallowRef(OFFLINE_SYNC_STATUS)\n\n\twatchEffect((onCleanup) => {\n\t\tconst controller = createSyncStatusController({\n\t\t\tsyncEngine,\n\t\t\tsubscribeSyncStatus,\n\t\t\tevents: subscribeSyncStatus ? null : events,\n\t\t})\n\t\tstatus.value = controller.getSnapshot()\n\t\tconst unsubscribe = controller.subscribe(() => {\n\t\t\tstatus.value = controller.getSnapshot()\n\t\t})\n\t\tonCleanup(() => {\n\t\t\tunsubscribe()\n\t\t\tcontroller.destroy()\n\t\t})\n\t})\n\n\treturn readonly(status)\n}\n","import { useKoraContext } from '../context'\nimport type { KoraAppLike } from '../types'\n\n/**\n * Returns the typed Kora app from {@link KoraProvider}'s `app` prop.\n */\nexport function useApp<T extends KoraAppLike = KoraAppLike>(): T {\n\tconst { app } = useKoraContext()\n\tif (!app) {\n\t\tthrow new Error(\n\t\t\t'useApp() requires <KoraProvider :app=\"app\">. Pass your createApp() result to the provider.',\n\t\t)\n\t}\n\treturn app as T\n}\n","import type { CollectionAccessor } from '@korajs/store'\nimport { useKoraContext } from '../context'\n\n/**\n * Returns a collection accessor for the given schema collection name.\n */\nexport function useCollection(name: string): CollectionAccessor {\n\tconst { store } = useKoraContext()\n\treturn store.collection(name)\n}\n","import { asRichTextSyncEngine, createRichTextController } from '@korajs/store'\nimport type { AwarenessUser } from '@korajs/sync'\nimport { reactive, shallowRef, watch } from 'vue'\nimport { useKoraContext } from '../context'\nimport type { UseRichTextResult } from '../types'\n\nexport interface UseRichTextOptions {\n\tuser?: AwarenessUser\n\tuseDocChannel?: boolean\n}\n\n/**\n * Binds a richtext field to a shared Yjs document for editor integration.\n */\nexport function useRichText(\n\tcollectionName: string,\n\trecordId: string,\n\tfieldName: string,\n\toptions?: UseRichTextOptions,\n): UseRichTextResult {\n\tconst { store, syncEngine } = useKoraContext()\n\tconst controllerRef = shallowRef<ReturnType<typeof createRichTextController> | null>(null)\n\n\tconst state = reactive({\n\t\tready: false,\n\t\terror: null as Error | null,\n\t\tcanUndo: false,\n\t\tcanRedo: false,\n\t\tcursors: [] as UseRichTextResult['cursors'],\n\t})\n\n\twatch(\n\t\t() => [collectionName, recordId, fieldName, options?.useDocChannel] as const,\n\t\t([name, id, field, useDocChannel], _previous, onCleanup) => {\n\t\t\tcontrollerRef.value?.destroy()\n\n\t\t\tconst controller = createRichTextController({\n\t\t\t\tcollection: store.collection(name),\n\t\t\t\tcollectionName: name,\n\t\t\t\trecordId: id,\n\t\t\t\tfieldName: field,\n\t\t\t\tstore,\n\t\t\t\tsyncEngine: asRichTextSyncEngine(syncEngine),\n\t\t\t\tuseDocChannel,\n\t\t\t\tuser: options?.user,\n\t\t\t})\n\n\t\t\tconst syncState = (): void => {\n\t\t\t\tconst snapshot = controller.getSnapshot()\n\t\t\t\tstate.ready = snapshot.ready\n\t\t\t\tstate.error = snapshot.error\n\t\t\t\tstate.canUndo = snapshot.canUndo\n\t\t\t\tstate.canRedo = snapshot.canRedo\n\t\t\t\tstate.cursors = [...snapshot.cursors]\n\t\t\t}\n\n\t\t\tsyncState()\n\t\t\tconst unsubscribe = controller.subscribe(syncState)\n\t\t\tcontrollerRef.value = controller\n\n\t\t\tonCleanup(() => {\n\t\t\t\tunsubscribe()\n\t\t\t\tcontroller.destroy()\n\t\t\t\tif (controllerRef.value === controller) {\n\t\t\t\t\tcontrollerRef.value = null\n\t\t\t\t}\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n\n\twatch(\n\t\t() => options?.user,\n\t\t(user) => {\n\t\t\tcontrollerRef.value?.setUser(user)\n\t\t},\n\t)\n\n\tconst controller = (): NonNullable<typeof controllerRef.value> => {\n\t\tif (!controllerRef.value) {\n\t\t\tthrow new Error('useRichText controller is not initialized')\n\t\t}\n\t\treturn controllerRef.value\n\t}\n\n\treturn {\n\t\tget doc() {\n\t\t\treturn controller().doc\n\t\t},\n\t\tget text() {\n\t\t\treturn controller().text\n\t\t},\n\t\tundo: () => controller().undo(),\n\t\tredo: () => controller().redo(),\n\t\tget ready() {\n\t\t\treturn state.ready\n\t\t},\n\t\tget error() {\n\t\t\treturn state.error\n\t\t},\n\t\tget canUndo() {\n\t\t\treturn state.canUndo\n\t\t},\n\t\tget canRedo() {\n\t\t\treturn state.canRedo\n\t\t},\n\t\tget cursors() {\n\t\t\treturn state.cursors\n\t\t},\n\t\tsetCursor: (anchor: number, head: number) => controller().setCursor(anchor, head),\n\t\tclearCursor: () => controller().clearCursor(),\n\t}\n}\n","import type { AwarenessState } from '@korajs/sync'\nimport { subscribeRemoteAwarenessStates } from '@korajs/sync'\nimport { type ShallowRef, onScopeDispose, shallowRef, watch, watchEffect } from 'vue'\nimport { useKoraContext } from '../context'\n\n/**\n * Sets the local user's collaborative presence state.\n */\nexport function usePresence(user: { name: string; color: string; avatar?: string } | null): void {\n\tconst { syncEngine } = useKoraContext()\n\n\twatch(\n\t\t() => [syncEngine, user?.name, user?.color, user?.avatar] as const,\n\t\t([engine, name, color, avatar], _prev, onCleanup) => {\n\t\t\tif (!engine || !name || !color) return\n\n\t\t\tconst awareness = engine.getAwarenessManager()\n\t\t\tawareness.setLocalState({\n\t\t\t\tuser: {\n\t\t\t\t\tname,\n\t\t\t\t\tcolor,\n\t\t\t\t\tavatar,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tonCleanup(() => {\n\t\t\t\tawareness.setLocalState(null)\n\t\t\t})\n\t\t},\n\t\t{ immediate: true },\n\t)\n}\n\n/**\n * Reactive list of remote collaborators' awareness states.\n */\nexport function useCollaborators(): ShallowRef<AwarenessState[]> {\n\tconst { syncEngine } = useKoraContext()\n\tconst collaborators = shallowRef<AwarenessState[]>([])\n\n\twatchEffect((onCleanup) => {\n\t\tif (!syncEngine) {\n\t\t\tcollaborators.value = []\n\t\t\treturn\n\t\t}\n\n\t\tconst awareness = syncEngine.getAwarenessManager()\n\t\tconst unsubscribe = subscribeRemoteAwarenessStates(awareness, (states) => {\n\t\t\tcollaborators.value = states\n\t\t})\n\t\tonCleanup(unsubscribe)\n\t})\n\n\tonScopeDispose(() => {\n\t\tcollaborators.value = []\n\t})\n\n\treturn collaborators\n}\n"],"mappings":";AAAA,SAAS,aAAAA,kBAAiB;AAC1B,SAAmB,UAAAC,eAAc;;;ACDjC,SAAS,iBAAiB;AAC1B,SAA6C,cAAc;AAGpD,IAAM,iBACZ,uBAAO,gBAAgB;AAGjB,IAAM,sBAAiD,uBAAO,YAAY;AAE1E,SAAS,iBAAmC;AAClD,QAAM,aAAa,OAAO,cAAc;AACxC,MAAI,CAAC,YAAY,OAAO;AACvB,UAAM,IAAI;AAAA,MACT;AAAA,MACA;AAAA,MACA,EAAE,KAAK,kDAAkD;AAAA,IAC1D;AAAA,EACD;AACA,SAAO,WAAW;AACnB;;;ACpBA,SAAS,uBAAuB;AAGhC;AAAA,EAGC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;;;ACPA,SAAS,uBACf,KACA,UACkB;AAClB,MAAI,OAAO,OAAO,IAAI,uBAAuB,YAAY;AACxD,WAAO,IAAI,mBAAmB;AAAA,EAC/B;AACA,SAAO;AACR;;;ADIO,IAAM,eAAe,gBAAgB;AAAA,EAC3C,MAAM;AAAA,EACN,OAAO;AAAA,IACN,KAAK;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,UAAU;AAAA,MACT,MAAM,CAAC,QAAQ,MAAM;AAA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AAAA,MAC7B,CAAC;AAAA,IACF;AAAA,IACA,EAAE,WAAW,KAAK;AAAA,EACnB;AACD;AAKO,SAAS,mBAAiD;AAChE,QAAM,EAAE,WAAW,IAAI,eAAe;AACtC,QAAM,gBAAgBC,YAA6B,CAAC,CAAC;AAErD,EAAAC,aAAY,CAAC,cAAc;AAC1B,QAAI,CAAC,YAAY;AAChB,oBAAc,QAAQ,CAAC;AACvB;AAAA,IACD;AAEA,UAAM,YAAY,WAAW,oBAAoB;AACjD,UAAM,cAAc,+BAA+B,WAAW,CAAC,WAAW;AACzE,oBAAc,QAAQ;AAAA,IACvB,CAAC;AACD,cAAU,WAAW;AAAA,EACtB,CAAC;AAED,EAAAC,gBAAe,MAAM;AACpB,kBAAc,QAAQ,CAAC;AAAA,EACxB,CAAC;AAED,SAAO;AACR;;;AV5BO,SAAS,YAAY,QAAa,SAA4B;AACpE,SAAO,QAAQ,qBAAqB,OAAO;AAC5C;AAMO,SAAS,aAA0B;AACzC,QAAM,MAAMC,QAAO,mBAAmB;AACtC,MAAI,CAAC,KAAK;AACT,UAAM,IAAIC;AAAA,MACT;AAAA,MACA;AAAA,MACA,EAAE,KAAK,gEAAgE;AAAA,IACxE;AAAA,EACD;AACA,SAAO;AACR;","names":["KoraError","inject","shallowRef","watch","shallowRef","watch","onScopeDispose","ref","readonly","shallowRef","shallowRef","readonly","shallowRef","watch","shallowRef","watch","controller","onScopeDispose","shallowRef","watch","watchEffect","watch","shallowRef","watchEffect","onScopeDispose","inject","KoraError"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@korajs/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
4
|
"description": "Kora.js Vue 3 composables for offline-first applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"yjs": "^13.6.30",
|
|
29
|
-
"@korajs/core": "0.
|
|
30
|
-
"@korajs/
|
|
31
|
-
"@korajs/
|
|
29
|
+
"@korajs/core": "1.0.0-beta.0",
|
|
30
|
+
"@korajs/sync": "1.0.0-beta.0",
|
|
31
|
+
"@korajs/store": "1.0.0-beta.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@vue/test-utils": "^2.4.6",
|