@lunora/svelte 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/dist/index.d.mts CHANGED
@@ -562,8 +562,6 @@ type ConnectionStatusStore = Readable<ConnectionStatus>;
562
562
  * before this runs).
563
563
  */
564
564
  declare const connectionStatus: (client?: LunoraClient) => ConnectionStatusStore;
565
- /** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
566
- type FlagContext = Record<string, unknown>;
567
565
  /** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
568
566
  type FlagValue = boolean | number | string | {
569
567
  [key: string]: unknown;
@@ -576,31 +574,37 @@ type FlagValue = boolean | number | string | {
576
574
  * server's resolved value — re-emitted whenever the provider re-evaluates (e.g. a
577
575
  * flag is toggled in Cloudflare Flagship). The flag's kind is inferred from
578
576
  * `defaultValue`'s runtime type, so `flag("dark", false)` reads a boolean and
579
- * `flag("hero", "control")` a string. `context` supplies a per-call targeting
580
- * context merged on top of the app's default `identify` targeting key.
577
+ * `flag("hero", "control")` a string.
578
+ *
579
+ * The reactive channel is public, so the server evaluates every flag under the
580
+ * socket's own verified identity — the targeting key your `defineFlags({
581
+ * identify })` derives — and accepts no client-supplied targeting context. For
582
+ * evaluation under a context you compute, call `ctx.flags.*` inside a query,
583
+ * mutation, or action and return the resolved value.
581
584
  *
582
585
  * The subscription opens lazily on the first `$`-read and tears down when the
583
586
  * last subscriber detaches. Pass `client` explicitly, or omit it to resolve the
584
587
  * ambient client published by `setLunoraClient`. Evaluation never throws — a
585
588
  * provider error resolves the default (the same fail-open contract as `ctx.flags`).
586
589
  */
587
- declare function flag<T extends FlagValue>(key: string, defaultValue: T, context?: FlagContext): Readable<T>;
588
- declare function flag<T extends FlagValue>(client: LunoraClient, key: string, defaultValue: T, context?: FlagContext): Readable<T>;
590
+ declare function flag<T extends FlagValue>(key: string, defaultValue: T): Readable<T>;
591
+ declare function flag<T extends FlagValue>(client: LunoraClient, key: string, defaultValue: T): Readable<T>;
589
592
  /**
590
593
  * Open several feature flags at once as a single Svelte readable store of the
591
594
  * resolved record, live over Lunora's WebSocket.
592
595
  *
593
596
  * Pass a record of `key → defaultValue`; each flag's kind is inferred from its
594
597
  * default, and the store holds the same-shaped record with resolved values (the
595
- * defaults until each evaluation lands). A single `context` applies to every
596
- * flag. This is the batched form of {@link flag} one store, one subscription
597
- * per key, torn down together when the last subscriber detaches.
598
+ * defaults until each evaluation lands). This is the batched form of {@link flag}
599
+ * one store, one subscription per key, torn down together when the last
600
+ * subscriber detaches. Like {@link flag} it evaluates under the socket's
601
+ * server-verified identity only.
598
602
  *
599
603
  * Pass `client` explicitly, or omit it to resolve the ambient client published
600
604
  * by `setLunoraClient`.
601
605
  */
602
- declare function flags<T extends Record<string, FlagValue>>(flagDefaults: T, context?: FlagContext): Readable<T>;
603
- declare function flags<T extends Record<string, FlagValue>>(client: LunoraClient, flagDefaults: T, context?: FlagContext): Readable<T>;
606
+ declare function flags<T extends Record<string, FlagValue>>(flagDefaults: T): Readable<T>;
607
+ declare function flags<T extends Record<string, FlagValue>>(client: LunoraClient, flagDefaults: T): Readable<T>;
604
608
  /**
605
609
  * Hydrate a query store from a {@link Preloaded} token produced by
606
610
  * `preloadQuery` during SSR, then keep it live — the reactive-loader handoff.
@@ -1128,7 +1132,7 @@ interface VoiceAgentHandle {
1128
1132
  */
1129
1133
  declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
1130
1134
  declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
