@lunora/vue 1.0.0-alpha.102 → 1.0.0-alpha.104
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 +17 -12
- package/dist/index.d.ts +17 -12
- package/dist/index.mjs +1 -1
- 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/useFlag-CCgWKa-m.mjs +0 -1
- package/dist/packem_shared/useInfiniteQuery-BRhjOdWk.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -557,8 +557,6 @@ declare const useAuth: () => UseAuthResult;
|
|
|
557
557
|
* Call inside `setup()` / an active effect scope.
|
|
558
558
|
*/
|
|
559
559
|
declare const useConnectionStatus: () => Readonly<Ref<ConnectionStatus>>;
|
|
560
|
-
/** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
|
|
561
|
-
type FlagContext = Record<string, unknown>;
|
|
562
560
|
/** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
|
|
563
561
|
type FlagValue = boolean | number | string | {
|
|
564
562
|
[key: string]: unknown;
|
|
@@ -572,10 +570,15 @@ type FlagValue = boolean | number | string | {
|
|
|
572
570
|
* from `defaultValue`'s runtime type, so `useFlag("dark", false)` reads a boolean
|
|
573
571
|
* and `useFlag("hero", "control")` a string.
|
|
574
572
|
*
|
|
575
|
-
* `key`
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
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.
|
|
579
582
|
*
|
|
580
583
|
* Evaluation runs through whatever OpenFeature provider the app wired in
|
|
581
584
|
* `lunora/flags.ts`; the read never throws — a provider error resolves the
|
|
@@ -584,17 +587,19 @@ type FlagValue = boolean | number | string | {
|
|
|
584
587
|
* (or any active effect scope); the subscription tears down on unmount. During
|
|
585
588
|
* SSR no subscription opens at all and the ref stays at `defaultValue`.
|
|
586
589
|
*/
|
|
587
|
-
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>>;
|
|
588
591
|
/**
|
|
589
592
|
* Subscribe to several feature flags at once, live over Lunora's WebSocket.
|
|
590
593
|
*
|
|
591
594
|
* Pass a record of `key → defaultValue`; each flag's kind is inferred from its
|
|
592
595
|
* default, and the returned `ref` holds the same-shaped record with resolved
|
|
593
|
-
* values (the defaults until each evaluation lands).
|
|
594
|
-
*
|
|
595
|
-
*
|
|
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.
|
|
596
601
|
*/
|
|
597
|
-
declare const useFlags: <T extends Record<string, FlagValue>>(flags: T
|
|
602
|
+
declare const useFlags: <T extends Record<string, FlagValue>>(flags: T) => Readonly<Ref<T>>;
|
|
598
603
|
/**
|
|
599
604
|
* The reactive handle returned by {@link useMutation} — the Vue counterpart to
|
|
600
605
|
* React's `useMutation`, re-expressed with refs. The surface is identical across
|
|
@@ -1051,7 +1056,7 @@ interface UseVoiceAgentResult {
|
|
|
1051
1056
|
* `createSocket`) so the composable is drivable outside a browser.
|
|
1052
1057
|
*/
|
|
1053
1058
|
declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
|
|
1054
|
-
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,
|
|
1055
1060
|
/**
|
|
1056
1061
|
* `@lunora/vue` — the Vue adapter for Lunora.
|
|
1057
1062
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -557,8 +557,6 @@ declare const useAuth: () => UseAuthResult;
|
|
|
557
557
|
* Call inside `setup()` / an active effect scope.
|
|
558
558
|
*/
|
|
559
559
|
declare const useConnectionStatus: () => Readonly<Ref<ConnectionStatus>>;
|
|
560
|
-
/** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
|
|
561
|
-
type FlagContext = Record<string, unknown>;
|
|
562
560
|
/** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
|
|
563
561
|
type FlagValue = boolean | number | string | {
|
|
564
562
|
[key: string]: unknown;
|
|
@@ -572,10 +570,15 @@ type FlagValue = boolean | number | string | {
|
|
|
572
570
|
* from `defaultValue`'s runtime type, so `useFlag("dark", false)` reads a boolean
|
|
573
571
|
* and `useFlag("hero", "control")` a string.
|
|
574
572
|
*
|
|
575
|
-
* `key`
|
|
576
|
-
*
|
|
577
|
-
*
|
|
578
|
-
*
|
|
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.
|
|
579
582
|
*
|
|
580
583
|
* Evaluation runs through whatever OpenFeature provider the app wired in
|
|
581
584
|
* `lunora/flags.ts`; the read never throws — a provider error resolves the
|
|
@@ -584,17 +587,19 @@ type FlagValue = boolean | number | string | {
|
|
|
584
587
|
* (or any active effect scope); the subscription tears down on unmount. During
|
|
585
588
|
* SSR no subscription opens at all and the ref stays at `defaultValue`.
|
|
586
589
|
*/
|
|
587
|
-
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>>;
|
|
588
591
|
/**
|
|
589
592
|
* Subscribe to several feature flags at once, live over Lunora's WebSocket.
|
|
590
593
|
*
|
|
591
594
|
* Pass a record of `key → defaultValue`; each flag's kind is inferred from its
|
|
592
595
|
* default, and the returned `ref` holds the same-shaped record with resolved
|
|
593
|
-
* values (the defaults until each evaluation lands).
|
|
594
|
-
*
|
|
595
|
-
*
|
|
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.
|
|
596
601
|
*/
|
|
597
|
-
declare const useFlags: <T extends Record<string, FlagValue>>(flags: T
|
|
602
|
+
declare const useFlags: <T extends Record<string, FlagValue>>(flags: T) => Readonly<Ref<T>>;
|
|
598
603
|
/**
|
|
599
604
|
* The reactive handle returned by {@link useMutation} — the Vue counterpart to
|
|
600
605
|
* React's `useMutation`, re-expressed with refs. The surface is identical across
|
|
@@ -1051,7 +1056,7 @@ interface UseVoiceAgentResult {
|
|
|
1051
1056
|
* `createSocket`) so the composable is drivable outside a browser.
|
|
1052
1057
|
*/
|
|
1053
1058
|
declare const useVoiceAgent: (options: UseVoiceAgentOptions) => UseVoiceAgentResult;
|
|
1054
|
-
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,
|
|
1055
1060
|
/**
|
|
1056
1061
|
* `@lunora/vue` — the Vue adapter for Lunora.
|
|
1057
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-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-
|
|
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};
|
|
@@ -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.104",
|
|
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.69",
|
|
58
|
+
"@lunora/errors": "1.0.0-alpha.27",
|
|
59
|
+
"@lunora/ratelimit": "1.0.0-alpha.33",
|
|
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{shallowRef as l,watch as f,toValue as s}from"vue";import{i as b}from"./is-browser-BEdfLJHK.mjs";import{s as m}from"./stable-key-B_BlboiY.mjs";import{useLunora as _}from"./LUNORA_INJECTION_KEY-Bct9tKCj.mjs";const k="__lunora_flags__:eval",F=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},$={__lunoraRef:k},d=(t,e,o)=>{try{return t.subscribe($,{context:e.context,default:e.default,key:e.key,type:F(e.default)},r=>{o(r)},{onError:()=>{o(e.default)}})}catch{return()=>{}}},p=t=>t===void 0?"":m(t),L=(t,e,o)=>{const r=_(),u=l(e);return f(()=>`${s(t)}\0${p(s(o))}`,(v,y,i)=>{const a=s(t),c=s(o);u.value=e,b()&&i(d(r,{context:c,default:e,key:a},n=>{u.value=n}))},{immediate:!0}),u},R=(t,e)=>{const o=_(),r=l(t),u=m(t);return f(()=>`${u}\0${p(s(e))}`,(v,y,i)=>{const a=s(e);if(r.value=t,!b())return;const c=[];for(const[n,x]of Object.entries(t))c.push(d(o,{context:a,default:x,key:n},h=>{r.value={...r.value,[n]:h}}));i(()=>{for(const n of c)n()})},{immediate:!0}),r};export{L as useFlag,R 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};
|