@lunora/vue 1.0.0-alpha.10 → 1.0.0-alpha.11
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/dist/index.d.mts +37 -4
- package/dist/index.d.ts +37 -4
- package/dist/index.mjs +1 -0
- package/dist/packem_shared/useMutator-B_Ahs_ZN.mjs +19 -0
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Component, Ref, InjectionKey, App, DeepReadonly, MaybeRefOrGetter,
|
|
2
|
-
import { Preloaded, LunoraClient, User, ConnectionStatus, FunctionReference, ReturnOf, ArgsOf, MutationCallOptions } from '@lunora/client';
|
|
3
|
-
export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe, User } from '@lunora/client';
|
|
1
|
+
import { Component, Ref, InjectionKey, App, DeepReadonly, MaybeRefOrGetter, ComputedRef, ShallowRef } from 'vue';
|
|
2
|
+
import { Preloaded, LunoraClient, User, ConnectionStatus, FunctionReference, ReturnOf, ArgsOf, MutationCallOptions, MutatorHandle } from '@lunora/client';
|
|
3
|
+
export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe, User } from '@lunora/client';
|
|
4
4
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
5
|
export type { PaginationResult, PaginationStatus } from '@lunora/client/pagination';
|
|
6
6
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
@@ -172,6 +172,39 @@ interface MutationHandle<F extends FunctionReference> {
|
|
|
172
172
|
* adapter-specific.
|
|
173
173
|
*/
|
|
174
174
|
declare const useMutation: <F extends FunctionReference>(function_: F) => MutationHandle<F>;
|
|
175
|
+
/**
|
|
176
|
+
* The reactive handle returned by {@link useMutator} — the Vue counterpart to
|
|
177
|
+
* `@lunora/react`'s `useMutator`, re-expressed with refs. The surface is
|
|
178
|
+
* identical across the Lunora adapters (`@lunora/solid`, `/svelte`):
|
|
179
|
+
* `error`/`isError`/`pending` are refs you read in a template and `mutate` is an
|
|
180
|
+
* awaitable that resolves once the write is persisted (or rejects).
|
|
181
|
+
*/
|
|
182
|
+
interface MutatorHook<TArgs> {
|
|
183
|
+
/** The latest invocation's error, or `undefined`. */
|
|
184
|
+
error: Ref<Error | undefined>;
|
|
185
|
+
/** `true` when the latest invocation rejected. */
|
|
186
|
+
isError: ComputedRef<boolean>;
|
|
187
|
+
/** Run the mutator; resolves once the write is persisted, rejects on failure. */
|
|
188
|
+
mutate: (args: TArgs) => Promise<void>;
|
|
189
|
+
/** `true` while ANY invocation from this handle is in flight (ref-counted, so overlapping calls compose). */
|
|
190
|
+
pending: Ref<boolean>;
|
|
191
|
+
/** Clear the latest `error` back to idle. */
|
|
192
|
+
reset: () => void;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Ergonomic `{ mutate, pending, error, isError, reset }` wrapper over a bound
|
|
196
|
+
* custom-mutator handle from `@lunora/db`'s `bindMutators` — the Vue equivalent
|
|
197
|
+
* of `@lunora/react`'s `useMutator`. The optimistic overlay and
|
|
198
|
+
* server-authoritative push are owned by the bound handle (and TanStack DB's
|
|
199
|
+
* optimistic-transaction layer rebases pending overlays on every sync tick);
|
|
200
|
+
* this composable only surfaces reactive state for the in-flight/error
|
|
201
|
+
* lifecycle. Reads stay on the existing TanStack `useLiveQuery`; no new query
|
|
202
|
+
* composable is needed.
|
|
203
|
+
*
|
|
204
|
+
* `pending` is ref-counted across overlapping invocations of THIS handle, so it
|
|
205
|
+
* clears only once every concurrent call has settled.
|
|
206
|
+
*/
|
|
207
|
+
declare const useMutator: <TArgs = Record<string, unknown>>(handle: MutatorHandle<TArgs>) => MutatorHook<TArgs>;
|
|
175
208
|
/** The args a paginated query exposes minus the framework-supplied page cursor. */
|
|
176
209
|
type PaginatedArgs<F extends FunctionReference> = Omit<ArgsOf<F>, "paginationOpts">;
|
|
177
210
|
/** The element type of the `page` array a paginated query returns. */
|
|
@@ -381,4 +414,4 @@ interface UseSubscriptionResult<T> {
|
|
|
381
414
|
* high-frequency streams.
|
|
382
415
|
*/
|
|
383
416
|
declare const useSubscription: <F extends FunctionReference>(function_: F, args: MaybeRefOrGetter<ArgsOf<F> | "skip">, options?: UseQueryOptions) => UseSubscriptionResult<ReturnOf<F>>;
|
|
384
|
-
export { AuthLoading, Authenticated, type FlagContext, type FlagValue, type HeartbeatReference, LUNORA_INJECTION_KEY, type ListPresentReference, type MutationHandle, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseSubscriptionResult, createLunora, hydratePreloaded, provideLunora, subscribeToQuery, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery, useLunora, useMutation, usePaginatedQuery, usePresence, useQuery, useRateLimit, useSubscription };
|
|
417
|
+
export { AuthLoading, Authenticated, type FlagContext, type FlagValue, type HeartbeatReference, LUNORA_INJECTION_KEY, type ListPresentReference, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseSubscriptionResult, createLunora, hydratePreloaded, provideLunora, subscribeToQuery, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery, useLunora, useMutation, useMutator, usePaginatedQuery, usePresence, useQuery, useRateLimit, useSubscription };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Component, Ref, InjectionKey, App, DeepReadonly, MaybeRefOrGetter,
|
|
2
|
-
import { Preloaded, LunoraClient, User, ConnectionStatus, FunctionReference, ReturnOf, ArgsOf, MutationCallOptions } from '@lunora/client';
|
|
3
|
-
export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe, User } from '@lunora/client';
|
|
1
|
+
import { Component, Ref, InjectionKey, App, DeepReadonly, MaybeRefOrGetter, ComputedRef, ShallowRef } from 'vue';
|
|
2
|
+
import { Preloaded, LunoraClient, User, ConnectionStatus, FunctionReference, ReturnOf, ArgsOf, MutationCallOptions, MutatorHandle } from '@lunora/client';
|
|
3
|
+
export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe, User } from '@lunora/client';
|
|
4
4
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
5
|
export type { PaginationResult, PaginationStatus } from '@lunora/client/pagination';
|
|
6
6
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
@@ -172,6 +172,39 @@ interface MutationHandle<F extends FunctionReference> {
|
|
|
172
172
|
* adapter-specific.
|
|
173
173
|
*/
|
|
174
174
|
declare const useMutation: <F extends FunctionReference>(function_: F) => MutationHandle<F>;
|
|
175
|
+
/**
|
|
176
|
+
* The reactive handle returned by {@link useMutator} — the Vue counterpart to
|
|
177
|
+
* `@lunora/react`'s `useMutator`, re-expressed with refs. The surface is
|
|
178
|
+
* identical across the Lunora adapters (`@lunora/solid`, `/svelte`):
|
|
179
|
+
* `error`/`isError`/`pending` are refs you read in a template and `mutate` is an
|
|
180
|
+
* awaitable that resolves once the write is persisted (or rejects).
|
|
181
|
+
*/
|
|
182
|
+
interface MutatorHook<TArgs> {
|
|
183
|
+
/** The latest invocation's error, or `undefined`. */
|
|
184
|
+
error: Ref<Error | undefined>;
|
|
185
|
+
/** `true` when the latest invocation rejected. */
|
|
186
|
+
isError: ComputedRef<boolean>;
|
|
187
|
+
/** Run the mutator; resolves once the write is persisted, rejects on failure. */
|
|
188
|
+
mutate: (args: TArgs) => Promise<void>;
|
|
189
|
+
/** `true` while ANY invocation from this handle is in flight (ref-counted, so overlapping calls compose). */
|
|
190
|
+
pending: Ref<boolean>;
|
|
191
|
+
/** Clear the latest `error` back to idle. */
|
|
192
|
+
reset: () => void;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Ergonomic `{ mutate, pending, error, isError, reset }` wrapper over a bound
|
|
196
|
+
* custom-mutator handle from `@lunora/db`'s `bindMutators` — the Vue equivalent
|
|
197
|
+
* of `@lunora/react`'s `useMutator`. The optimistic overlay and
|
|
198
|
+
* server-authoritative push are owned by the bound handle (and TanStack DB's
|
|
199
|
+
* optimistic-transaction layer rebases pending overlays on every sync tick);
|
|
200
|
+
* this composable only surfaces reactive state for the in-flight/error
|
|
201
|
+
* lifecycle. Reads stay on the existing TanStack `useLiveQuery`; no new query
|
|
202
|
+
* composable is needed.
|
|
203
|
+
*
|
|
204
|
+
* `pending` is ref-counted across overlapping invocations of THIS handle, so it
|
|
205
|
+
* clears only once every concurrent call has settled.
|
|
206
|
+
*/
|
|
207
|
+
declare const useMutator: <TArgs = Record<string, unknown>>(handle: MutatorHandle<TArgs>) => MutatorHook<TArgs>;
|
|
175
208
|
/** The args a paginated query exposes minus the framework-supplied page cursor. */
|
|
176
209
|
type PaginatedArgs<F extends FunctionReference> = Omit<ArgsOf<F>, "paginationOpts">;
|
|
177
210
|
/** The element type of the `page` array a paginated query returns. */
|
|
@@ -381,4 +414,4 @@ interface UseSubscriptionResult<T> {
|
|
|
381
414
|
* high-frequency streams.
|
|
382
415
|
*/
|
|
383
416
|
declare const useSubscription: <F extends FunctionReference>(function_: F, args: MaybeRefOrGetter<ArgsOf<F> | "skip">, options?: UseQueryOptions) => UseSubscriptionResult<ReturnOf<F>>;
|
|
384
|
-
export { AuthLoading, Authenticated, type FlagContext, type FlagValue, type HeartbeatReference, LUNORA_INJECTION_KEY, type ListPresentReference, type MutationHandle, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseSubscriptionResult, createLunora, hydratePreloaded, provideLunora, subscribeToQuery, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery, useLunora, useMutation, usePaginatedQuery, usePresence, useQuery, useRateLimit, useSubscription };
|
|
417
|
+
export { AuthLoading, Authenticated, type FlagContext, type FlagValue, type HeartbeatReference, LUNORA_INJECTION_KEY, type ListPresentReference, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, type UseInfiniteQueryOptions, type UseInfiniteQueryResult, type UsePaginatedQueryOptions, type UsePaginatedQueryResult, type UsePresenceOptions, type UsePresenceResult, type UseQueryOptions, type UseRateLimitOptions, type UseRateLimitResult, type UseSubscriptionResult, createLunora, hydratePreloaded, provideLunora, subscribeToQuery, useAuth, useConnectionStatus, useFlag, useFlags, useInfiniteQuery, useLunora, useMutation, useMutator, usePaginatedQuery, usePresence, useQuery, useRateLimit, useSubscription };
|
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ export { useAuth } from './packem_shared/useAuth-C2aEzXXH.mjs';
|
|
|
5
5
|
export { default as useConnectionStatus } from './packem_shared/useConnectionStatus-CDgduQYe.mjs';
|
|
6
6
|
export { useFlag, useFlags } from './packem_shared/useFlag-yTJu5_q7.mjs';
|
|
7
7
|
export { useMutation } from './packem_shared/useMutation-DWubV5pv.mjs';
|
|
8
|
+
export { useMutator } from './packem_shared/useMutator-B_Ahs_ZN.mjs';
|
|
8
9
|
export { useInfiniteQuery, usePaginatedQuery } from './packem_shared/useInfiniteQuery-CEfbw7Nw.mjs';
|
|
9
10
|
export { usePresence } from './packem_shared/usePresence-BeN5xaZM.mjs';
|
|
10
11
|
export { subscribeToQuery, useQuery } from './packem_shared/subscribeToQuery-Cv5YL-SI.mjs';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createMutatorRunner } from '@lunora/client';
|
|
2
|
+
import { shallowRef, computed } from 'vue';
|
|
3
|
+
|
|
4
|
+
const useMutator = (handle) => {
|
|
5
|
+
const error = shallowRef(void 0);
|
|
6
|
+
const pending = shallowRef(false);
|
|
7
|
+
const isError = computed(() => error.value !== void 0);
|
|
8
|
+
const { mutate, reset } = createMutatorRunner(handle, {
|
|
9
|
+
setError: (value) => {
|
|
10
|
+
error.value = value;
|
|
11
|
+
},
|
|
12
|
+
setPending: (value) => {
|
|
13
|
+
pending.value = value;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return { error, isError, mutate, pending, reset };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { useMutator };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/vue",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.11",
|
|
4
4
|
"description": "Vue adapter for Lunora — live composables, optimistic mutations, and reactive loaders",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/client": "1.0.0-alpha.
|
|
57
|
+
"@lunora/client": "1.0.0-alpha.5",
|
|
58
58
|
"@lunora/ratelimit": "1.0.0-alpha.3",
|
|
59
|
-
"@lunora/runtime": "1.0.0-alpha.
|
|
59
|
+
"@lunora/runtime": "1.0.0-alpha.8"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"vue": "^3.5.0"
|