1131
- export { type ActionHandle, type AgentApi, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagContext, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
1135
+ export { type ActionHandle, type AgentApi, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
1132
1136
  /**
1133
1137
  * Svelte adapter for Lunora (`@lunora/svelte`).
1134
1138
  *
package/dist/index.d.ts CHANGED
@@ -562,8 +562,6 @@ type ConnectionStatusStore = Readable<ConnectionStatus>;
562
562
  * before this runs).
563
563
  */
564
564
  declare const connectionStatus: (client?: LunoraClient) => ConnectionStatusStore;
565
- /** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
566
- type FlagContext = Record<string, unknown>;
567
565
  /** The value kinds a flag resolves to — OpenFeature's boolean / number / string / structured (JSON) flags. */
568
566
  type FlagValue = boolean | number | string | {
569
567
  [key: string]: unknown;
@@ -576,31 +574,37 @@ type FlagValue = boolean | number | string | {
576
574
  * server's resolved value — re-emitted whenever the provider re-evaluates (e.g. a
577
575
  * flag is toggled in Cloudflare Flagship). The flag's kind is inferred from
578
576
  * `defaultValue`'s runtime type, so `flag("dark", false)` reads a boolean and
579
- * `flag("hero", "control")` a string. `context` supplies a per-call targeting
580
- * context merged on top of the app's default `identify` targeting key.
577
+ * `flag("hero", "control")` a string.
578
+ *
579
+ * The reactive channel is public, so the server evaluates every flag under the
580
+ * socket's own verified identity — the targeting key your `defineFlags({
581
+ * identify })` derives — and accepts no client-supplied targeting context. For
582
+ * evaluation under a context you compute, call `ctx.flags.*` inside a query,
583
+ * mutation, or action and return the resolved value.
581
584
  *
582
585
  * The subscription opens lazily on the first `$`-read and tears down when the
583
586
  * last subscriber detaches. Pass `client` explicitly, or omit it to resolve the
584
587
  * ambient client published by `setLunoraClient`. Evaluation never throws — a
585
588
  * provider error resolves the default (the same fail-open contract as `ctx.flags`).
586
589
  */
587
- declare function flag<T extends FlagValue>(key: string, defaultValue: T, context?: FlagContext): Readable<T>;
588
- declare function flag<T extends FlagValue>(client: LunoraClient, key: string, defaultValue: T, context?: FlagContext): Readable<T>;
590
+ declare function flag<T extends FlagValue>(key: string, defaultValue: T): Readable<T>;
591
+ declare function flag<T extends FlagValue>(client: LunoraClient, key: string, defaultValue: T): Readable<T>;
589
592
  /**
590
593
  * Open several feature flags at once as a single Svelte readable store of the
591
594
  * resolved record, live over Lunora's WebSocket.
592
595
  *
593
596
  * Pass a record of `key → defaultValue`; each flag's kind is inferred from its
594
597
  * default, and the store holds the same-shaped record with resolved values (the
595
- * defaults until each evaluation lands). A single `context` applies to every
596
- * flag. This is the batched form of {@link flag} one store, one subscription
597
- * per key, torn down together when the last subscriber detaches.
598
+ * defaults until each evaluation lands). This is the batched form of {@link flag}
599
+ * one store, one subscription per key, torn down together when the last
600
+ * subscriber detaches. Like {@link flag} it evaluates under the socket's
601
+ * server-verified identity only.
598
602
  *
599
603
  * Pass `client` explicitly, or omit it to resolve the ambient client published
600
604
  * by `setLunoraClient`.
601
605
  */
602
- declare function flags<T extends Record<string, FlagValue>>(flagDefaults: T, context?: FlagContext): Readable<T>;
603
- declare function flags<T extends Record<string, FlagValue>>(client: LunoraClient, flagDefaults: T, context?: FlagContext): Readable<T>;
606
+ declare function flags<T extends Record<string, FlagValue>>(flagDefaults: T): Readable<T>;
607
+ declare function flags<T extends Record<string, FlagValue>>(client: LunoraClient, flagDefaults: T): Readable<T>;
604
608
  /**
605
609
  * Hydrate a query store from a {@link Preloaded} token produced by
606
610
  * `preloadQuery` during SSR, then keep it live — the reactive-loader handoff.
@@ -1128,7 +1132,7 @@ interface VoiceAgentHandle {
1128
1132
  */
1129
1133
  declare function voiceAgent(options: VoiceAgentOptions): VoiceAgentHandle;
1130
1134
  declare function voiceAgent(client: LunoraClient, options: VoiceAgentOptions): VoiceAgentHandle;
1131
- export { type ActionHandle, type AgentApi, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagContext, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
1135
+ export { type ActionHandle, type AgentApi, type AgentChatApi, type AgentChatHandle, type AgentChatMessage, type AgentChatOptions, type AgentHandle, type AgentLiveEvent, type AgentOptions, type AgentProgressEvent, type AgentStateApi, type AgentStateHandle, type AgentStateOptions, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, type AgentToolEventsApi, type AgentToolEventsHandle, type AgentToolEventsOptions, type AuthGateStore, type AuthStore, type ConnectionStatusStore, type FlagValue, type HeartbeatReference, type InfiniteQueryHandle, type InfiniteQueryOptions, type ListPresentReference, type MutationHandle, type MutatorHandleStore, type PageItemOf, type PaginatedArgs, type PaginatedQueryHandle, type PaginatedQueryOptions, type PresenceHandle, type PresenceOptions, type QueryStore, type QueryStoreOptions, type RateLimitHandle, type RateLimitOptions, type ReactiveArgs, type ReactivePaginatedArgs, type StreamHandle, type StreamStatus, type StreamStoreOptions, type SubscriptionHandle, type SubscriptionStoreOptions, type VoiceAgentHandle, type VoiceAgentOptions, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, action, agent, agentChat, agentState, agentToolEvents, auth, authGate, connectionStatus, flag, flags,
1132
1136
  /**
1133
1137
  * Svelte adapter for Lunora (`@lunora/svelte`).
1134
1138
  *
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{action as t}from"./packem_shared/action-SjeZUGhX.mjs";import{agent as a}from"./packem_shared/agent-CFzp-ncV.mjs";import{agentChat as f}from"./packem_shared/agentChat-BhMVjqq4.mjs";import{agentState as n}from"./packem_shared/agentState-at2Rg_Q9.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-BrybzNXi.mjs";import{auth as g,authGate as s}from"./packem_shared/auth-Bew4W5n1.mjs";import{connectionStatus as l}from"./packem_shared/connectionStatus-D9A79Eqw.mjs";import{getLunoraClient as h,setLunoraClient as y}from"./packem_shared/getLunoraClient-DU7BmZy1.mjs";import{flag as L,flags as v}from"./packem_shared/flag-BUhJN_h7.mjs";import{hydratePreloaded as S}from"./packem_shared/hydratePreloaded-CW7Ak8zY.mjs";import{mutation as q}from"./packem_shared/mutation-DLBr5Op1.mjs";import{mutator as E}from"./packem_shared/mutator-DECDuo94.mjs";import{infiniteQuery as P,paginatedQuery as T}from"./packem_shared/infiniteQuery-CFBT6Hbs.mjs";import{presence as k}from"./packem_shared/presence-I_W9Zbhg.mjs";import{query as z}from"./packem_shared/query-aWSTFtNz.mjs";import{rateLimit as D}from"./packem_shared/rateLimit-Cli38qWO.mjs";import{stream as H}from"./packem_shared/stream-eY1eAuVw.mjs";import{subscription as J}from"./packem_shared/subscription-3foboeMU.mjs";import{voiceAgent as M}from"./packem_shared/voiceAgent-odCezdLl.mjs";export{t as action,a as agent,f as agentChat,n as agentState,i as agentToolEvents,g as auth,s as authGate,l as connectionStatus,L as flag,v as flags,h as getLunoraClient,S as hydratePreloaded,P as infiniteQuery,q as mutation,E as mutator,T as paginatedQuery,k as presence,z as query,D as rateLimit,y as setLunoraClient,H as stream,J as subscription,M as voiceAgent};
1
+ import{action as t}from"./packem_shared/action-SjeZUGhX.mjs";import{agent as a}from"./packem_shared/agent-CFzp-ncV.mjs";import{agentChat as f}from"./packem_shared/agentChat-BhMVjqq4.mjs";import{agentState as n}from"./packem_shared/agentState-at2Rg_Q9.mjs";import{agentToolEvents as i}from"./packem_shared/agentToolEvents-BrybzNXi.mjs";import{auth as g,authGate as s}from"./packem_shared/auth-Bew4W5n1.mjs";import{connectionStatus as l}from"./packem_shared/connectionStatus-D9A79Eqw.mjs";import{getLunoraClient as h,setLunoraClient as y}from"./packem_shared/getLunoraClient-DU7BmZy1.mjs";import{flag as L,flags as v}from"./packem_shared/flag-C6RFEBM_.mjs";import{hydratePreloaded as S}from"./packem_shared/hydratePreloaded-CW7Ak8zY.mjs";import{mutation as q}from"./packem_shared/mutation-DLBr5Op1.mjs";import{mutator as E}from"./packem_shared/mutator-DECDuo94.mjs";import{infiniteQuery as P,paginatedQuery as T}from"./packem_shared/infiniteQuery-CFBT6Hbs.mjs";import{presence as k}from"./packem_shared/presence-I_W9Zbhg.mjs";import{query as z}from"./packem_shared/query-aWSTFtNz.mjs";import{rateLimit as D}from"./packem_shared/rateLimit-Cli38qWO.mjs";import{stream as H}from"./packem_shared/stream-eY1eAuVw.mjs";import{subscription as J}from"./packem_shared/subscription-3foboeMU.mjs";import{voiceAgent as M}from"./packem_shared/voiceAgent-odCezdLl.mjs";export{t as action,a as agent,f as agentChat,n as agentState,i as agentToolEvents,g as auth,s as authGate,l as connectionStatus,L as flag,v as flags,h as getLunoraClient,S as hydratePreloaded,P as infiniteQuery,q as mutation,E as mutator,T as paginatedQuery,k as presence,z as query,D as rateLimit,y as setLunoraClient,H as stream,J as subscription,M as voiceAgent};
@@ -0,0 +1 @@
1
+ import{readable as l}from"svelte/store";import{i as m}from"./is-browser-BEdfLJHK.mjs";import{isClient as i}from"./agent-CFzp-ncV.mjs";import{getLunoraClient as a}from"./getLunoraClient-DU7BmZy1.mjs";const _="__lunora_flags__:eval",g=e=>{const t=typeof e;return t==="boolean"||t==="number"||t==="string"?t:"object"},h={__lunoraRef:_},k=(e,t,n)=>{try{return e.subscribe(h,{default:t.default,key:t.key,type:g(t.default)},o=>{n(o)},{onError:()=>{n(t.default)}})}catch{return()=>{}}},b=(e,t,n,o)=>m()?k(e,{default:n,key:t},o):()=>{};function A(e,t,n){const o=i(e),s=o?e:a(),f=o?t:e,r=o?n:t;return l(r,u=>b(s,f,r,u))}function L(e,t){const n=i(e),o=n?e:a(),s=n?t:e;return l(s,f=>{let r={...s};const u=[];for(const[c,p]of Object.entries(s))u.push(b(o,c,p,d=>{r={...r,[c]:d},f(r)}));return()=>{for(const c of u)c()}})}export{A as flag,L as flags};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/svelte",
3
- "version": "1.0.0-alpha.101",
3
+ "version": "1.0.0-alpha.103",
4
4
  "description": "Svelte adapter for Lunora — live stores, 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.67",
58
- "@lunora/errors": "1.0.0-alpha.26",
59
- "@lunora/ratelimit": "1.0.0-alpha.31",
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
- import{readable as a}from"svelte/store";import{i as x}from"./is-browser-BEdfLJHK.mjs";import{isClient as b}from"./agent-CFzp-ncV.mjs";import{getLunoraClient as d}from"./getLunoraClient-DU7BmZy1.mjs";const h="__lunora_flags__:eval",k=n=>{const t=typeof n;return t==="boolean"||t==="number"||t==="string"?t:"object"},y={__lunoraRef:h},E=(n,t,o)=>{try{return n.subscribe(y,{context:t.context,default:t.default,key:t.key,type:k(t.default)},e=>{o(e)},{onError:()=>{o(t.default)}})}catch{return()=>{}}},p=(n,t,o,e,c)=>x()?E(n,{context:e,default:o,key:t},c):()=>{};function V(n,t,o,e){const c=b(n),r=c?n:d(),l=c?t:n,u=c?o:t,s=(c?e:o)??void 0;return a(u,i=>p(r,l,u,s,i))}function j(n,t,o){const e=b(n),c=e?n:d(),r=e?t:n,l=(e?o:t)??void 0;return a(r,u=>{let s={...r};const i=[];for(const[f,m]of Object.entries(r))i.push(p(c,f,m,l,_=>{s={...s,[f]:_},u(s)}));return()=>{for(const f of i)f()}})}export{V as flag,j as flags};