@lunora/vue 1.0.0-alpha.101 → 1.0.0-alpha.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -16
- package/dist/index.d.mts +41 -17
- package/dist/index.d.ts +41 -17
- package/dist/index.mjs +1 -1
- package/dist/packem_shared/{hydratePreloaded-kyzbcRHO.mjs → hydratePreloaded-BtfKkWB8.mjs} +1 -1
- package/dist/packem_shared/subscribeToQuery-CHbbz_3v.mjs +1 -0
- package/dist/packem_shared/useAgentChat-BZBKErKQ.mjs +1 -0
- package/dist/packem_shared/useFlag-xVfWC_c6.mjs +1 -0
- package/dist/packem_shared/useInfiniteQuery-Dr8XgbH7.mjs +1 -0
- package/package.json +4 -4
- package/dist/packem_shared/stable-key-B_BlboiY.mjs +0 -1
- package/dist/packem_shared/subscribeToQuery-DPfbYx11.mjs +0 -1
- package/dist/packem_shared/useAgentChat-C3Q3Wf5w.mjs +0 -1
- package/dist/packem_shared/useFlag-_IYnlB1G.mjs +0 -1
- package/dist/packem_shared/useInfiniteQuery-BRhjOdWk.mjs +0 -1
package/README.md
CHANGED
|
@@ -74,22 +74,26 @@ const { mutate, pending } = useMutation(api.messages.send);
|
|
|
74
74
|
|
|
75
75
|
## API
|
|
76
76
|
|
|
77
|
-
| Composable | React equivalent | Description
|
|
78
|
-
| --------------------- | --------------------- |
|
|
79
|
-
| `createLunora` | `LunoraProvider` | Vue plugin — call `app.use(createLunora(client))` at the app root.
|
|
80
|
-
| `useLunora` | `useLunora` | Inject the ambient `LunoraClient` from the nearest provider.
|
|
81
|
-
| `useQuery` | `useQuery` | Live query `ShallowRef` — re-subscribes when reactive args change.
|
|
82
|
-
| `useMutation` | `useMutation` | Optimistic mutation handle (`data`, `error`, `pending`, `mutate`, `reset`).
|
|
83
|
-
| `useSubscription` | `useSubscription` | Raw subscription `ShallowRef` — unbounded live stream.
|
|
84
|
-
| `usePaginatedQuery` | `usePaginatedQuery` | Cursor-paginated query with `loadMore`, `status`, and `results`.
|
|
85
|
-
| `useInfiniteQuery` | `useInfiniteQuery` | Infinite-scroll variant of `usePaginatedQuery`.
|
|
86
|
-
| `useAuth` | `useAuth` | Reactive auth: readonly `token`/`user` refs plus `setToken`.
|
|
87
|
-
| `usePresence` | `usePresence` | Collaborative-awareness — heartbeat + live present-members `ShallowRef`.
|
|
88
|
-
| `useFlag` | `useFlag` | Live OpenFeature flag as a readonly `Ref` — holds `default` until resolved.
|
|
89
|
-
| `useFlags` | `useFlags` | Batch variant — a readonly `Ref` of one value per key in the defaults map.
|
|
90
|
-
| `useRateLimit` | `useRateLimit` | Client-side rate-limit mirror — `ok`, `disabled`, `retryAfter` as ComputedRefs.
|
|
91
|
-
| `useConnectionStatus` | `useConnectionStatus` | Reactive connection state (`idle`, `connecting`, `connected`, `offline`).
|
|
92
|
-
| `hydratePreloaded` | `usePreloadedQuery` | Seed a query synchronously from an SSR `Preloaded` token, then go live.
|
|
77
|
+
| Composable | React equivalent | Description |
|
|
78
|
+
| --------------------- | --------------------- | --------------------------------------------------------------------------------- |
|
|
79
|
+
| `createLunora` | `LunoraProvider` | Vue plugin — call `app.use(createLunora(client))` at the app root. |
|
|
80
|
+
| `useLunora` | `useLunora` | Inject the ambient `LunoraClient` from the nearest provider. |
|
|
81
|
+
| `useQuery` | `useQuery` | Live query `ShallowRef` — re-subscribes when reactive args change. |
|
|
82
|
+
| `useMutation` | `useMutation` | Optimistic mutation handle (`data`, `error`, `pending`, `mutate`, `reset`). |
|
|
83
|
+
| `useSubscription` | `useSubscription` | Raw subscription `ShallowRef` — unbounded live stream. |
|
|
84
|
+
| `usePaginatedQuery` | `usePaginatedQuery` | Cursor-paginated query with `loadMore`, `status`, and `results`. |
|
|
85
|
+
| `useInfiniteQuery` | `useInfiniteQuery` | Infinite-scroll variant of `usePaginatedQuery`. |
|
|
86
|
+
| `useAuth` | `useAuth` | Reactive auth: readonly `token`/`user` refs plus `setToken`. |
|
|
87
|
+
| `usePresence` | `usePresence` | Collaborative-awareness — heartbeat + live present-members `ShallowRef`. |
|
|
88
|
+
| `useFlag` | `useFlag` | Live OpenFeature flag as a readonly `Ref` — holds `default` until resolved. |
|
|
89
|
+
| `useFlags` | `useFlags` | Batch variant — a readonly `Ref` of one value per key in the defaults map. |
|
|
90
|
+
| `useRateLimit` | `useRateLimit` | Client-side rate-limit mirror — `ok`, `disabled`, `retryAfter` as ComputedRefs. |
|
|
91
|
+
| `useConnectionStatus` | `useConnectionStatus` | Reactive connection state (`idle`, `connecting`, `connected`, `offline`). |
|
|
92
|
+
| `hydratePreloaded` | `usePreloadedQuery` | Seed a query synchronously from an SSR `Preloaded` token, then go live. |
|
|
93
|
+
| `useAgentToolEvents` | `useAgentToolEvents` | One agent thread's tool lifecycle as a `ComputedRef` of discriminated events. |
|
|
94
|
+
| `useVoiceAgent` | `useVoiceAgent` | Full-duplex voice call — refs for status/transcript/level, `startCall`/`endCall`. |
|
|
95
|
+
|
|
96
|
+
`useVoiceAgent` opens nothing until `startCall()` — that call is what requests the microphone, so it must run from a user gesture. `endCall()` releases the socket, the mic tracks and the Web Audio graph, and `onScopeDispose` runs it for you on unmount.
|
|
93
97
|
|
|
94
98
|
## Related
|
|
95
99
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, Ref, InjectionKey, App, MaybeRefOrGetter, ComputedRef, DeepReadonly, ShallowRef } from 'vue';
|
|
2
|
-
import { Preloaded, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle } from '@lunora/client';
|
|
3
|
-
export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe, User } from '@lunora/client';
|
|
2
|
+
import { Preloaded, LunoraClient, SubscriptionErrorCallback, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle } from '@lunora/client';
|
|
3
|
+
export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, 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';
|
|
@@ -32,8 +32,15 @@ declare const AuthLoading: Component;
|
|
|
32
32
|
*
|
|
33
33
|
* The subscription tears down with the surrounding effect scope (component
|
|
34
34
|
* unmount or `effectScope().stop()`), inherited from `subscribeToQuery`.
|
|
35
|
+
*
|
|
36
|
+
* The ref is `Ref<T>`, not `Ref<T | undefined>`: `subscribeToQuery`'s ref widens
|
|
37
|
+
* to `undefined` because it also serves the unseeded `useQuery` case, but this
|
|
38
|
+
* entry point always passes `seed: preloaded.value`, so the "seeded
|
|
39
|
+
* synchronously, no loading flash" contract means it is never undefined. Every
|
|
40
|
+
* other adapter's `hydratePreloaded` returns `T`; narrowing here stops Vue
|
|
41
|
+
* consumers guarding a state that cannot occur.
|
|
35
42
|
*/
|
|
36
|
-
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Ref<T
|
|
43
|
+
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Ref<T>;
|
|
37
44
|
/**
|
|
38
45
|
* Injection key carrying the {@link LunoraClient} down the component tree.
|
|
39
46
|
* Exported so advanced consumers can inject it by hand; most apps use
|
|
@@ -69,6 +76,12 @@ declare const provideLunora: (client: LunoraClient) => void;
|
|
|
69
76
|
declare const useLunora: () => LunoraClient;
|
|
70
77
|
/** Options shared by the live-query composables. */
|
|
71
78
|
interface UseQueryOptions {
|
|
79
|
+
/**
|
|
80
|
+
* Called when the server pushes a subscription-scoped error (an RLS denial, a
|
|
81
|
+
* query that starts failing server-side). Without a handler such an error has
|
|
82
|
+
* nowhere to go and the ref simply freezes at its last good value.
|
|
83
|
+
*/
|
|
84
|
+
onError?: SubscriptionErrorCallback;
|
|
72
85
|
/** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
|
|
73
86
|
shardKey?: string;
|
|
74
87
|
}
|
|
@@ -544,8 +557,6 @@ declare const useAuth: () => UseAuthResult;
|
|
|
544
557
|
* Call inside `setup()` / an active effect scope.
|
|
545
558
|
*/
|
|
546
559
|
declare const useConnectionStatus: () => Readonly<Ref<ConnectionStatus>>;
|
|
547
|
-
/** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
|
|
548
|
-
type FlagContext = Record<string, unknown>;
|
|
549
560
|
/** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
|
|
550
561
|
type FlagValue = boolean | number | string | {
|
|
551
562
|
[key: string]: unknown;
|
|
@@ -559,27 +570,36 @@ type FlagValue = boolean | number | string | {
|
|
|
559
570
|
* from `defaultValue`'s runtime type, so `useFlag("dark", false)` reads a boolean
|
|
560
571
|
* and `useFlag("hero", "control")` a string.
|
|
561
572
|
*
|
|
562
|
-
* `key`
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
573
|
+
* `key` may be a plain value, a `ref`, or a getter: passing a reactive source
|
|
574
|
+
* makes the subscription reactive — when it changes the old subscription is torn
|
|
575
|
+
* down and a fresh one opens.
|
|
576
|
+
*
|
|
577
|
+
* The reactive channel is public, so the server evaluates every flag under the
|
|
578
|
+
* socket's own verified identity — the targeting key your `defineFlags({
|
|
579
|
+
* identify })` derives — and accepts no client-supplied targeting context. For
|
|
580
|
+
* evaluation under a context you compute, call `ctx.flags.*` inside a query,
|
|
581
|
+
* mutation, or action and return the resolved value.
|
|
566
582
|
*
|
|
567
583
|
* Evaluation runs through whatever OpenFeature provider the app wired in
|
|
568
584
|
* `lunora/flags.ts`; the read never throws — a provider error resolves the
|
|
569
|
-
* default (the same fail-open contract as server-side `ctx.flags`)
|
|
570
|
-
*
|
|
585
|
+
* default (the same fail-open contract as server-side `ctx.flags`) — both an
|
|
586
|
+
* attach throw and a provider error pushed mid-session. Call inside `setup()`
|
|
587
|
+
* (or any active effect scope); the subscription tears down on unmount. During
|
|
588
|
+
* SSR no subscription opens at all and the ref stays at `defaultValue`.
|
|
571
589
|
*/
|
|
572
|
-
declare const useFlag: <T extends FlagValue>(key: MaybeRefOrGetter<string>, defaultValue: T
|
|
590
|
+
declare const useFlag: <T extends FlagValue>(key: MaybeRefOrGetter<string>, defaultValue: T) => Readonly<Ref<T>>;
|
|
573
591
|
/**
|
|
574
592
|
* Subscribe to several feature flags at once, live over Lunora's WebSocket.
|
|
575
593
|
*
|
|
576
594
|
* Pass a record of `key → defaultValue`; each flag's kind is inferred from its
|
|
577
595
|
* default, and the returned `ref` holds the same-shaped record with resolved
|
|
578
|
-
* values (the defaults until each evaluation lands).
|
|
579
|
-
*
|
|
580
|
-
*
|
|
596
|
+
* values (the defaults until each evaluation lands). This is the batched form of
|
|
597
|
+
* {@link useFlag} — one subscription per key, torn down together when the
|
|
598
|
+
* enclosing effect scope stops. Like {@link useFlag} it evaluates under the
|
|
599
|
+
* socket's server-verified identity only. The flag set is fixed for the
|
|
600
|
+
* composable's lifetime, so nothing here is reactive.
|
|
581
601
|
*/
|
|
582
|
-
declare const useFlags: <T extends Record<string, FlagValue>>(flags: T
|
|
602
|
+
declare const useFlags: <T extends Record<string, FlagValue>>(flags: T) => Readonly<Ref<T>>;
|
|
583
603
|
/**
|
|
584
604
|
* The reactive handle returned by {@link useMutation} — the Vue counterpart to
|
|
585
605
|
* React's `useMutation`, re-expressed with refs. The surface is identical across
|
|
@@ -808,6 +828,10 @@ declare const subscribeToQuery: <F extends FunctionReference, T = ReturnOf<F>>(c
|
|
|
808
828
|
*
|
|
809
829
|
* Call inside `setup()` (or any active effect scope). For SSR seeding with no
|
|
810
830
|
* loading flash, use `hydratePreloaded` instead.
|
|
831
|
+
*
|
|
832
|
+
* Pass `onError` to surface a subscription-scoped error the server pushes (an RLS
|
|
833
|
+
* denial, a query that starts failing server-side). Without it such an error is
|
|
834
|
+
* dropped and the ref just freezes at its last good value.
|
|
811
835
|
*/
|
|
812
836
|
declare const useQuery: <F extends FunctionReference>(function_: F, args: MaybeRefOrGetter<ArgsOf<F> | "skip">, options?: UseQueryOptions) => Ref<ReturnOf<F> | undefined>;
|
|
813
837
|
interface UseRateLimitOptions {
|
|
@@ -1032,7 +1056,7 @@ interface UseVoiceAgentResult {
|
|
|
1032
1056
|
* `createSocket`) so the composable is drivable outside a browser.
|
|
1033
1057
|
*/
|
|
1034
1058
|
declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
|
|
1035
|
-
export { type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type
|
|
1059
|
+
export { type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type FlagValue, type HeartbeatReference,
|
|
1036
1060
|
/**
|
|
1037
1061
|
* `@lunora/vue` — the Vue adapter for Lunora.
|
|
1038
1062
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, Ref, InjectionKey, App, MaybeRefOrGetter, ComputedRef, DeepReadonly, ShallowRef } from 'vue';
|
|
2
|
-
import { Preloaded, LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle } from '@lunora/client';
|
|
3
|
-
export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe, User } from '@lunora/client';
|
|
2
|
+
import { Preloaded, LunoraClient, SubscriptionErrorCallback, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle } from '@lunora/client';
|
|
3
|
+
export type { ArgsOf, FunctionReference, LunoraClient, MutationCallOptions, MutatorHandle, MutatorTransaction, OptimisticLocalStore, OptimisticUpdate, Preloaded, ReturnOf, SubscriptionError, SubscriptionErrorCallback, 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';
|
|
@@ -32,8 +32,15 @@ declare const AuthLoading: Component;
|
|
|
32
32
|
*
|
|
33
33
|
* The subscription tears down with the surrounding effect scope (component
|
|
34
34
|
* unmount or `effectScope().stop()`), inherited from `subscribeToQuery`.
|
|
35
|
+
*
|
|
36
|
+
* The ref is `Ref<T>`, not `Ref<T | undefined>`: `subscribeToQuery`'s ref widens
|
|
37
|
+
* to `undefined` because it also serves the unseeded `useQuery` case, but this
|
|
38
|
+
* entry point always passes `seed: preloaded.value`, so the "seeded
|
|
39
|
+
* synchronously, no loading flash" contract means it is never undefined. Every
|
|
40
|
+
* other adapter's `hydratePreloaded` returns `T`; narrowing here stops Vue
|
|
41
|
+
* consumers guarding a state that cannot occur.
|
|
35
42
|
*/
|
|
36
|
-
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Ref<T
|
|
43
|
+
declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Ref<T>;
|
|
37
44
|
/**
|
|
38
45
|
* Injection key carrying the {@link LunoraClient} down the component tree.
|
|
39
46
|
* Exported so advanced consumers can inject it by hand; most apps use
|
|
@@ -69,6 +76,12 @@ declare const provideLunora: (client: LunoraClient) => void;
|
|
|
69
76
|
declare const useLunora: () => LunoraClient;
|
|
70
77
|
/** Options shared by the live-query composables. */
|
|
71
78
|
interface UseQueryOptions {
|
|
79
|
+
/**
|
|
80
|
+
* Called when the server pushes a subscription-scoped error (an RLS denial, a
|
|
81
|
+
* query that starts failing server-side). Without a handler such an error has
|
|
82
|
+
* nowhere to go and the ref simply freezes at its last good value.
|
|
83
|
+
*/
|
|
84
|
+
onError?: SubscriptionErrorCallback;
|
|
72
85
|
/** Route to a specific shard when the target function is `.shardBy(...)`-partitioned. */
|
|
73
86
|
shardKey?: string;
|
|
74
87
|
}
|
|
@@ -544,8 +557,6 @@ declare const useAuth: () => UseAuthResult;
|
|
|
544
557
|
* Call inside `setup()` / an active effect scope.
|
|
545
558
|
*/
|
|
546
559
|
declare const useConnectionStatus: () => Readonly<Ref<ConnectionStatus>>;
|
|
547
|
-
/** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
|
|
548
|
-
type FlagContext = Record<string, unknown>;
|
|
549
560
|
/** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
|
|
550
561
|
type FlagValue = boolean | number | string | {
|
|
551
562
|
[key: string]: unknown;
|
|
@@ -559,27 +570,36 @@ type FlagValue = boolean | number | string | {
|
|
|
559
570
|
* from `defaultValue`'s runtime type, so `useFlag("dark", false)` reads a boolean
|
|
560
571
|
* and `useFlag("hero", "control")` a string.
|
|
561
572
|
*
|
|
562
|
-
* `key`
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
573
|
+
* `key` may be a plain value, a `ref`, or a getter: passing a reactive source
|
|
574
|
+
* makes the subscription reactive — when it changes the old subscription is torn
|
|
575
|
+
* down and a fresh one opens.
|
|
576
|
+
*
|
|
577
|
+
* The reactive channel is public, so the server evaluates every flag under the
|
|
578
|
+
* socket's own verified identity — the targeting key your `defineFlags({
|
|
579
|
+
* identify })` derives — and accepts no client-supplied targeting context. For
|
|
580
|
+
* evaluation under a context you compute, call `ctx.flags.*` inside a query,
|
|
581
|
+
* mutation, or action and return the resolved value.
|
|
566
582
|
*
|
|
567
583
|
* Evaluation runs through whatever OpenFeature provider the app wired in
|
|
568
584
|
* `lunora/flags.ts`; the read never throws — a provider error resolves the
|
|
569
|
-
* default (the same fail-open contract as server-side `ctx.flags`)
|
|
570
|
-
*
|
|
585
|
+
* default (the same fail-open contract as server-side `ctx.flags`) — both an
|
|
586
|
+
* attach throw and a provider error pushed mid-session. Call inside `setup()`
|
|
587
|
+
* (or any active effect scope); the subscription tears down on unmount. During
|
|
588
|
+
* SSR no subscription opens at all and the ref stays at `defaultValue`.
|
|
571
589
|
*/
|
|
572
|
-
declare const useFlag: <T extends FlagValue>(key: MaybeRefOrGetter<string>, defaultValue: T
|
|
590
|
+
declare const useFlag: <T extends FlagValue>(key: MaybeRefOrGetter<string>, defaultValue: T) => Readonly<Ref<T>>;
|
|
573
591
|
/**
|
|
574
592
|
* Subscribe to several feature flags at once, live over Lunora's WebSocket.
|
|
575
593
|
*
|
|
576
594
|
* Pass a record of `key → defaultValue`; each flag's kind is inferred from its
|
|
577
595
|
* default, and the returned `ref` holds the same-shaped record with resolved
|
|
578
|
-
* values (the defaults until each evaluation lands).
|
|
579
|
-
*
|
|
580
|
-
*
|
|
596
|
+
* values (the defaults until each evaluation lands). This is the batched form of
|
|
597
|
+
* {@link useFlag} — one subscription per key, torn down together when the
|
|
598
|
+
* enclosing effect scope stops. Like {@link useFlag} it evaluates under the
|
|
599
|
+
* socket's server-verified identity only. The flag set is fixed for the
|
|
600
|
+
* composable's lifetime, so nothing here is reactive.
|
|
581
601
|
*/
|
|
582
|
-
declare const useFlags: <T extends Record<string, FlagValue>>(flags: T
|
|
602
|
+
declare const useFlags: <T extends Record<string, FlagValue>>(flags: T) => Readonly<Ref<T>>;
|
|
583
603
|
/**
|
|
584
604
|
* The reactive handle returned by {@link useMutation} — the Vue counterpart to
|
|
585
605
|
* React's `useMutation`, re-expressed with refs. The surface is identical across
|
|
@@ -808,6 +828,10 @@ declare const subscribeToQuery: <F extends FunctionReference, T = ReturnOf<F>>(c
|
|
|
808
828
|
*
|
|
809
829
|
* Call inside `setup()` (or any active effect scope). For SSR seeding with no
|
|
810
830
|
* loading flash, use `hydratePreloaded` instead.
|
|
831
|
+
*
|
|
832
|
+
* Pass `onError` to surface a subscription-scoped error the server pushes (an RLS
|
|
833
|
+
* denial, a query that starts failing server-side). Without it such an error is
|
|
834
|
+
* dropped and the ref just freezes at its last good value.
|
|
811
835
|
*/
|
|
812
836
|
declare const useQuery: <F extends FunctionReference>(function_: F, args: MaybeRefOrGetter<ArgsOf<F> | "skip">, options?: UseQueryOptions) => Ref<ReturnOf<F> | undefined>;
|
|
813
837
|
interface UseRateLimitOptions {
|
|
@@ -1032,7 +1056,7 @@ interface UseVoiceAgentResult {
|
|
|
1032
1056
|
* `createSocket`) so the composable is drivable outside a browser.
|
|
1033
1057
|
*/
|
|
1034
1058
|
declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
|
|
1035
|
-
export { type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type
|
|
1059
|
+
export { type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type FlagValue, type HeartbeatReference,
|
|
1036
1060
|
/**
|
|
1037
1061
|
* `@lunora/vue` — the Vue adapter for Lunora.
|
|
1038
1062
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AuthLoading as r,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-nfI43dvD.mjs";import{hydratePreloaded as a}from"./packem_shared/hydratePreloaded-
|
|
1
|
+
import{AuthLoading as r,Authenticated as t,Unauthenticated as u}from"./packem_shared/AuthLoading-nfI43dvD.mjs";import{hydratePreloaded as a}from"./packem_shared/hydratePreloaded-BtfKkWB8.mjs";import{LUNORA_INJECTION_KEY as f,createLunora as m,provideLunora as p,useLunora as x}from"./packem_shared/LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{useAction as A}from"./packem_shared/useAction-C4VLsh4M.mjs";import{useAgent as d}from"./packem_shared/useAgent-Bji8ptsw.mjs";import{useAgentChat as h}from"./packem_shared/useAgentChat-BZBKErKQ.mjs";import{useAgentState as l}from"./packem_shared/useAgentState-B_LPf5ZX.mjs";import{useAgentToolEvents as Q}from"./packem_shared/useAgentToolEvents-DYYeyrXW.mjs";import{useAuth as b}from"./packem_shared/useAuth-DJ9902_4.mjs";import{default as E}from"./packem_shared/useConnectionStatus-BSFJBnmi.mjs";import{useFlag as N,useFlags as P}from"./packem_shared/useFlag-xVfWC_c6.mjs";import{useMutation as v}from"./packem_shared/useMutation-D6PkaNaE.mjs";import{useMutator as M}from"./packem_shared/useMutator-CO7nXlRf.mjs";import{useInfiniteQuery as R,usePaginatedQuery as U}from"./packem_shared/useInfiniteQuery-Dr8XgbH7.mjs";import{usePresence as J}from"./packem_shared/usePresence-D5H9k1UX.mjs";import{subscribeToQuery as V,useQuery as Y}from"./packem_shared/subscribeToQuery-CHbbz_3v.mjs";import{useRateLimit as k}from"./packem_shared/useRateLimit-zoPsflSG.mjs";import{useStream as w}from"./packem_shared/useStream-pSLl_8ix.mjs";import{useSubscription as B}from"./packem_shared/useSubscription-uZqOa1Pu.mjs";import{useVoiceAgent as G}from"./packem_shared/useVoiceAgent-CR6Tyf_3.mjs";export{r as AuthLoading,t as Authenticated,f as LUNORA_INJECTION_KEY,u as Unauthenticated,m as createLunora,a as hydratePreloaded,p as provideLunora,V as subscribeToQuery,A as useAction,d as useAgent,h as useAgentChat,l as useAgentState,Q as useAgentToolEvents,b as useAuth,E as useConnectionStatus,N as useFlag,P as useFlags,R as useInfiniteQuery,x as useLunora,v as useMutation,M as useMutator,U as usePaginatedQuery,J as usePresence,Y as useQuery,k as useRateLimit,w as useStream,B as useSubscription,G as useVoiceAgent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLunora as s}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{subscribeToQuery as u}from"./subscribeToQuery-
|
|
1
|
+
import{useLunora as s}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{subscribeToQuery as u}from"./subscribeToQuery-CHbbz_3v.mjs";const d=e=>{const r=s(),{args:n,functionPath:o,shardKey:t,value:c}=e;return u(r,{__lunoraRef:o},n,{seed:c,shardKey:t})};export{d as hydratePreloaded};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createQuerySubscription as b}from"@lunora/client/query";import{shallowRef as i,watch as f,toValue as p}from"vue";import{i as n}from"./is-browser-BEdfLJHK.mjs";import{useLunora as l}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as y}from"./scope-dispose-Mq3k4nvP.mjs";const D=(s,t,e,o={})=>{const r=i(o.seed);if(n()){const a=s.subscribe(t,e,u=>{r.value=u},{shardKey:o.shardKey});y(a)}return r},E=(s,t,e={})=>{const o=l(),r=i(void 0);return f(()=>p(t),(a,u,c)=>{if(!n())return;const m=b(o,s,a,{onData:d=>{r.value=d},onError:e.onError,onReset:()=>{r.value=void 0}},{shardKey:e.shardKey});c(m)},{immediate:!0}),r};export{D as subscribeToQuery,E as useQuery};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{reconcileOptimistic as y,maxSeq as A}from"@lunora/client";import{ref as D,watch as N,toValue as s,computed as c}from"vue";import{NO_MUTATION_REF as F}from"./useAgent-Bji8ptsw.mjs";import{useMutation as m}from"./useMutation-D6PkaNaE.mjs";import{useStream as U}from"./useStream-pSLl_8ix.mjs";import{useSubscription as w}from"./useSubscription-uZqOa1Pu.mjs";const V={__lunoraRef:""},W=R=>{const{api:u,cancel:v,limit:p,send:k,sendArgs:x,stream:h,threadKey:a}=R,{data:I}=w(u.agents.agentMessages,()=>{const t=s(a);return p===void 0?{key:t}:{key:t,limit:p}}),{data:M}=w(u.agents.agentThread,()=>({key:s(a)})),S=h===void 0?"skip":()=>({key:s(a)}),{chunks:_}=U(h??V,S),b=m(k),K=m(v??F),T=m(u.agents.agentResolveApproval),r=D([]);let f=0;N(()=>s(a),()=>{r.value=[]});const l=c(()=>M.value),j=c(()=>l.value?.status),i=c(()=>I.value??[]),q=c(()=>{const t=i.value,n=y(r.value,t);if(n.length===0)return t;const e=A(t);return[...t,...n.map((o,d)=>({content:o.content,optimistic:!0,role:"user",seq:e+1+d}))]}),E=c(()=>{const t=s(a),n=i.value.filter(e=>e.role==="assistant").length;return _.value.filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=n).map(e=>e.text).join("")}),O=async(t,n)=>{const e=f;f+=1;const o=A(i.value);r.value=[...y(r.value,i.value),{content:t,id:e,maxDurableSeqAtSend:o}];try{await b.mutate({input:t,threadKey:s(a),...x,...n})}catch(d){throw r.value=r.value.filter(C=>C.id!==e),d}},g=async(t,n,e)=>{const o=l.value?.instanceId;if(o===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await T.mutate({decision:t,instanceId:o,threadKey:s(a),toolCallId:n,...e===void 0?{}:{note:e}})};return{approve:async(t,n)=>g("approve",t,n),cancel:async()=>{const t=l.value?.instanceId;v===void 0||t===void 0||await K.mutate({instanceId:t,threadKey:s(a)})},messages:q,reject:async(t,n)=>g("reject",t,n),send:O,status:j,streamingText:E}};export{W as useAgentChat};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowRef as c,watch as b,toValue as m}from"vue";import{i as a}from"./is-browser-BEdfLJHK.mjs";import{useLunora as l}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as p}from"./scope-dispose-Mq3k4nvP.mjs";const _="__lunora_flags__:eval",d=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:_},i=(t,e,r)=>{try{return t.subscribe(v,{default:e.default,key:e.key,type:d(e.default)},o=>{r(o)},{onError:()=>{r(e.default)}})}catch{return()=>{}}},g=(t,e)=>{const r=l(),o=c(e);return b(()=>m(t),(n,u,s)=>{o.value=e,a()&&s(i(r,{default:e,key:n},f=>{o.value=f}))},{immediate:!0}),o},w=t=>{const e=l(),r=c(t);if(!a())return r;const o=[];for(const[n,u]of Object.entries(t))o.push(i(e,{default:u,key:n},s=>{r.value={...r.value,[n]:s}}));return p(()=>{for(const n of o)n()}),r};export{g as useFlag,w as useFlags};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{shallowRef as E,watch as _,toValue as N,onScopeDispose as V,computed as L}from"vue";import{initialPages as D,derivePaginationStatus as T,rebalance as q,applyLoadMore as z}from"@lunora/client/pagination";import{i as G}from"./is-browser-BEdfLJHK.mjs";import{useLunora as H}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const X=/["\\\u0000-\u001F\uD800-\uDFFF]/,U=e=>X.test(e)?JSON.stringify(e):`"${e}"`,x=e=>{if(e===void 0)return"null";if(typeof e=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof e=="number"){if(Number.isNaN(e))return"nan";if(e===1/0)return"inf";if(e===-1/0)return"-inf";if(Object.is(e,-0))return"-0"}if(typeof e=="string")return U(e);if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e)){let n="[";for(let o=0;o<e.length;o++)o>0&&(n+=","),n+=x(e[o]);return n+"]"}const r=Object.getPrototypeOf(e);if(r!==null&&r!==Object.prototype){const n=e.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${n} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const l=e,u=Object.keys(l).sort();let i="{",t=!0;for(const n of u){const o=l[n];o!==void 0&&(t?t=!1:i+=",",i+=U(n),i+=":",i+=x(o))}return i+"}"},F=e=>{let r="";for(let u=0;u<e.length;u+=32768)r+=String.fromCharCode(...e.subarray(u,u+32768));return btoa(r)},y="$lunora.wire$",J=64,Y="__proto__",Z=e=>{if(e===null||typeof e!="object")return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype},S=(e,r=0)=>{if(r>J)throw new RangeError(`wire-codec: value nesting exceeds the ${J}-level limit`);if(e===void 0)return[y,"undefined"];if(e===null)return null;const l=typeof e;if(l==="bigint")return[y,"bigint",e.toString()];if(l==="number"){const t=e;return Number.isNaN(t)?[y,"nan"]:t===1/0?[y,"inf"]:t===-1/0?[y,"-inf"]:t}if(l!=="object")return e;if(e instanceof Date)return[y,"date",S(e.getTime(),r+1)];if(e instanceof Error){const t=e,n={};for(const p of Object.keys(t))t[p]!==void 0&&(n[p]=S(t[p],r+1));const o=[y,"error",t.name,t.message,n];return t.cause!==void 0&&o.push(S(t.cause,r+1)),o}if(e instanceof URL)return[y,"url",e.href];if(e instanceof Map)return[y,"map",[...e.entries()].map(([t,n])=>[S(t,r+1),S(n,r+1)])];if(e instanceof Set)return[y,"set",[...e].map(t=>S(t,r+1))];if(e instanceof ArrayBuffer)return[y,"bytes",F(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,n=t.constructor.name,o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return n==="Uint8Array"?[y,"bytes",F(o)]:[y,"bytes",F(o),n]}if(Array.isArray(e)){const t=e.map(n=>S(n,r+1));return t.length>0&&t[0]===y?[y,"arr",t]:t}if(!Z(e)){const t=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const u=e,i={};for(const t of Object.keys(u)){const n=u[t];if(n===void 0)continue;const o=S(n,r+1);t===Y?Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):i[t]=o}return i},W=e=>x(S(e)),O=(e,r)=>`${e}::${W(r)}`,A=(e,r)=>({...r,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),v=(e,r,l)=>{const u=H(),{initialNumItems:i,shardKey:t}=l,n=E(D(i)),o=E([]);let p;const b=new Map,g=new Map,h=new Set,K=(s,a)=>{o.value=s.map(w=>{const P=O(e.__lunoraRef,A(w,a));return g.get(P)})},Q=(s,a,w)=>{const P=c=>O(e.__lunoraRef,A(c,w));for(const c of a){const d=P(c);if(g.has(d))continue;const m=s.find(f=>f.lower===c.lower);if(m){const f=g.get(P(m));f&&g.set(d,f)}}},C=(s,a)=>{const w=new Set;for(const c of s)w.add(O(e.__lunoraRef,A(c,a)));for(const[c,d]of b)w.has(d.currentKey)||(d.unsub(),b.delete(c),g.delete(d.currentKey),h.delete(d.currentKey));const P=new Set([...b.values()].map(c=>c.currentKey));for(const c of s){const d=A(c,a),m=O(e.__lunoraRef,d);if(P.has(m))continue;const f={currentKey:m,unsub:void 0};h.add(m);const k=u.subscribe(e,d,M=>{g.set(f.currentKey,M),h.delete(f.currentKey);const R=N(r);if(K(n.value,R),h.size===0){const $=n.value,j=q($,o.value);j&&(Q($,j,R),n.value=j)}},{shardKey:t});f.unsub=k,b.set(m,f),P.add(m)}},I=()=>{for(const s of b.values())s.unsub();b.clear(),g.clear(),h.clear()};_(()=>W(N(r)),()=>{if(!G())return;const s=N(r);I(),n.value=D(i),o.value=[],p=void 0,s!=="skip"&&(C(n.value,s),K(n.value,s))},{immediate:!0}),_(()=>n.value,s=>{const a=N(r);a!=="skip"&&(C(s,a),K(s,a))}),V(I);const B=E("LoadingFirstPage");return _([()=>N(r),o],([s,a])=>{B.value=T(s==="skip",a).status},{immediate:!0}),{loadMore:s=>{const a=N(r);if(a==="skip")return;const{nextCursor:w,status:P}=T(!1,o.value);if(P!=="CanLoadMore"||w===p)return;const c=z(n.value,w,s);if(!c)return;p=w;const d=n.value.at(-1),m=c.at(-2);if(d&&m){const f=O(e.__lunoraRef,A(d,a)),k=O(e.__lunoraRef,A(m,a)),M=b.get(f);if(M&&f!==k){M.currentKey=k,b.set(k,M),b.delete(f);const R=g.get(f);R&&(g.set(k,R),g.delete(f))}}n.value=c},pageResults:o,status:B}},se=(e,r,l)=>{const{loadMore:u,pageResults:i,status:t}=v(e,r,l),n=L(()=>i.value.flatMap(p=>p?.page??[]));return{isLoading:L(()=>t.value==="LoadingFirstPage"||t.value==="LoadingMore"),loadMore:u,results:n,status:t}},ie=(e,r,l)=>{const{initialNumItems:u}=l,{loadMore:i,pageResults:t,status:n}=v(e,r,l),o=L(()=>t.value.flatMap(K=>K?[K.page]:[])),p=L(()=>n.value==="LoadingFirstPage"),b=L(()=>n.value==="CanLoadMore"),g=L(()=>n.value==="LoadingMore");return{fetchNextPage:K=>{i(K??u)},hasNextPage:b,isFetchingNextPage:g,isLoading:p,pages:o,status:n}};export{ie as useInfiniteQuery,se as usePaginatedQuery};
|
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.103",
|
|
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.
|
|
58
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
59
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
57
|
+
"@lunora/client": "1.0.0-alpha.68",
|
|
58
|
+
"@lunora/errors": "1.0.0-alpha.27",
|
|
59
|
+
"@lunora/ratelimit": "1.0.0-alpha.32",
|
|
60
60
|
"@visulima/storage-client": "1.0.2"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const a=/["\\\u0000-\u001F\uD800-\uDFFF]/,f=t=>a.test(t)?JSON.stringify(t):`"${t}"`,y=t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(typeof t=="number"){if(Number.isNaN(t))return"nan";if(t===1/0)return"inf";if(t===-1/0)return"-inf";if(Object.is(t,-0))return"-0"}if(typeof t=="string")return f(t);if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t)){let r="[";for(let n=0;n<t.length;n++)n>0&&(r+=","),r+=y(t[n]);return r+"]"}const i=Object.getPrototypeOf(t);if(i!==null&&i!==Object.prototype){const r=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${r} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const o=t,c=Object.keys(o).sort();let e="{",s=!0;for(const r of c){const n=o[r];n!==void 0&&(s?s=!1:e+=",",e+=f(r),e+=":",e+=y(n))}return e+"}"};export{y as s};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createQuerySubscription as b}from"@lunora/client/query";import{shallowRef as i,watch as p,toValue as f}from"vue";import{i as n}from"./is-browser-BEdfLJHK.mjs";import{useLunora as l}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";import{o as y}from"./scope-dispose-Mq3k4nvP.mjs";const D=(o,s,t,e={})=>{const r=i(e.seed);if(n()){const a=o.subscribe(s,t,u=>{r.value=u},{shardKey:e.shardKey});y(a)}return r},R=(o,s,t={})=>{const e=l(),r=i(void 0);return p(()=>f(s),(a,u,c)=>{if(!n())return;const m=b(e,o,a,{onData:d=>{r.value=d},onReset:()=>{r.value=void 0}},{shardKey:t.shardKey});c(m)},{immediate:!0}),r};export{D as subscribeToQuery,R as useQuery};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{reconcileOptimistic as y,maxSeq as A}from"@lunora/client";import{ref as D,computed as c,toValue as s}from"vue";import{NO_MUTATION_REF as N}from"./useAgent-Bji8ptsw.mjs";import{useMutation as m}from"./useMutation-D6PkaNaE.mjs";import{useStream as F}from"./useStream-pSLl_8ix.mjs";import{useSubscription as R}from"./useSubscription-uZqOa1Pu.mjs";const U={__lunoraRef:""},Q=k=>{const{api:u,cancel:p,limit:v,send:w,sendArgs:x,stream:h,threadKey:a}=k,{data:I}=R(u.agents.agentMessages,()=>{const t=s(a);return v===void 0?{key:t}:{key:t,limit:v}}),{data:M}=R(u.agents.agentThread,()=>({key:s(a)})),S=h===void 0?"skip":()=>({key:s(a)}),{chunks:_}=F(h??U,S),b=m(w),K=m(p??N),T=m(u.agents.agentResolveApproval),o=D([]);let f=0;const l=c(()=>M.value),j=c(()=>l.value?.status),i=c(()=>I.value??[]),q=c(()=>{const t=i.value,n=y(o.value,t);if(n.length===0)return t;const e=A(t);return[...t,...n.map((r,d)=>({content:r.content,optimistic:!0,role:"user",seq:e+1+d}))]}),E=c(()=>{const t=s(a),n=i.value.filter(e=>e.role==="assistant").length;return _.value.filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=n).map(e=>e.text).join("")}),O=async(t,n)=>{const e=f;f+=1;const r=A(i.value);o.value=[...y(o.value,i.value),{content:t,id:e,maxDurableSeqAtSend:r}];try{await b.mutate({input:t,threadKey:s(a),...x,...n})}catch(d){throw o.value=o.value.filter(C=>C.id!==e),d}},g=async(t,n,e)=>{const r=l.value?.instanceId;if(r===void 0)throw new Error(`useAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await T.mutate({decision:t,instanceId:r,threadKey:s(a),toolCallId:n,...e===void 0?{}:{note:e}})};return{approve:async(t,n)=>g("approve",t,n),cancel:async()=>{const t=l.value?.instanceId;p===void 0||t===void 0||await K.mutate({instanceId:t,threadKey:s(a)})},messages:q,reject:async(t,n)=>g("reject",t,n),send:O,status:j,streamingText:E}};export{Q as useAgentChat};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{shallowRef as _,watch as m,toValue as n}from"vue";import{s as p}from"./stable-key-B_BlboiY.mjs";import{useLunora as v}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const $="__lunora_flags__:eval",y=e=>{const t=typeof e;return t==="boolean"||t==="number"||t==="string"?t:"object"},d={__lunoraRef:$},h=e=>e===void 0?"":p(e),C=(e,t,c)=>{const r=v(),a=y(t),u=_(t);return m(()=>`${n(e)}\0${h(n(c))}`,(g,f,l)=>{const i=n(e),s=n(c);u.value=t;let o;try{o=r.subscribe(d,{context:s,default:t,key:i,type:a},b=>{u.value=b})}catch{return}l(o)},{immediate:!0}),u},F=(e,t)=>{const c=v(),r=_(e),a=p(e);return m(()=>`${a}\0${h(n(t))}`,(u,g,f)=>{const l=n(t);r.value=e;const i=[];for(const[s,o]of Object.entries(e))try{i.push(c.subscribe(d,{context:l,default:o,key:s,type:y(o)},b=>{r.value={...r.value,[s]:b}}))}catch{}f(()=>{for(const s of i)s()})},{immediate:!0}),r};export{C as useFlag,F as useFlags};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{shallowRef as x,watch as O,toValue as A,onScopeDispose as V,computed as S}from"vue";import{initialPages as F,derivePaginationStatus as U,rebalance as W,applyLoadMore as z}from"@lunora/client/pagination";import{i as G}from"./is-browser-BEdfLJHK.mjs";import{s as H}from"./stable-key-B_BlboiY.mjs";import{useLunora as X}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const j=e=>{let n="";for(let f=0;f<e.length;f+=32768)n+=String.fromCharCode(...e.subarray(f,f+32768));return btoa(n)},u="$lunora.wire$",$=64,Y="__proto__",q=e=>{if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n===null||n===Object.prototype},K=(e,n=0)=>{if(n>$)throw new RangeError(`wire-codec: value nesting exceeds the ${$}-level limit`);if(e===void 0)return[u,"undefined"];if(e===null)return null;const y=typeof e;if(y==="bigint")return[u,"bigint",e.toString()];if(y==="number"){const t=e;return Number.isNaN(t)?[u,"nan"]:t===1/0?[u,"inf"]:t===-1/0?[u,"-inf"]:t}if(y!=="object")return e;if(e instanceof Date)return[u,"date",K(e.getTime(),n+1)];if(e instanceof Error){const t=e,r={};for(const g of Object.keys(t))t[g]!==void 0&&(r[g]=K(t[g],n+1));const s=[u,"error",t.name,t.message,r];return t.cause!==void 0&&s.push(K(t.cause,n+1)),s}if(e instanceof URL)return[u,"url",e.href];if(e instanceof Map)return[u,"map",[...e.entries()].map(([t,r])=>[K(t,n+1),K(r,n+1)])];if(e instanceof Set)return[u,"set",[...e].map(t=>K(t,n+1))];if(e instanceof ArrayBuffer)return[u,"bytes",j(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,r=t.constructor.name,s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return r==="Uint8Array"?[u,"bytes",j(s)]:[u,"bytes",j(s),r]}if(Array.isArray(e)){const t=e.map(r=>K(r,n+1));return t.length>0&&t[0]===u?[u,"arr",t]:t}if(!q(e)){const t=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${t} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const f=e,b={};for(const t of Object.keys(f)){const r=f[t];if(r===void 0)continue;const s=K(r,n+1);t===Y?Object.defineProperty(b,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):b[t]=s}return b},T=e=>H(K(e)),R=(e,n)=>`${e}::${T(n)}`,k=(e,n)=>({...n,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),D=(e,n,y)=>{const f=X(),{initialNumItems:b,shardKey:t}=y,r=x(F(b)),s=x([]);let g;const p=new Map,d=new Map,M=new Set,L=(o,i)=>{s.value=o.map(w=>{const P=R(e.__lunoraRef,k(w,i));return d.get(P)})},Q=(o,i,w)=>{const P=a=>R(e.__lunoraRef,k(a,w));for(const a of i){const l=P(a);if(d.has(l))continue;const m=o.find(c=>c.lower===a.lower);if(m){const c=d.get(P(m));c&&d.set(l,c)}}},B=(o,i)=>{const w=new Set;for(const a of o)w.add(R(e.__lunoraRef,k(a,i)));for(const[a,l]of p)w.has(l.currentKey)||(l.unsub(),p.delete(a),d.delete(l.currentKey),M.delete(l.currentKey));const P=new Set([...p.values()].map(a=>a.currentKey));for(const a of o){const l=k(a,i),m=R(e.__lunoraRef,l);if(P.has(m))continue;const c={currentKey:m,unsub:void 0};M.add(m);const h=f.subscribe(e,l,v=>{d.set(c.currentKey,v),M.delete(c.currentKey);const _=A(n);if(L(r.value,_),M.size===0){const I=r.value,N=W(I,s.value);N&&(Q(I,N,_),r.value=N)}},{shardKey:t});c.unsub=h,p.set(m,c),P.add(m)}},C=()=>{for(const o of p.values())o.unsub();p.clear(),d.clear(),M.clear()};O(()=>T(A(n)),()=>{if(!G())return;const o=A(n);C(),r.value=F(b),s.value=[],g=void 0,o!=="skip"&&(B(r.value,o),L(r.value,o))},{immediate:!0}),O(()=>r.value,o=>{const i=A(n);i!=="skip"&&(B(o,i),L(o,i))}),V(C);const E=x("LoadingFirstPage");return O([()=>A(n),s],([o,i])=>{E.value=U(o==="skip",i).status},{immediate:!0}),{loadMore:o=>{const i=A(n);if(i==="skip")return;const{nextCursor:w,status:P}=U(!1,s.value);if(P!=="CanLoadMore"||w===g)return;const a=z(r.value,w,o);if(!a)return;g=w;const l=r.value.at(-1),m=a.at(-2);if(l&&m){const c=R(e.__lunoraRef,k(l,i)),h=R(e.__lunoraRef,k(m,i)),v=p.get(c);if(v&&c!==h){v.currentKey=h,p.set(h,v),p.delete(c);const _=d.get(c);_&&(d.set(h,_),d.delete(c))}}r.value=a},pageResults:s,status:E}},oe=(e,n,y)=>{const{loadMore:f,pageResults:b,status:t}=D(e,n,y),r=S(()=>b.value.flatMap(g=>g?.page??[]));return{isLoading:S(()=>t.value==="LoadingFirstPage"||t.value==="LoadingMore"),loadMore:f,results:r,status:t}},se=(e,n,y)=>{const{initialNumItems:f}=y,{loadMore:b,pageResults:t,status:r}=D(e,n,y),s=S(()=>t.value.flatMap(L=>L?[L.page]:[])),g=S(()=>r.value==="LoadingFirstPage"),p=S(()=>r.value==="CanLoadMore"),d=S(()=>r.value==="LoadingMore");return{fetchNextPage:L=>{b(L??f)},hasNextPage:p,isFetchingNextPage:d,isLoading:g,pages:s,status:r}};export{se as useInfiniteQuery,oe as usePaginatedQuery};
|