@lunora/solid 1.0.0-alpha.55 → 1.0.0-alpha.56

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.
Files changed (35) hide show
  1. package/README.md +4 -0
  2. package/dist/index.d.mts +61 -17
  3. package/dist/index.d.ts +61 -17
  4. package/dist/index.mjs +1 -1
  5. package/dist/packem_shared/AuthLoading-6vueEnV0.mjs +1 -0
  6. package/dist/packem_shared/LunoraContext-dPcjtn6R.mjs +1 -0
  7. package/dist/packem_shared/LunoraProvider-BKWckcDR.mjs +1 -0
  8. package/dist/packem_shared/{createAction-CbGirc8n.mjs → createAction-M4s8XBXV.mjs} +1 -1
  9. package/dist/packem_shared/{createAgent-CvY_sduu.mjs → createAgent-DTUKko5X.mjs} +1 -1
  10. package/dist/packem_shared/{createAgentChat-BONQ21Fr.mjs → createAgentChat-BjVMwDVY.mjs} +1 -1
  11. package/dist/packem_shared/{createAgentState-D6iGuFht.mjs → createAgentState-DIknFZyn.mjs} +1 -1
  12. package/dist/packem_shared/{createAgentToolEvents-Beu0Hk7M.mjs → createAgentToolEvents-BZDqkzK6.mjs} +1 -1
  13. package/dist/packem_shared/createConnectionStatus-BnlXYWeE.mjs +1 -0
  14. package/dist/packem_shared/createFlag-l_riySES.mjs +1 -0
  15. package/dist/packem_shared/createInfiniteQuery-CAU4Yr4Z.mjs +1 -0
  16. package/dist/packem_shared/{createMutation-DE50ca4x.mjs → createMutation-DcSsIbGF.mjs} +1 -1
  17. package/dist/packem_shared/createPresence-Da_DdL7L.mjs +1 -0
  18. package/dist/packem_shared/createQuery-DnfKuyeU.mjs +1 -0
  19. package/dist/packem_shared/createStream-B10b3ijV.mjs +1 -0
  20. package/dist/packem_shared/createSubscription-D9e8lT1C.mjs +1 -0
  21. package/dist/packem_shared/{createVoiceAgent-zdX0zuEH.mjs → createVoiceAgent-BjL6DH05.mjs} +1 -1
  22. package/dist/packem_shared/hydratePreloaded-CnJNitir.mjs +1 -0
  23. package/dist/packem_shared/solid-compat-ByG5HD_F.mjs +1 -0
  24. package/package.json +2 -2
  25. package/dist/packem_shared/AuthLoading-Cw7P46Me.mjs +0 -1
  26. package/dist/packem_shared/LunoraContext-Ck27Dk1M.mjs +0 -1
  27. package/dist/packem_shared/LunoraProvider-DMXdQNLA.mjs +0 -1
  28. package/dist/packem_shared/createConnectionStatus-atEsI2Uf.mjs +0 -1
  29. package/dist/packem_shared/createFlag-Budmp0PL.mjs +0 -1
  30. package/dist/packem_shared/createInfiniteQuery-BvSHuI_n.mjs +0 -1
  31. package/dist/packem_shared/createPresence-DexXIxGo.mjs +0 -1
  32. package/dist/packem_shared/createQuery-Mf7pD2Wc.mjs +0 -1
  33. package/dist/packem_shared/createStream-wnMAf-xL.mjs +0 -1
  34. package/dist/packem_shared/createSubscription-CkJjcYO4.mjs +0 -1
  35. package/dist/packem_shared/hydratePreloaded-DaixZhLe.mjs +0 -1
package/README.md CHANGED
@@ -52,6 +52,10 @@ yarn add @lunora/solid
52
52
  pnpm add @lunora/solid
53
53
  ```
54
54
 
55
+ Requires `solid-js@^1.9.0 || ^2.0.0-rc.0` as a peer. A single build serves both
56
+ majors and the public API is identical on either; on Solid 2.0 the surrounding
57
+ imports move (`solid-js/web` → `@solidjs/web`, `solid-js/store` → `solid-js`).
58
+
55
59
  ## Usage
56
60
 
57
61
  ```tsx
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle, Preloaded } from '@lunora/client';
2
2
  export type { ArgsOf, FunctionReference, MutatorHandle, MutatorTransaction, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe } from '@lunora/client';
3
- import { Context, Accessor, JSX } from 'solid-js';
3
+ import { Context, Accessor } from 'solid-js';
4
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
6
6
  /**
@@ -10,7 +10,8 @@ import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
10
10
  * `<LunoraProvider client={…}>` at the root of the tree wires the whole app.
11
11
  *
12
12
  * Defaults to `undefined` so {@link useLunora} can throw a helpful error when a
13
- * primitive is used outside a provider rather than dereferencing it.
13
+ * primitive is used outside a provider rather than dereferencing it. Solid 2
14
+ * refuses to hand back an `undefined` default at all — see {@link useLunora}.
14
15
  */
15
16
  declare const LunoraContext: Context<LunoraClient | undefined>;
16
17
  /**
@@ -465,6 +466,33 @@ interface CreateAgentToolEventsResult {
465
466
  * + approvals) use `createAgentChat`; this primitive is the tool-observability slice.
466
467
  */
467
468
  declare const createAgentToolEvents: (options: CreateAgentToolEventsOptions) => CreateAgentToolEventsResult;
469
+ /**
470
+ * Children accepted by this adapter's components.
471
+ *
472
+ * Structurally identical to Solid 2.0's `Element`, which is in turn a widening
473
+ * of 1.x's `JSX.Element` (a DOM `Node` satisfies `object` with no
474
+ * `call`/`apply`/`bind`). Children are contravariant, so one union that accepts
475
+ * both majors' element types is enough — no `any` required here.
476
+ */
477
+ type SolidChildren = SolidChildrenArray | boolean | null | number | (object & {
478
+ readonly apply?: never;
479
+ readonly bind?: never;
480
+ readonly call?: never;
481
+ }) | (string & {}) | undefined;
482
+ interface SolidChildrenArray extends Array<SolidChildren> {}
483
+ /**
484
+ * The return type of this adapter's components.
485
+ *
486
+ * Deliberately `any`, and the one place in the package where that is the right
487
+ * answer. TypeScript checks a component's return type against the *renderer's*
488
+ * `JSX.Element`, and the two majors define that incompatibly — 1.x's is rooted
489
+ * in the DOM `Node` interface, 2.0's in an opaque `RenderedElement`. Neither is
490
+ * assignable to the other, so no concrete type satisfies both, and a structural
491
+ * union (as used for {@link SolidChildren}) fails in the return position. `any`
492
+ * is what lets one set of `.d.ts` files type-check inside a 1.x app and a 2.x
493
+ * app alike.
494
+ */
495
+ type SolidElement = any;
468
496
  interface UseAuthResult {
469
497
  setToken: (token: string | null) => void;
470
498
  token: Accessor<string | null>;
@@ -478,23 +506,25 @@ interface UseAuthResult {
478
506
  */
479
507
  declare const createAuth: () => UseAuthResult;
480
508
  interface AuthGateProps {
481
- children: JSX.Element;
509
+ children: SolidChildren;
482
510
  }
511
+ /** An auth-gate component: renders its children only while the gate's condition holds. */
512
+ type AuthGate = (props: AuthGateProps) => SolidElement;
483
513
  /**
484
514
  * Render `children` only after authentication has settled and a token + user
485
515
  * are both present.
486
516
  */
487
- declare const Authenticated: (props: AuthGateProps) => JSX.Element;
517
+ declare const Authenticated: AuthGate;
488
518
  /**
489
519
  * Render `children` while authentication is still in progress — token is set
490
520
  * but the user has not yet resolved.
491
521
  */
492
- declare const AuthLoading: (props: AuthGateProps) => JSX.Element;
522
+ declare const AuthLoading: AuthGate;
493
523
  /**
494
524
  * Render `children` only when auth has settled and no token is present (the
495
525
  * signed-out state).
496
526
  */
497
- declare const Unauthenticated: (props: AuthGateProps) => JSX.Element;
527
+ declare const Unauthenticated: AuthGate;
498
528
  /**
499
529
  * Reactive accessor of the client's aggregate live-socket status across all
500
530
  * shard connections. Reads the current status synchronously and updates on
@@ -502,8 +532,14 @@ declare const Unauthenticated: (props: AuthGateProps) => JSX.Element;
502
532
  * fine-grained signals mean only the components that read the accessor
503
533
  * re-render. The Solid equivalent of `@lunora/react`'s `useConnectionStatus`.
504
534
  *
505
- * The status listener is torn down via `onCleanup` when the owning reactive
506
- * scope disposes (component unmount). Call inside a component / reactive root.
535
+ * The listener is registered at **mount**, not in the component body, because
536
+ * `onConnectionStatus` invokes it synchronously on subscribe: Solid 2 rejects a
537
+ * signal write inside an owned scope (`REACTIVE_WRITE_IN_OWNED_SCOPE`) and — since
538
+ * the throw escapes render — halts the reactive system for the whole page, not
539
+ * just this component. Nothing is missed by waiting: the initial value comes
540
+ * from `client.connectionStatus()`, and the immediate callback re-syncs at
541
+ * mount. Torn down when the owning scope disposes. Call inside a component /
542
+ * reactive root.
507
543
  */
508
544
  declare const createConnectionStatus: () => Accessor<ConnectionStatus>;
509
545
  /** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
@@ -978,9 +1014,9 @@ declare const createVoiceAgent: (options: CreateVoiceAgentOptions) => CreateVoic
978
1014
  * returned accessor is seeded **synchronously** from `preloaded.value`, so the
979
1015
  * very first read — during hydration — returns the server-rendered value with
980
1016
  * no loading flash and no `Suspense` fallback (unlike `createResource`, which
981
- * always starts pending). After the component mounts, a WebSocket subscription
982
- * attaches in an effect and every subsequent server delta flows into the same
983
- * signal, so the UI goes live with zero refetch.
1017
+ * always starts pending). Once the component mounts, a WebSocket subscription
1018
+ * attaches and every subsequent server delta flows into the same signal, so the
1019
+ * UI goes live with zero refetch.
984
1020
  *
985
1021
  * ```tsx
986
1022
  * // route loader (server): const preloaded = await preloadQuery(client, api.messages.list, args);
@@ -988,13 +1024,13 @@ declare const createVoiceAgent: (options: CreateVoiceAgentOptions) => CreateVoic
988
1024
  * return <pre>{JSON.stringify(messages())}</pre>;
989
1025
  * ```
990
1026
  *
991
- * Effects do not run on the server during SSR (Solid only runs them after
992
- * hydration), so the subscription is strictly client-side — the seed is the
993
- * only value the server render ever sees.
1027
+ * Mount callbacks do not run on the server during SSR (both Solid majors defer
1028
+ * them until after hydration), so the subscription is strictly client-side —
1029
+ * the seed is the only value the server render ever sees.
994
1030
  */
995
1031
  declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Accessor<T>;
996
1032
  interface LunoraProviderProps {
997
- children: JSX.Element;
1033
+ children: SolidChildren;
998
1034
  /**
999
1035
  * The framework-neutral transport. Build it once at the app root with
1000
1036
  * `new LunoraClient({ url })` (or `createServerClient` during SSR) and pass
@@ -1021,8 +1057,16 @@ interface LunoraProviderProps {
1021
1057
  * </LunoraProvider>
1022
1058
  * ), root);
1023
1059
  * ```
1060
+ *
1061
+ * Written with `createComponent` rather than JSX on purpose. Solid 1.x and 2.0
1062
+ * compile JSX against different runtimes (`solid-js/web` vs `@solidjs/web`), so
1063
+ * a JSX source file would force this package to ship two builds; `createComponent`
1064
+ * is exported from the `solid-js` root in both majors, and the provider component
1065
+ * itself is resolved per-major by {@link providerOf}. The `get` accessors keep
1066
+ * both props lazy, so swapping the `client` prop re-provides the new value to
1067
+ * descendants exactly as the JSX form did.
1024
1068
  */
1025
- declare const LunoraProvider: (props: LunoraProviderProps) => JSX.Element;
1069
+ declare const LunoraProvider: (props: LunoraProviderProps) => SolidElement;
1026
1070
  export { type ActionClient, type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type CreateAgentApi, type CreateAgentChatApi, type CreateAgentChatOptions, type CreateAgentChatResult, type CreateAgentOptions, type CreateAgentResult, type CreateAgentStateApi, type CreateAgentStateOptions, type CreateAgentStateResult, type CreateAgentToolEventsApi, type CreateAgentToolEventsOptions, type CreateAgentToolEventsResult, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreatePaginatedQueryOptions, type CreatePaginatedQueryResult, type CreatePresenceOptions, type CreatePresenceResult, type CreateQueryOptions, type CreateRateLimitOptions, type CreateRateLimitResult, type CreateStreamOptions, type CreateStreamResult, type CreateStreamStatus, type CreateSubscriptionResult, type CreateVoiceAgentOptions, type CreateVoiceAgentResult, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraContext, LunoraProvider,
1027
1071
  /**
1028
1072
  * SolidJS adapter for Lunora.
@@ -1042,4 +1086,4 @@ export { type ActionClient, type ActionHandle, type AgentChatMessage, type Agent
1042
1086
  * framework-neutral server contract) — call it from your SolidStart route loader
1043
1087
  * and hand the resulting `Preloaded` token to `hydratePreloaded`.
1044
1088
  */
1045
- type LunoraProviderProps, type MutationClient, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, createAction, createActionForClient, createAgent, createAgentChat, createAgentState, createAgentToolEvents, createAuth, createConnectionStatus, createFlag, createFlags, createInfiniteQuery, createMutation, createMutationForClient, createMutator, createPaginatedQuery, createPresence, createQuery, createRateLimit, createStream, createSubscription, createVoiceAgent, hydratePreloaded, useLunora };
1089
+ type LunoraProviderProps, type MutationClient, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, type SolidChildren, Unauthenticated, type UseAuthResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, createAction, createActionForClient, createAgent, createAgentChat, createAgentState, createAgentToolEvents, createAuth, createConnectionStatus, createFlag, createFlags, createInfiniteQuery, createMutation, createMutationForClient, createMutator, createPaginatedQuery, createPresence, createQuery, createRateLimit, createStream, createSubscription, createVoiceAgent, hydratePreloaded, useLunora };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LunoraClient, FunctionReference, ArgsOf, ActionCallOptions, ReturnOf, User, ConnectionStatus, MutationCallOptions, MutatorHandle, Preloaded } from '@lunora/client';
2
2
  export type { ArgsOf, FunctionReference, MutatorHandle, MutatorTransaction, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe } from '@lunora/client';
3
- import { Context, Accessor, JSX } from 'solid-js';
3
+ import { Context, Accessor } from 'solid-js';
4
4
  import { PaginationStatus } from '@lunora/client/pagination';
5
5
  import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
6
6
  /**
@@ -10,7 +10,8 @@ import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
10
10
  * `<LunoraProvider client={…}>` at the root of the tree wires the whole app.
11
11
  *
12
12
  * Defaults to `undefined` so {@link useLunora} can throw a helpful error when a
13
- * primitive is used outside a provider rather than dereferencing it.
13
+ * primitive is used outside a provider rather than dereferencing it. Solid 2
14
+ * refuses to hand back an `undefined` default at all — see {@link useLunora}.
14
15
  */
15
16
  declare const LunoraContext: Context<LunoraClient | undefined>;
16
17
  /**
@@ -465,6 +466,33 @@ interface CreateAgentToolEventsResult {
465
466
  * + approvals) use `createAgentChat`; this primitive is the tool-observability slice.
466
467
  */
467
468
  declare const createAgentToolEvents: (options: CreateAgentToolEventsOptions) => CreateAgentToolEventsResult;
469
+ /**
470
+ * Children accepted by this adapter's components.
471
+ *
472
+ * Structurally identical to Solid 2.0's `Element`, which is in turn a widening
473
+ * of 1.x's `JSX.Element` (a DOM `Node` satisfies `object` with no
474
+ * `call`/`apply`/`bind`). Children are contravariant, so one union that accepts
475
+ * both majors' element types is enough — no `any` required here.
476
+ */
477
+ type SolidChildren = SolidChildrenArray | boolean | null | number | (object & {
478
+ readonly apply?: never;
479
+ readonly bind?: never;
480
+ readonly call?: never;
481
+ }) | (string & {}) | undefined;
482
+ interface SolidChildrenArray extends Array<SolidChildren> {}
483
+ /**
484
+ * The return type of this adapter's components.
485
+ *
486
+ * Deliberately `any`, and the one place in the package where that is the right
487
+ * answer. TypeScript checks a component's return type against the *renderer's*
488
+ * `JSX.Element`, and the two majors define that incompatibly — 1.x's is rooted
489
+ * in the DOM `Node` interface, 2.0's in an opaque `RenderedElement`. Neither is
490
+ * assignable to the other, so no concrete type satisfies both, and a structural
491
+ * union (as used for {@link SolidChildren}) fails in the return position. `any`
492
+ * is what lets one set of `.d.ts` files type-check inside a 1.x app and a 2.x
493
+ * app alike.
494
+ */
495
+ type SolidElement = any;
468
496
  interface UseAuthResult {
469
497
  setToken: (token: string | null) => void;
470
498
  token: Accessor<string | null>;
@@ -478,23 +506,25 @@ interface UseAuthResult {
478
506
  */
479
507
  declare const createAuth: () => UseAuthResult;
480
508
  interface AuthGateProps {
481
- children: JSX.Element;
509
+ children: SolidChildren;
482
510
  }
511
+ /** An auth-gate component: renders its children only while the gate's condition holds. */
512
+ type AuthGate = (props: AuthGateProps) => SolidElement;
483
513
  /**
484
514
  * Render `children` only after authentication has settled and a token + user
485
515
  * are both present.
486
516
  */
487
- declare const Authenticated: (props: AuthGateProps) => JSX.Element;
517
+ declare const Authenticated: AuthGate;
488
518
  /**
489
519
  * Render `children` while authentication is still in progress — token is set
490
520
  * but the user has not yet resolved.
491
521
  */
492
- declare const AuthLoading: (props: AuthGateProps) => JSX.Element;
522
+ declare const AuthLoading: AuthGate;
493
523
  /**
494
524
  * Render `children` only when auth has settled and no token is present (the
495
525
  * signed-out state).
496
526
  */
497
- declare const Unauthenticated: (props: AuthGateProps) => JSX.Element;
527
+ declare const Unauthenticated: AuthGate;
498
528
  /**
499
529
  * Reactive accessor of the client's aggregate live-socket status across all
500
530
  * shard connections. Reads the current status synchronously and updates on
@@ -502,8 +532,14 @@ declare const Unauthenticated: (props: AuthGateProps) => JSX.Element;
502
532
  * fine-grained signals mean only the components that read the accessor
503
533
  * re-render. The Solid equivalent of `@lunora/react`'s `useConnectionStatus`.
504
534
  *
505
- * The status listener is torn down via `onCleanup` when the owning reactive
506
- * scope disposes (component unmount). Call inside a component / reactive root.
535
+ * The listener is registered at **mount**, not in the component body, because
536
+ * `onConnectionStatus` invokes it synchronously on subscribe: Solid 2 rejects a
537
+ * signal write inside an owned scope (`REACTIVE_WRITE_IN_OWNED_SCOPE`) and — since
538
+ * the throw escapes render — halts the reactive system for the whole page, not
539
+ * just this component. Nothing is missed by waiting: the initial value comes
540
+ * from `client.connectionStatus()`, and the immediate callback re-syncs at
541
+ * mount. Torn down when the owning scope disposes. Call inside a component /
542
+ * reactive root.
507
543
  */
508
544
  declare const createConnectionStatus: () => Accessor<ConnectionStatus>;
509
545
  /** A targeting context merged on top of the app's default (`defineFlags({ identify })`). */
@@ -978,9 +1014,9 @@ declare const createVoiceAgent: (options: CreateVoiceAgentOptions) => CreateVoic
978
1014
  * returned accessor is seeded **synchronously** from `preloaded.value`, so the
979
1015
  * very first read — during hydration — returns the server-rendered value with
980
1016
  * no loading flash and no `Suspense` fallback (unlike `createResource`, which
981
- * always starts pending). After the component mounts, a WebSocket subscription
982
- * attaches in an effect and every subsequent server delta flows into the same
983
- * signal, so the UI goes live with zero refetch.
1017
+ * always starts pending). Once the component mounts, a WebSocket subscription
1018
+ * attaches and every subsequent server delta flows into the same signal, so the
1019
+ * UI goes live with zero refetch.
984
1020
  *
985
1021
  * ```tsx
986
1022
  * // route loader (server): const preloaded = await preloadQuery(client, api.messages.list, args);
@@ -988,13 +1024,13 @@ declare const createVoiceAgent: (options: CreateVoiceAgentOptions) => CreateVoic
988
1024
  * return <pre>{JSON.stringify(messages())}</pre>;
989
1025
  * ```
990
1026
  *
991
- * Effects do not run on the server during SSR (Solid only runs them after
992
- * hydration), so the subscription is strictly client-side — the seed is the
993
- * only value the server render ever sees.
1027
+ * Mount callbacks do not run on the server during SSR (both Solid majors defer
1028
+ * them until after hydration), so the subscription is strictly client-side —
1029
+ * the seed is the only value the server render ever sees.
994
1030
  */
995
1031
  declare const hydratePreloaded: <T>(preloaded: Preloaded<T>) => Accessor<T>;
996
1032
  interface LunoraProviderProps {
997
- children: JSX.Element;
1033
+ children: SolidChildren;
998
1034
  /**
999
1035
  * The framework-neutral transport. Build it once at the app root with
1000
1036
  * `new LunoraClient({ url })` (or `createServerClient` during SSR) and pass
@@ -1021,8 +1057,16 @@ interface LunoraProviderProps {
1021
1057
  * </LunoraProvider>
1022
1058
  * ), root);
1023
1059
  * ```
1060
+ *
1061
+ * Written with `createComponent` rather than JSX on purpose. Solid 1.x and 2.0
1062
+ * compile JSX against different runtimes (`solid-js/web` vs `@solidjs/web`), so
1063
+ * a JSX source file would force this package to ship two builds; `createComponent`
1064
+ * is exported from the `solid-js` root in both majors, and the provider component
1065
+ * itself is resolved per-major by {@link providerOf}. The `get` accessors keep
1066
+ * both props lazy, so swapping the `client` prop re-provides the new value to
1067
+ * descendants exactly as the JSX form did.
1024
1068
  */
1025
- declare const LunoraProvider: (props: LunoraProviderProps) => JSX.Element;
1069
+ declare const LunoraProvider: (props: LunoraProviderProps) => SolidElement;
1026
1070
  export { type ActionClient, type ActionHandle, type AgentChatMessage, type AgentLiveEvent, type AgentProgressEvent, type AgentThreadRecord, type AgentThreadStatus, type AgentTokenDelta, type AgentToolEvent, AuthLoading, Authenticated, type CreateAgentApi, type CreateAgentChatApi, type CreateAgentChatOptions, type CreateAgentChatResult, type CreateAgentOptions, type CreateAgentResult, type CreateAgentStateApi, type CreateAgentStateOptions, type CreateAgentStateResult, type CreateAgentToolEventsApi, type CreateAgentToolEventsOptions, type CreateAgentToolEventsResult, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreatePaginatedQueryOptions, type CreatePaginatedQueryResult, type CreatePresenceOptions, type CreatePresenceResult, type CreateQueryOptions, type CreateRateLimitOptions, type CreateRateLimitResult, type CreateStreamOptions, type CreateStreamResult, type CreateStreamStatus, type CreateSubscriptionResult, type CreateVoiceAgentOptions, type CreateVoiceAgentResult, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraContext, LunoraProvider,
1027
1071
  /**
1028
1072
  * SolidJS adapter for Lunora.
@@ -1042,4 +1086,4 @@ export { type ActionClient, type ActionHandle, type AgentChatMessage, type Agent
1042
1086
  * framework-neutral server contract) — call it from your SolidStart route loader
1043
1087
  * and hand the resulting `Preloaded` token to `hydratePreloaded`.
1044
1088
  */
1045
- type LunoraProviderProps, type MutationClient, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, createAction, createActionForClient, createAgent, createAgentChat, createAgentState, createAgentToolEvents, createAuth, createConnectionStatus, createFlag, createFlags, createInfiniteQuery, createMutation, createMutationForClient, createMutator, createPaginatedQuery, createPresence, createQuery, createRateLimit, createStream, createSubscription, createVoiceAgent, hydratePreloaded, useLunora };
1089
+ type LunoraProviderProps, type MutationClient, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, type SolidChildren, Unauthenticated, type UseAuthResult, type VoiceAudioFormat, type VoiceReference, type VoiceStatus, createAction, createActionForClient, createAgent, createAgentChat, createAgentState, createAgentToolEvents, createAuth, createConnectionStatus, createFlag, createFlags, createInfiniteQuery, createMutation, createMutationForClient, createMutator, createPaginatedQuery, createPresence, createQuery, createRateLimit, createStream, createSubscription, createVoiceAgent, hydratePreloaded, useLunora };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{LunoraContext as r,useLunora as o}from"./packem_shared/LunoraContext-Ck27Dk1M.mjs";import{createAction as c,createActionForClient as n}from"./packem_shared/createAction-CbGirc8n.mjs";import{createAgent as m}from"./packem_shared/createAgent-CvY_sduu.mjs";import{createAgentChat as x}from"./packem_shared/createAgentChat-BONQ21Fr.mjs";import{createAgentState as u}from"./packem_shared/createAgentState-D6iGuFht.mjs";import{createAgentToolEvents as A}from"./packem_shared/createAgentToolEvents-Beu0Hk7M.mjs";import{AuthLoading as l,Authenticated as s,Unauthenticated as h,createAuth as C}from"./packem_shared/AuthLoading-Cw7P46Me.mjs";import{default as y}from"./packem_shared/createConnectionStatus-atEsI2Uf.mjs";import{createFlag as P,createFlags as S}from"./packem_shared/createFlag-Budmp0PL.mjs";import{createMutation as Q,createMutationForClient as v}from"./packem_shared/createMutation-DE50ca4x.mjs";import{createMutator as E}from"./packem_shared/createMutator-q9cMjGKv.mjs";import{createInfiniteQuery as R,createPaginatedQuery as T}from"./packem_shared/createInfiniteQuery-BvSHuI_n.mjs";import{createPresence as V}from"./packem_shared/createPresence-DexXIxGo.mjs";import{createQuery as k}from"./packem_shared/createQuery-Mf7pD2Wc.mjs";import{createRateLimit as w}from"./packem_shared/createRateLimit-CIVWrD5H.mjs";import{createStream as B}from"./packem_shared/createStream-wnMAf-xL.mjs";import{createSubscription as G}from"./packem_shared/createSubscription-CkJjcYO4.mjs";import{createVoiceAgent as J}from"./packem_shared/createVoiceAgent-zdX0zuEH.mjs";import{default as N}from"./packem_shared/hydratePreloaded-DaixZhLe.mjs";import{LunoraProvider as W}from"./packem_shared/LunoraProvider-DMXdQNLA.mjs";export{l as AuthLoading,s as Authenticated,r as LunoraContext,W as LunoraProvider,h as Unauthenticated,c as createAction,n as createActionForClient,m as createAgent,x as createAgentChat,u as createAgentState,A as createAgentToolEvents,C as createAuth,y as createConnectionStatus,P as createFlag,S as createFlags,R as createInfiniteQuery,Q as createMutation,v as createMutationForClient,E as createMutator,T as createPaginatedQuery,V as createPresence,k as createQuery,w as createRateLimit,B as createStream,G as createSubscription,J as createVoiceAgent,N as hydratePreloaded,o as useLunora};
1
+ import{LunoraContext as r,useLunora as o}from"./packem_shared/LunoraContext-dPcjtn6R.mjs";import{createAction as c,createActionForClient as n}from"./packem_shared/createAction-M4s8XBXV.mjs";import{createAgent as m}from"./packem_shared/createAgent-DTUKko5X.mjs";import{createAgentChat as x}from"./packem_shared/createAgentChat-BjVMwDVY.mjs";import{createAgentState as u}from"./packem_shared/createAgentState-DIknFZyn.mjs";import{createAgentToolEvents as A}from"./packem_shared/createAgentToolEvents-BZDqkzK6.mjs";import{AuthLoading as l,Authenticated as s,Unauthenticated as h,createAuth as C}from"./packem_shared/AuthLoading-6vueEnV0.mjs";import{default as y}from"./packem_shared/createConnectionStatus-BnlXYWeE.mjs";import{createFlag as P,createFlags as S}from"./packem_shared/createFlag-l_riySES.mjs";import{createMutation as Q,createMutationForClient as v}from"./packem_shared/createMutation-DcSsIbGF.mjs";import{createMutator as E}from"./packem_shared/createMutator-q9cMjGKv.mjs";import{createInfiniteQuery as R,createPaginatedQuery as T}from"./packem_shared/createInfiniteQuery-CAU4Yr4Z.mjs";import{createPresence as V}from"./packem_shared/createPresence-Da_DdL7L.mjs";import{createQuery as k}from"./packem_shared/createQuery-DnfKuyeU.mjs";import{createRateLimit as w}from"./packem_shared/createRateLimit-CIVWrD5H.mjs";import{createStream as B}from"./packem_shared/createStream-B10b3ijV.mjs";import{createSubscription as G}from"./packem_shared/createSubscription-D9e8lT1C.mjs";import{createVoiceAgent as J}from"./packem_shared/createVoiceAgent-BjL6DH05.mjs";import{default as N}from"./packem_shared/hydratePreloaded-CnJNitir.mjs";import{LunoraProvider as W}from"./packem_shared/LunoraProvider-BKWckcDR.mjs";export{l as AuthLoading,s as Authenticated,r as LunoraContext,W as LunoraProvider,h as Unauthenticated,c as createAction,n as createActionForClient,m as createAgent,x as createAgentChat,u as createAgentState,A as createAgentToolEvents,C as createAuth,y as createConnectionStatus,P as createFlag,S as createFlags,R as createInfiniteQuery,Q as createMutation,v as createMutationForClient,E as createMutator,T as createPaginatedQuery,V as createPresence,k as createQuery,w as createRateLimit,B as createStream,G as createSubscription,J as createVoiceAgent,N as hydratePreloaded,o as useLunora};
@@ -0,0 +1 @@
1
+ import{getIdentityStore as i}from"@lunora/client/auth";import{createSignal as r,onCleanup as g,createComponent as k,Show as m}from"solid-js";import{useLunora as T}from"./LunoraContext-dPcjtn6R.mjs";const d=()=>{const t=T(),e=i(t),[n,u]=r(t.getAuthToken()),[c,l]=r(e.getUser()),a=t.onAuthTokenChange(o=>{u(()=>o)}),h=e.subscribe(()=>{l(()=>e.getUser())});return g(()=>{a(),h()}),{setToken:o=>{t.setAuthToken(o)},token:n,user:c}},f=m,s=t=>e=>{const n=d();return k(f,{get children(){return e.children},get when(){return t(n)}})},b=s(({token:t,user:e})=>t()===null?!1:e()!==null),w=s(({token:t,user:e})=>t()===null?!1:e()===null),C=s(({token:t,user:e})=>t()===null?e()===null:!1);export{w as AuthLoading,b as Authenticated,C as Unauthenticated,d as createAuth};
@@ -0,0 +1 @@
1
+ import{LunoraError as o}from"@lunora/errors";import{createContext as t,useContext as e}from"solid-js";const n=t(),s=()=>{let r;try{r=e(n)}catch{r=void 0}if(!r)throw new o("INTERNAL","useLunora must be used inside <LunoraProvider />");return r};export{n as LunoraContext,s as useLunora};
@@ -0,0 +1 @@
1
+ import{createComponent as e}from"solid-js";import{LunoraContext as o}from"./LunoraContext-dPcjtn6R.mjs";import{p as t}from"./solid-compat-ByG5HD_F.mjs";const a=r=>e(t(o),{get children(){return r.children},get value(){return r.client}});export{a as LunoraProvider};
@@ -1 +1 @@
1
- import{createCallRunner as m}from"@lunora/client";import{createSignal as r}from"solid-js";import{useLunora as p}from"./LunoraContext-Ck27Dk1M.mjs";const u=(t,c)=>{const[s,n]=r(void 0),[a,e]=r(void 0),[i,l]=r(!1);return{call:m((o,d)=>t.action(c,o,d),{setError:e,setPending:l,setResult:o=>{n(()=>o),e(void 0)}}),data:s,error:a,pending:i,reset:()=>{n(()=>{}),e(void 0)}}},R=t=>u(p(),t);export{R as createAction,u as createActionForClient};
1
+ import{createCallRunner as m}from"@lunora/client";import{createSignal as r}from"solid-js";import{useLunora as p}from"./LunoraContext-dPcjtn6R.mjs";const u=(t,c)=>{const[s,n]=r(void 0),[a,e]=r(void 0),[i,l]=r(!1);return{call:m((o,d)=>t.action(c,o,d),{setError:e,setPending:l,setResult:o=>{n(()=>o),e(void 0)}}),data:s,error:a,pending:i,reset:()=>{n(()=>{}),e(void 0)}}},R=t=>u(p(),t);export{R as createAction,u as createActionForClient};
@@ -1 +1 @@
1
- import{createMemo as s}from"solid-js";import{createMutation as i}from"./createMutation-DE50ca4x.mjs";import{createSubscription as M}from"./createSubscription-CkJjcYO4.mjs";const l={__lunoraRef:""},c=t=>typeof t=="function"?t():t,K=t=>{const{api:u,cancel:r,run:d,runArgs:f,threadKey:n}=t,o=i(d),m=i(r??l),{data:p}=M(u.agents.agentThread,()=>({key:c(n)})),a=s(()=>p()),y=s(()=>a()?.status),g=async(e,h)=>{await o.mutate({input:e,threadKey:c(n),...f,...h})};return{cancel:async()=>{const e=a()?.instanceId;r===void 0||e===void 0||await m.mutate({instanceId:e,threadKey:c(n)})},pending:o.pending,run:g,status:y,thread:a}};export{l as NO_MUTATION_REF,K as createAgent,c as resolveMaybe};
1
+ import{createMemo as s}from"solid-js";import{createMutation as i}from"./createMutation-DcSsIbGF.mjs";import{createSubscription as M}from"./createSubscription-D9e8lT1C.mjs";const l={__lunoraRef:""},c=t=>typeof t=="function"?t():t,K=t=>{const{api:u,cancel:r,run:d,runArgs:f,threadKey:n}=t,o=i(d),m=i(r??l),{data:p}=M(u.agents.agentThread,()=>({key:c(n)})),a=s(()=>p()),y=s(()=>a()?.status),g=async(e,h)=>{await o.mutate({input:e,threadKey:c(n),...f,...h})};return{cancel:async()=>{const e=a()?.instanceId;r===void 0||e===void 0||await m.mutate({instanceId:e,threadKey:c(n)})},pending:o.pending,run:g,status:y,thread:a}};export{l as NO_MUTATION_REF,K as createAgent,c as resolveMaybe};
@@ -1 +1 @@
1
- import{reconcileOptimistic as v,maxSeq as A}from"@lunora/client";import{createSignal as F,createMemo as c}from"solid-js";import{resolveMaybe as a,NO_MUTATION_REF as U}from"./createAgent-CvY_sduu.mjs";import{createMutation as u}from"./createMutation-DE50ca4x.mjs";import{createStream as $}from"./createStream-wnMAf-xL.mjs";import{createSubscription as M}from"./createSubscription-CkJjcYO4.mjs";const z={__lunoraRef:""},X=R=>{const{api:m,cancel:l,limit:p,send:S,sendArgs:k,stream:h,threadKey:r}=R,{data:w}=M(m.agents.agentMessages,()=>{const t=a(r);return p===void 0?{key:t}:{key:t,limit:p}}),{data:x}=M(m.agents.agentThread,()=>({key:a(r)})),I=h===void 0?"skip":()=>({key:a(r)}),{chunks:b}=$(h??z,I),_=u(S),K=u(l??U),O=u(m.agents.agentResolveApproval),[T,g]=F([]);let f=0;const d=c(()=>x()),j=c(()=>d()?.status),i=c(()=>w()??[]),q=c(()=>{const t=i(),n=v(T(),t);if(n.length===0)return t;const e=A(t);return[...t,...n.map((s,o)=>({content:s.content,optimistic:!0,role:"user",seq:e+1+o}))]}),E=c(()=>{const t=a(r),n=i().filter(e=>e.role==="assistant").length;return b().filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=n).map(e=>e.text).join("")}),C=async(t,n)=>{const e=f;f+=1;const s=A(i());g(o=>[...v(o,i()),{content:t,id:e,maxDurableSeqAtSend:s}]);try{await _.mutate({input:t,threadKey:a(r),...k,...n})}catch(o){throw g(D=>D.filter(N=>N.id!==e)),o}},y=async(t,n,e)=>{const s=d()?.instanceId;if(s===void 0)throw new Error(`createAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await O.mutate({decision:t,instanceId:s,threadKey:a(r),toolCallId:n,...e===void 0?{}:{note:e}})};return{approve:async(t,n)=>y("approve",t,n),cancel:async()=>{const t=d()?.instanceId;l===void 0||t===void 0||await K.mutate({instanceId:t,threadKey:a(r)})},messages:q,reject:async(t,n)=>y("reject",t,n),send:C,status:j,streamingText:E}};export{X as createAgentChat};
1
+ import{reconcileOptimistic as v,maxSeq as A}from"@lunora/client";import{createSignal as F,createMemo as c}from"solid-js";import{resolveMaybe as a,NO_MUTATION_REF as U}from"./createAgent-DTUKko5X.mjs";import{createMutation as u}from"./createMutation-DcSsIbGF.mjs";import{createStream as $}from"./createStream-B10b3ijV.mjs";import{createSubscription as M}from"./createSubscription-D9e8lT1C.mjs";const z={__lunoraRef:""},X=R=>{const{api:m,cancel:l,limit:p,send:S,sendArgs:k,stream:h,threadKey:r}=R,{data:w}=M(m.agents.agentMessages,()=>{const t=a(r);return p===void 0?{key:t}:{key:t,limit:p}}),{data:x}=M(m.agents.agentThread,()=>({key:a(r)})),I=h===void 0?"skip":()=>({key:a(r)}),{chunks:b}=$(h??z,I),_=u(S),K=u(l??U),O=u(m.agents.agentResolveApproval),[T,g]=F([]);let f=0;const d=c(()=>x()),j=c(()=>d()?.status),i=c(()=>w()??[]),q=c(()=>{const t=i(),n=v(T(),t);if(n.length===0)return t;const e=A(t);return[...t,...n.map((s,o)=>({content:s.content,optimistic:!0,role:"user",seq:e+1+o}))]}),E=c(()=>{const t=a(r),n=i().filter(e=>e.role==="assistant").length;return b().filter(e=>e.kind!=="progress"&&e.threadKey===t&&e.turn>=n).map(e=>e.text).join("")}),C=async(t,n)=>{const e=f;f+=1;const s=A(i());g(o=>[...v(o,i()),{content:t,id:e,maxDurableSeqAtSend:s}]);try{await _.mutate({input:t,threadKey:a(r),...k,...n})}catch(o){throw g(D=>D.filter(N=>N.id!==e)),o}},y=async(t,n,e)=>{const s=d()?.instanceId;if(s===void 0)throw new Error(`createAgentChat: cannot ${t} — no in-flight run (thread has no instanceId)`);await O.mutate({decision:t,instanceId:s,threadKey:a(r),toolCallId:n,...e===void 0?{}:{note:e}})};return{approve:async(t,n)=>y("approve",t,n),cancel:async()=>{const t=d()?.instanceId;l===void 0||t===void 0||await K.mutate({instanceId:t,threadKey:a(r)})},messages:q,reject:async(t,n)=>y("reject",t,n),send:C,status:j,streamingText:E}};export{X as createAgentChat};
@@ -1 +1 @@
1
- import{createMemo as o}from"solid-js";import{resolveMaybe as n}from"./createAgent-CvY_sduu.mjs";import{createSubscription as c}from"./createSubscription-CkJjcYO4.mjs";const p=e=>{const{data:t,error:r}=c(e.api.agents.agentState,()=>({key:n(e.threadKey)})),a=o(()=>t());return{error:r,state:a}};export{p as createAgentState};
1
+ import{createMemo as o}from"solid-js";import{resolveMaybe as n}from"./createAgent-DTUKko5X.mjs";import{createSubscription as c}from"./createSubscription-D9e8lT1C.mjs";const p=e=>{const{data:t,error:r}=c(e.api.agents.agentState,()=>({key:n(e.threadKey)})),a=o(()=>t());return{error:r,state:a}};export{p as createAgentState};
@@ -1 +1 @@
1
- import{createMemo as v}from"solid-js";import{resolveMaybe as n}from"./createAgent-CvY_sduu.mjs";import{createStream as f}from"./createStream-wnMAf-xL.mjs";import{createSubscription as y}from"./createSubscription-CkJjcYO4.mjs";const C={__lunoraRef:""},I=[],N=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(r=>({input:r.input,seq:t.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]},_=t=>{const{api:r,limit:a,stream:i,threadKey:e}=t,u=()=>{const l=n(e);return a===void 0?{key:l}:{key:l,limit:a}},{data:p}=y(r.agents.agentMessages,u),s=i===void 0?"skip":()=>({key:n(e)}),{chunks:c}=f(i??C,s);return{events:v(()=>{const l=n(e),d=(p()??I).flatMap(o=>N(o)??[]);for(const o of c())o.kind==="progress"&&o.threadKey===l&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}};export{_ as createAgentToolEvents};
1
+ import{createMemo as v}from"solid-js";import{resolveMaybe as n}from"./createAgent-DTUKko5X.mjs";import{createStream as f}from"./createStream-B10b3ijV.mjs";import{createSubscription as y}from"./createSubscription-D9e8lT1C.mjs";const C={__lunoraRef:""},I=[],N=t=>{if(t.role==="assistant"&&t.toolCalls)return t.toolCalls.map(r=>({input:r.input,seq:t.seq,toolCallId:r.id,toolName:r.name,type:"call"}));if(t.role==="tool")return t.status==="awaiting_approval"?[{seq:t.seq,type:"awaiting-approval",...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]:[{output:t.content,seq:t.seq,type:"result",...t.status==="approved"||t.status==="rejected"?{status:t.status}:{},...t.toolCallId===void 0?{}:{toolCallId:t.toolCallId},...t.toolName===void 0?{}:{toolName:t.toolName}}]},_=t=>{const{api:r,limit:a,stream:i,threadKey:e}=t,u=()=>{const l=n(e);return a===void 0?{key:l}:{key:l,limit:a}},{data:p}=y(r.agents.agentMessages,u),s=i===void 0?"skip":()=>({key:n(e)}),{chunks:c}=f(i??C,s);return{events:v(()=>{const l=n(e),d=(p()??I).flatMap(o=>N(o)??[]);for(const o of c())o.kind==="progress"&&o.threadKey===l&&d.push({data:o.data,toolCallId:o.toolCallId,type:"progress"});return d})}};export{_ as createAgentToolEvents};
@@ -0,0 +1 @@
1
+ import{createSignal as s}from"solid-js";import{useLunora as a}from"./LunoraContext-dPcjtn6R.mjs";import{o as r}from"./solid-compat-ByG5HD_F.mjs";const m=()=>{const t=a(),[o,n]=s(t.connectionStatus());return r(()=>t.onConnectionStatus(e=>{n(e)})),o};export{m as default};
@@ -0,0 +1 @@
1
+ import{createSignal as l}from"solid-js";import{s as m}from"./stable-key-ITGZkfuz.mjs";import{useLunora as p}from"./LunoraContext-dPcjtn6R.mjs";import{resolveMaybe as n}from"./createAgent-DTUKko5X.mjs";import{t as y}from"./solid-compat-ByG5HD_F.mjs";const $="__lunora_flags__:eval",_=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},v={__lunoraRef:$},d=t=>t===void 0?"":m(t),F=(t,e,s)=>{const a=p(),c=_(e),[b,u]=l(e);return y(()=>`${n(t)} ${d(n(s))}`,()=>{const i=n(t),r=n(s);u(()=>e);let o;try{o=a.subscribe(v,{context:r,default:e,key:i,type:c},f=>{u(()=>f)})}catch{return}return o}),b},L=(t,e)=>{const s=p(),[a,c]=l(t),b=m(t);return y(()=>`${b} ${d(n(e))}`,()=>{const u=n(e);c(()=>t);const i=[];for(const[r,o]of Object.entries(t))try{i.push(s.subscribe(v,{context:u,default:o,key:r,type:_(o)},f=>{c(g=>({...g,[r]:f}))}))}catch{}return()=>{for(const r of i)r()}}),a};export{F as createFlag,L as createFlags};
@@ -0,0 +1 @@
1
+ import{initialPages as T,derivePaginationStatus as B,applyLoadMore as z,rebalance as G}from"@lunora/client/pagination";import{createMemo as A,createSignal as U}from"solid-js";import{s as H}from"./stable-key-ITGZkfuz.mjs";import{useLunora as V}from"./LunoraContext-dPcjtn6R.mjs";import{t as $}from"./solid-compat-ByG5HD_F.mjs";const E=e=>{let n="";for(let u=0;u<e.length;u+=32768)n+=String.fromCharCode(...e.subarray(u,u+32768));return btoa(n)},f="$lunora.wire$",F=64,X="__proto__",Y=e=>{if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n===null||n===Object.prototype},P=(e,n=0)=>{if(n>F)throw new RangeError(`wire-codec: value nesting exceeds the ${F}-level limit`);if(e===void 0)return[f,"undefined"];if(e===null)return null;const l=typeof e;if(l==="bigint")return[f,"bigint",e.toString()];if(l==="number"){const t=e;return Number.isNaN(t)?[f,"nan"]:t===1/0?[f,"inf"]:t===-1/0?[f,"-inf"]:t}if(l!=="object")return e;if(e instanceof Date)return[f,"date",P(e.getTime(),n+1)];if(e instanceof Error){const t=e,r={};for(const d of Object.keys(t))t[d]!==void 0&&(r[d]=P(t[d],n+1));const o=[f,"error",t.name,t.message,r];return t.cause!==void 0&&o.push(P(t.cause,n+1)),o}if(e instanceof URL)return[f,"url",e.href];if(e instanceof Map)return[f,"map",[...e.entries()].map(([t,r])=>[P(t,n+1),P(r,n+1)])];if(e instanceof Set)return[f,"set",[...e].map(t=>P(t,n+1))];if(e instanceof ArrayBuffer)return[f,"bytes",E(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,r=t.constructor.name,o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return r==="Uint8Array"?[f,"bytes",E(o)]:[f,"bytes",E(o),r]}if(Array.isArray(e)){const t=e.map(r=>P(r,n+1));return t.length>0&&t[0]===f?[f,"arr",t]:t}if(!Y(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,m={};for(const t of Object.keys(u)){const r=u[t];if(r===void 0)continue;const o=P(r,n+1);t===X?Object.defineProperty(m,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):m[t]=o}return m},J=e=>H(P(e)),h=(e,n)=>({...n,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),L=(e,n)=>`${e}::${J(n)}`,D=(e,n,l)=>{const u=V(),{initialNumItems:m,shardKey:t}=l,r=()=>typeof n=="function"?n():n,[o,d]=U(T(m)),g=new Map,[M,N]=U([]),y=new Map,S=new Set,x=(s,c)=>{const p=s.map(i=>{const a=L(e.__lunoraRef,h(i,c));return g.get(a)});N(p)},Q=(s,c,p)=>{const i=a=>L(e.__lunoraRef,h(a,p));for(const a of c){const b=i(a);if(g.has(b))continue;const k=s.find(w=>w.lower===a.lower);if(k){const w=g.get(i(k));w&&g.set(b,w)}}},W=(s,c)=>{const p=new Set;for(const i of s)p.add(L(e.__lunoraRef,h(i,c)));for(const[i,a]of y)p.has(i)||(a(),y.delete(i),S.delete(i),g.delete(i));for(const i of s){const a=h(i,c),b=L(e.__lunoraRef,a);if(y.has(b))continue;S.add(b);const k=u.subscribe(e,a,w=>{g.set(b,w),S.delete(b);const R=r();if(R!=="skip"&&(x(o(),R),S.size===0)){const _=o(),j=G(_,M());j&&(Q(_,j,R),d(j))}},{shardKey:t});y.set(b,k)}};let K=!1,O=!1;const C=(s,c)=>{if(K){O=!0;return}K=!0;try{let p=s,i=c;do{O=!1,W(p,i);const a=r();if(a==="skip")break;p=o(),i=a}while(O)}finally{K=!1}},I=()=>{for(const s of y.values())s();y.clear(),g.clear(),S.clear()};$(r,s=>(I(),d(T(m)),N([]),s!=="skip"&&(C(o(),s),x(o(),s)),I)),$(o,s=>{const c=r();c!=="skip"&&(C(s,c),x(s,c))});const q=A(()=>{const s=r()==="skip";return B(s,M()).status});return{loadMore:s=>{const c=r();if(c==="skip")return;const{nextCursor:p,status:i}=B(!1,M());if(i!=="CanLoadMore")return;const a=z(o(),p,s);if(!a)return;const b=o().at(-1),k=a.at(-2);if(b&&k){const w=L(e.__lunoraRef,h(b,c)),R=L(e.__lunoraRef,h(k,c));if(w!==R){const _=g.get(w);_&&g.set(R,_)}}d(a)},pageResults:M,status:q}},se=(e,n,l)=>{const{loadMore:u,pageResults:m,status:t}=D(e,n,l),r=A(()=>m().flatMap(d=>d?.page??[]));return{isLoading:A(()=>t()==="LoadingFirstPage"||t()==="LoadingMore"),loadMore:u,results:r,status:t}},oe=(e,n,l)=>{const{initialNumItems:u}=l,{loadMore:m,pageResults:t,status:r}=D(e,n,l),o=A(()=>t().flatMap(y=>y?[y.page]:[])),d=A(()=>r()==="LoadingFirstPage"),g=A(()=>r()==="CanLoadMore"),M=A(()=>r()==="LoadingMore");return{fetchNextPage:y=>{m(y??u)},hasNextPage:g,isFetchingNextPage:M,isLoading:d,pages:o,status:r}};export{oe as createInfiniteQuery,se as createPaginatedQuery};
@@ -1 +1 @@
1
- import{createCallRunner as l}from"@lunora/client";import{createSignal as s}from"solid-js";import{useLunora as p}from"./LunoraContext-Ck27Dk1M.mjs";const v=(e,o)=>{const[r,t]=s(void 0),[n,a]=s(void 0),[c,u]=s(!1),m=l((i,d)=>e.mutation(o,i,d),{setError:a,setPending:u,setResult:i=>{t(()=>i),a(void 0)}});return{data:r,error:n,mutate:m,pending:c,reset:()=>{t(()=>{}),a(void 0)}}},R=e=>{const o=p();return v({mutation:(r,t,n)=>o.mutation(r,t,n)},e)};export{R as createMutation,v as createMutationForClient};
1
+ import{createCallRunner as l}from"@lunora/client";import{createSignal as s}from"solid-js";import{useLunora as p}from"./LunoraContext-dPcjtn6R.mjs";const v=(e,o)=>{const[r,t]=s(void 0),[n,a]=s(void 0),[c,u]=s(!1),m=l((i,d)=>e.mutation(o,i,d),{setError:a,setPending:u,setResult:i=>{t(()=>i),a(void 0)}});return{data:r,error:n,mutate:m,pending:c,reset:()=>{t(()=>{}),a(void 0)}}},R=e=>{const o=p();return v({mutation:(r,t,n)=>o.mutation(r,t,n)},e)};export{R as createMutation,v as createMutationForClient};
@@ -0,0 +1 @@
1
+ import{createSignal as g}from"solid-js";import{useLunora as S}from"./LunoraContext-dPcjtn6R.mjs";import{o as D}from"./solid-compat-ByG5HD_F.mjs";const I=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const t=crypto.getRandomValues(new Uint8Array(16));return Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}}return Date.now().toString(36)},U=1e4,C=(t,e)=>{const r=S(),{heartbeat:d,intervalMs:u=U,listPresent:f,shardKey:i}=e,s=e.sessionId??I(),[l,m]=g(void 0);let a=e.data;const o=()=>{const n={roomId:t,sessionId:s,...a===void 0?{}:{data:a}};r.mutation(d,n,{shardKey:i}).catch(()=>{})},y=n=>{a=n,o()};return D(()=>{o();const n=setInterval(o,u),c=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};typeof document<"u"&&document.addEventListener("visibilitychange",c);const p=r.acquireConnectionContext({roomId:t,sessionId:s},{shardKey:i}),v=r.subscribe(f,{roomId:t},b=>{m(()=>b)},{shardKey:i});return()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",c),p(),v()}}),{present:l,sessionId:s,setData:y}};export{C as createPresence};
@@ -0,0 +1 @@
1
+ import{createQuerySubscription as a}from"@lunora/client/query";import{createSignal as f}from"solid-js";import{useLunora as m}from"./LunoraContext-dPcjtn6R.mjs";import{t as p}from"./solid-compat-ByG5HD_F.mjs";const Q=(t,e,o={})=>{const n=m(),{shardKey:s}=o,[c,r]=f(void 0);return p(()=>typeof e=="function"?e():e,u=>a(n,t,u,{onData:i=>{r(()=>i)},onReset:()=>{r(()=>{})}},{shardKey:s})),c};export{Q as createQuery};
@@ -0,0 +1 @@
1
+ import{createSignal as a,onCleanup as S}from"solid-js";import{useLunora as x}from"./LunoraContext-dPcjtn6R.mjs";import{t as C}from"./solid-compat-ByG5HD_F.mjs";const K=(d,o,s={})=>{const h=x(),[p,i]=a([]),[v,f]=a(void 0),[k,e]=a("idle"),y=typeof o=="function"?o:()=>o;let t;const u=()=>{t?.()};return C(y,l=>{if(i(()=>[]),f(()=>{}),l==="skip"){e("idle");return}e("streaming");let n=!0;const m=h.stream(d,l,{maxBuffer:s.maxBuffer,shardKey:s.shardKey}),c=()=>{m.cancel()};return t=c,(async()=>{try{for await(const r of m){if(!n)return;i(E=>[...E,r])}n&&e("complete")}catch(r){if(!n)return;f(()=>r instanceof Error?r:new Error(String(r))),e("error")}})().catch(()=>{}),()=>{n=!1,c(),t===c&&(t=void 0)}}),S(()=>{u()}),{cancel:u,chunks:p,error:v,status:k}};export{K as createStream};
@@ -0,0 +1 @@
1
+ import{createQuerySubscription as v}from"@lunora/client/query";import{LunoraError as p}from"@lunora/errors";import{createSignal as a}from"solid-js";import{useLunora as u}from"./LunoraContext-dPcjtn6R.mjs";import{t as l}from"./solid-compat-ByG5HD_F.mjs";const D=(i,r,d={})=>{const s=u(),[c,e]=a(void 0),[m,t]=a(void 0);return l(typeof r=="function"?r:()=>r,n=>{if(n==="skip"){e(()=>{}),t(()=>{});return}return v(s,i,n,{onData:o=>{e(()=>o),t(()=>{})},onError:o=>{const f=o.code?new p(o.code,o.message):new Error(o.message);t(()=>f),e(()=>{})},onReset:()=>{e(()=>{})}},{shardKey:d.shardKey})}),{data:c,error:m}};export{D as createSubscription};
@@ -1 +1 @@
1
- import{createSignal as w,onCleanup as B}from"solid-js";import{useLunora as $}from"./LunoraContext-Ck27Dk1M.mjs";import{resolveMaybe as J}from"./createAgent-CvY_sduu.mjs";const K=16e3,G=e=>{if(e.length===0)return 0;let s=0;for(const o of e)s+=o*o;return Math.sqrt(s/e.length)},j=(e,s)=>{const o=s/K,a=o>1?Math.floor(e.length/o):e.length,l=new ArrayBuffer(a*2),i=new DataView(l);for(let u=0;u<a;u+=1){const k=e[Math.floor(u*o)]??0,f=Math.max(-1,Math.min(1,k));i.setInt16(u*2,f<0?f*32768:f*32767,!0)}return new Uint8Array(l)},z=async e=>{const s=globalThis,o=s.navigator?.mediaDevices?.getUserMedia.bind(s.navigator.mediaDevices),a=s.AudioContext??s.webkitAudioContext;if(!o||!a)throw new Error("createVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const l=await o({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),i=new a,u=i.createMediaStreamSource(l),k=i.createScriptProcessor(4096,1,1);let f=!1,A=!1,d=0,p=0;return k.onaudioprocess=r=>{const h=r.inputBuffer.getChannelData(0),g=f?0:G(h);if(e.onLevel(g),f)return;if(e.onAudio(j(h,i.sampleRate)),e.isSpeaking()){p=g>=e.interruptThreshold?p+1:0,p>=e.interruptChunks&&(p=0,e.onInterrupt());return}p=0;const E=h.length/i.sampleRate*1e3;if(g>=e.silenceThreshold){A=!0,d=0;return}A&&(d+=E,d>=e.silenceDurationMs&&(A=!1,d=0,e.onSilence()))},u.connect(k),k.connect(i.destination),{setMuted:r=>{f=r},stop:()=>{k.disconnect(),u.disconnect();for(const r of l.getTracks())r.stop();i.close()}}},Q=()=>{const e=globalThis,s=e.AudioContext??e.webkitAudioContext;if(!s)throw new Error("createVoiceAgent: audio playback requires AudioContext (no browser audio available)");const o=new s,a=new Set;let l=0,i=Promise.resolve(),u=0;const k=async(d,p)=>{if(p!==u)return;let r;try{r=await o.decodeAudioData(d.buffer)}catch{return}if(p!==u)return;const h=o.createBufferSource();h.buffer=r,h.connect(o.destination);const g=Math.max(o.currentTime,l);h.start(g),l=g+r.duration,a.add(h),h.onended=()=>{a.delete(h)}},f=d=>{const p=Uint8Array.from(d),r=u;i=i.then(()=>k(p,r))},A=()=>{u+=1;for(const d of a)try{d.stop()}catch{}a.clear(),l=o.currentTime};return{enqueue:f,interrupt:A,stop:()=>{A(),o.close()}}},D=1,X=.01,Y=1200,Z=.15,ee=3,te=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,ne=e=>{const s=e.__lunoraRef,o=s.startsWith("agents:")?s.slice(7):s;return o.endsWith("Voice")?o.slice(0,-5):o},oe=(e,s,o)=>{const a=te(e),l=a.endsWith("/")?a.slice(0,-1):a,i=new URLSearchParams({threadKey:o});return`${l}/_lunora/voice/${encodeURIComponent(s)}?${i.toString()}`},ie=e=>{const{createMicrophone:s=z,createSpeaker:o=Q,createSocket:a,interruptChunks:l=ee,interruptThreshold:i=Z,silenceDurationMs:u=Y,silenceThreshold:k=X,threadKey:f,voice:A}=e,d=$(),[p,r]=w("idle"),[h,g]=w(!1),[E,x]=w(""),[F,y]=w(""),[I,_]=w(0),[U,L]=w(!1),[N,T]=w(void 0);let c,b=!1;const M=t=>{const n=c?.socket;return n?.readyState===D?(n.send(JSON.stringify(t)),!0):!1},C=()=>{const t=c;if(c=void 0,t){t.microphone?.stop(),t.speaker?.stop();try{t.socket.close()}catch{}}b=!1,g(!1),r("idle"),_(0)},P=C,W=t=>{const n=c;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),r("speaking"),y(m=>m+t.text);break}case"assistant_done":{n&&(n.speaking=!1),y(t.text),r("listening");break}case"error":{n&&(n.speaking=!1),T(new Error(t.message)),r("listening");break}case"interrupted":{n&&(n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),r("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),g(!0),r("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),x(t.text),y(""),r("thinking");break}}},V=t=>{const n=c;!n||n.suppressAudio||(n.speaker??=o({audioFormat:n.audioFormat}),n.speaking=!0,r("speaking"),n.speaker.enqueue(t))},H=async()=>{if(!(c||b)){b=!0,T(void 0),x(""),y("");try{const t=oe(d.url,ne(A),J(f)),m=(a??(S=>new globalThis.WebSocket(S)))(t);m.binaryType="arraybuffer";const v={audioFormat:"mp3",microphone:void 0,socket:m,speaker:void 0,speaking:!1,suppressAudio:!1};c=v,m.onmessage=S=>{if(typeof S.data=="string"){try{W(JSON.parse(S.data))}catch{}return}V(new Uint8Array(S.data))},m.onerror=()=>{T(new Error("createVoiceAgent: voice socket error"))},m.onclose=()=>{c===v&&C()};const R=await s({interruptChunks:l,interruptThreshold:i,isSpeaking:()=>c?.speaking??!1,onAudio:S=>{m.readyState===D&&m.send(S)},onInterrupt:()=>{M({type:"interrupt"}),c?.speaker?.interrupt(),c&&(c.speaking=!1,c.suppressAudio=!0),r("listening")},onLevel:S=>{_(S)},onSilence:()=>{M({type:"commit"}),r("thinking")},silenceDurationMs:u,silenceThreshold:k});c===v?(v.microphone=R,L(!1),r("listening")):R.stop()}catch(t){T(t instanceof Error?t:new Error(String(t))),C()}finally{b=!1}}},O=()=>{const t=!U();return c?.microphone?.setMuted(t),L(t),t},q=t=>{M({text:t,type:"text"})&&r("thinking")};return B(C),{audioLevel:I,connected:h,endCall:P,error:N,interimTranscript:F,isMuted:U,sendText:q,startCall:H,status:p,toggleMute:O,transcript:E}};export{ie as createVoiceAgent};
1
+ import{createSignal as w,onCleanup as B}from"solid-js";import{useLunora as $}from"./LunoraContext-dPcjtn6R.mjs";import{resolveMaybe as J}from"./createAgent-DTUKko5X.mjs";const K=16e3,G=e=>{if(e.length===0)return 0;let s=0;for(const o of e)s+=o*o;return Math.sqrt(s/e.length)},j=(e,s)=>{const o=s/K,a=o>1?Math.floor(e.length/o):e.length,l=new ArrayBuffer(a*2),i=new DataView(l);for(let u=0;u<a;u+=1){const k=e[Math.floor(u*o)]??0,f=Math.max(-1,Math.min(1,k));i.setInt16(u*2,f<0?f*32768:f*32767,!0)}return new Uint8Array(l)},z=async e=>{const s=globalThis,o=s.navigator?.mediaDevices?.getUserMedia.bind(s.navigator.mediaDevices),a=s.AudioContext??s.webkitAudioContext;if(!o||!a)throw new Error("createVoiceAgent: microphone capture requires getUserMedia + AudioContext (no browser audio available)");const l=await o({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}}),i=new a,u=i.createMediaStreamSource(l),k=i.createScriptProcessor(4096,1,1);let f=!1,A=!1,d=0,p=0;return k.onaudioprocess=r=>{const h=r.inputBuffer.getChannelData(0),g=f?0:G(h);if(e.onLevel(g),f)return;if(e.onAudio(j(h,i.sampleRate)),e.isSpeaking()){p=g>=e.interruptThreshold?p+1:0,p>=e.interruptChunks&&(p=0,e.onInterrupt());return}p=0;const E=h.length/i.sampleRate*1e3;if(g>=e.silenceThreshold){A=!0,d=0;return}A&&(d+=E,d>=e.silenceDurationMs&&(A=!1,d=0,e.onSilence()))},u.connect(k),k.connect(i.destination),{setMuted:r=>{f=r},stop:()=>{k.disconnect(),u.disconnect();for(const r of l.getTracks())r.stop();i.close()}}},Q=()=>{const e=globalThis,s=e.AudioContext??e.webkitAudioContext;if(!s)throw new Error("createVoiceAgent: audio playback requires AudioContext (no browser audio available)");const o=new s,a=new Set;let l=0,i=Promise.resolve(),u=0;const k=async(d,p)=>{if(p!==u)return;let r;try{r=await o.decodeAudioData(d.buffer)}catch{return}if(p!==u)return;const h=o.createBufferSource();h.buffer=r,h.connect(o.destination);const g=Math.max(o.currentTime,l);h.start(g),l=g+r.duration,a.add(h),h.onended=()=>{a.delete(h)}},f=d=>{const p=Uint8Array.from(d),r=u;i=i.then(()=>k(p,r))},A=()=>{u+=1;for(const d of a)try{d.stop()}catch{}a.clear(),l=o.currentTime};return{enqueue:f,interrupt:A,stop:()=>{A(),o.close()}}},D=1,X=.01,Y=1200,Z=.15,ee=3,te=e=>e.startsWith("https://")?`wss://${e.slice(8)}`:e.startsWith("http://")?`ws://${e.slice(7)}`:e,ne=e=>{const s=e.__lunoraRef,o=s.startsWith("agents:")?s.slice(7):s;return o.endsWith("Voice")?o.slice(0,-5):o},oe=(e,s,o)=>{const a=te(e),l=a.endsWith("/")?a.slice(0,-1):a,i=new URLSearchParams({threadKey:o});return`${l}/_lunora/voice/${encodeURIComponent(s)}?${i.toString()}`},ie=e=>{const{createMicrophone:s=z,createSpeaker:o=Q,createSocket:a,interruptChunks:l=ee,interruptThreshold:i=Z,silenceDurationMs:u=Y,silenceThreshold:k=X,threadKey:f,voice:A}=e,d=$(),[p,r]=w("idle"),[h,g]=w(!1),[E,x]=w(""),[F,y]=w(""),[I,_]=w(0),[U,L]=w(!1),[N,T]=w(void 0);let c,b=!1;const M=t=>{const n=c?.socket;return n?.readyState===D?(n.send(JSON.stringify(t)),!0):!1},C=()=>{const t=c;if(c=void 0,t){t.microphone?.stop(),t.speaker?.stop();try{t.socket.close()}catch{}}b=!1,g(!1),r("idle"),_(0)},P=C,W=t=>{const n=c;switch(t.type){case"assistant_delta":{n&&(n.speaking=!0),r("speaking"),y(m=>m+t.text);break}case"assistant_done":{n&&(n.speaking=!1),y(t.text),r("listening");break}case"error":{n&&(n.speaking=!1),T(new Error(t.message)),r("listening");break}case"interrupted":{n&&(n.speaking=!1,n.suppressAudio=!1),n?.speaker?.interrupt(),r("listening");break}case"ready":{n&&(n.audioFormat=t.audioFormat,n.suppressAudio=!1),g(!0),r("listening");break}case"user_transcript":{n&&(n.suppressAudio=!1),x(t.text),y(""),r("thinking");break}}},V=t=>{const n=c;!n||n.suppressAudio||(n.speaker??=o({audioFormat:n.audioFormat}),n.speaking=!0,r("speaking"),n.speaker.enqueue(t))},H=async()=>{if(!(c||b)){b=!0,T(void 0),x(""),y("");try{const t=oe(d.url,ne(A),J(f)),m=(a??(S=>new globalThis.WebSocket(S)))(t);m.binaryType="arraybuffer";const v={audioFormat:"mp3",microphone:void 0,socket:m,speaker:void 0,speaking:!1,suppressAudio:!1};c=v,m.onmessage=S=>{if(typeof S.data=="string"){try{W(JSON.parse(S.data))}catch{}return}V(new Uint8Array(S.data))},m.onerror=()=>{T(new Error("createVoiceAgent: voice socket error"))},m.onclose=()=>{c===v&&C()};const R=await s({interruptChunks:l,interruptThreshold:i,isSpeaking:()=>c?.speaking??!1,onAudio:S=>{m.readyState===D&&m.send(S)},onInterrupt:()=>{M({type:"interrupt"}),c?.speaker?.interrupt(),c&&(c.speaking=!1,c.suppressAudio=!0),r("listening")},onLevel:S=>{_(S)},onSilence:()=>{M({type:"commit"}),r("thinking")},silenceDurationMs:u,silenceThreshold:k});c===v?(v.microphone=R,L(!1),r("listening")):R.stop()}catch(t){T(t instanceof Error?t:new Error(String(t))),C()}finally{b=!1}}},O=()=>{const t=!U();return c?.microphone?.setMuted(t),L(t),t},q=t=>{M({text:t,type:"text"})&&r("thinking")};return B(C),{audioLevel:I,connected:h,endCall:P,error:N,interimTranscript:F,isMuted:U,sendText:q,startCall:H,status:p,toggleMute:O,transcript:E}};export{ie as createVoiceAgent};
@@ -0,0 +1 @@
1
+ import{createSignal as i}from"solid-js";import{useLunora as d}from"./LunoraContext-dPcjtn6R.mjs";import{o as l}from"./solid-compat-ByG5HD_F.mjs";const b=t=>{const o=d(),{args:a,functionPath:e,shardKey:r,value:n}=t,[s,c]=i(n),u={__lunoraRef:e};return l(()=>o.subscribe(u,a,f=>c(()=>f),{shardKey:r})),s};export{b as default};
@@ -0,0 +1 @@
1
+ import{LunoraError as f}from"@lunora/errors";import*as n from"solid-js";const e=n,s=typeof e.onSettled=="function",r=(o,t)=>{if(o===void 0)throw new f("INTERNAL",`@lunora/solid could not find \`${t}\` on the installed solid-js. Expected Solid 1.x (which exports it) or 2.x (which exports \`onSettled\`); found neither.`);return o},u=(o,t)=>{if(s){n.createEffect(o,t);return}const d=r(e.on,"on");n.createEffect(d(o,c=>{const i=t(c);i&&n.onCleanup(i)}))},a=o=>{if(s){r(e.onSettled,"onSettled")(o);return}r(e.onMount,"onMount")(()=>{const t=o();t&&n.onCleanup(t)})},p=o=>{const{Provider:t}=o;return t??o};export{a as o,p,u as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/solid",
3
- "version": "1.0.0-alpha.55",
3
+ "version": "1.0.0-alpha.56",
4
4
  "description": "SolidJS adapter for Lunora — live queries, optimistic mutations, and reactive loaders",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -60,7 +60,7 @@
60
60
  "@visulima/storage-client": "1.0.2"
61
61
  },
62
62
  "peerDependencies": {
63
- "solid-js": "^1.9.0"
63
+ "solid-js": "^1.9.0 || ^2.0.0-rc.0"
64
64
  },
65
65
  "peerDependenciesMeta": {
66
66
  "solid-js": {
@@ -1 +0,0 @@
1
- import{createComponent as o,memo as s}from"solid-js/web";import{getIdentityStore as m}from"@lunora/client/auth";import{Show as u,createSignal as l,onCleanup as d}from"solid-js";import{useLunora as f}from"./LunoraContext-Ck27Dk1M.mjs";const c=()=>{const e=f(),n=m(e),[t,i]=l(e.getAuthToken()),[h,a]=l(n.getUser()),g=e.onAuthTokenChange(r=>{i(()=>r)}),k=n.subscribe(()=>{a(()=>n.getUser())});return d(()=>{g(),k()}),{setToken:r=>{e.setAuthToken(r)},token:t,user:h}},b=e=>{const{token:n,user:t}=c();return o(u,{get when(){return s(()=>n()===null)()?!1:t()!==null},get children(){return e.children}})},w=e=>{const{token:n,user:t}=c();return o(u,{get when(){return s(()=>n()===null)()?!1:t()===null},get children(){return e.children}})},C=e=>{const{token:n,user:t}=c();return o(u,{get when(){return s(()=>n()===null)()?t()===null:!1},get children(){return e.children}})};export{w as AuthLoading,b as Authenticated,C as Unauthenticated,c as createAuth};
@@ -1 +0,0 @@
1
- import{LunoraError as r}from"@lunora/errors";import{createContext as t,useContext as e}from"solid-js";const n=t(),i=()=>{const o=e(n);if(!o)throw new r("INTERNAL","useLunora must be used inside <LunoraProvider />");return o};export{n as LunoraContext,i as useLunora};
@@ -1 +0,0 @@
1
- import{createComponent as e}from"solid-js/web";import{LunoraContext as t}from"./LunoraContext-Ck27Dk1M.mjs";const i=r=>e(t.Provider,{get value(){return r.client},get children(){return r.children}});export{i as LunoraProvider};
@@ -1 +0,0 @@
1
- import{createSignal as a,onCleanup as c}from"solid-js";import{useLunora as u}from"./LunoraContext-Ck27Dk1M.mjs";const S=()=>{const t=u(),[n,o]=a(t.connectionStatus()),e=t.onConnectionStatus(s=>{o(s)});return c(e),n};export{S as default};
@@ -1 +0,0 @@
1
- import{createSignal as f,createEffect as p,on as m,onCleanup as y}from"solid-js";import{s as _}from"./stable-key-ITGZkfuz.mjs";import{useLunora as g}from"./LunoraContext-Ck27Dk1M.mjs";import{resolveMaybe as r}from"./createAgent-CvY_sduu.mjs";const h="__lunora_flags__:eval",v=t=>{const e=typeof t;return e==="boolean"||e==="number"||e==="string"?e:"object"},C={__lunoraRef:h},$=t=>t===void 0?"":_(t),S=(t,e,s)=>{const a=g(),c=v(e),[b,u]=f(e);return p(m(()=>`${r(t)} ${$(r(s))}`,()=>{const i=r(t),n=r(s);u(()=>e);let o;try{o=a.subscribe(C,{context:n,default:e,key:i,type:c},l=>{u(()=>l)})}catch{return}y(o)})),b},j=(t,e)=>{const s=g(),[a,c]=f(t),b=_(t);return p(m(()=>`${b} ${$(r(e))}`,()=>{const u=r(e);c(()=>t);const i=[];for(const[n,o]of Object.entries(t))try{i.push(s.subscribe(C,{context:u,default:o,key:n,type:v(o)},l=>{c(d=>({...d,[n]:l}))}))}catch{}y(()=>{for(const n of i)n()})})),a};export{S as createFlag,j as createFlags};
@@ -1 +0,0 @@
1
- import{initialPages as T,derivePaginationStatus as B,applyLoadMore as G,rebalance as H}from"@lunora/client/pagination";import{createMemo as A,createSignal as U,createEffect as $,on as F,onCleanup as V}from"solid-js";import{s as X}from"./stable-key-ITGZkfuz.mjs";import{useLunora as Y}from"./LunoraContext-Ck27Dk1M.mjs";const E=e=>{let n="";for(let u=0;u<e.length;u+=32768)n+=String.fromCharCode(...e.subarray(u,u+32768));return btoa(n)},f="$lunora.wire$",D=64,J="__proto__",Z=e=>{if(e===null||typeof e!="object")return!1;const n=Object.getPrototypeOf(e);return n===null||n===Object.prototype},P=(e,n=0)=>{if(n>D)throw new RangeError(`wire-codec: value nesting exceeds the ${D}-level limit`);if(e===void 0)return[f,"undefined"];if(e===null)return null;const l=typeof e;if(l==="bigint")return[f,"bigint",e.toString()];if(l==="number"){const t=e;return Number.isNaN(t)?[f,"nan"]:t===1/0?[f,"inf"]:t===-1/0?[f,"-inf"]:t}if(l!=="object")return e;if(e instanceof Date)return[f,"date",P(e.getTime(),n+1)];if(e instanceof Error){const t=e,r={};for(const d of Object.keys(t))t[d]!==void 0&&(r[d]=P(t[d],n+1));const o=[f,"error",t.name,t.message,r];return t.cause!==void 0&&o.push(P(t.cause,n+1)),o}if(e instanceof URL)return[f,"url",e.href];if(e instanceof Map)return[f,"map",[...e.entries()].map(([t,r])=>[P(t,n+1),P(r,n+1)])];if(e instanceof Set)return[f,"set",[...e].map(t=>P(t,n+1))];if(e instanceof ArrayBuffer)return[f,"bytes",E(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const t=e,r=t.constructor.name,o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);return r==="Uint8Array"?[f,"bytes",E(o)]:[f,"bytes",E(o),r]}if(Array.isArray(e)){const t=e.map(r=>P(r,n+1));return t.length>0&&t[0]===f?[f,"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,m={};for(const t of Object.keys(u)){const r=u[t];if(r===void 0)continue;const o=P(r,n+1);t===J?Object.defineProperty(m,t,{configurable:!0,enumerable:!0,value:o,writable:!0}):m[t]=o}return m},v=e=>X(P(e)),h=(e,n)=>({...n,paginationOpts:{cursor:e.lower,endCursor:e.upper,numItems:e.numItems}}),L=(e,n)=>`${e}::${v(n)}`,Q=(e,n,l)=>{const u=Y(),{initialNumItems:m,shardKey:t}=l,r=()=>typeof n=="function"?n():n,[o,d]=U(T(m)),g=new Map,[M,N]=U([]),y=new Map,S=new Set,x=(s,c)=>{const p=s.map(i=>{const a=L(e.__lunoraRef,h(i,c));return g.get(a)});N(p)},W=(s,c,p)=>{const i=a=>L(e.__lunoraRef,h(a,p));for(const a of c){const b=i(a);if(g.has(b))continue;const k=s.find(w=>w.lower===a.lower);if(k){const w=g.get(i(k));w&&g.set(b,w)}}},q=(s,c)=>{const p=new Set;for(const i of s)p.add(L(e.__lunoraRef,h(i,c)));for(const[i,a]of y)p.has(i)||(a(),y.delete(i),S.delete(i),g.delete(i));for(const i of s){const a=h(i,c),b=L(e.__lunoraRef,a);if(y.has(b))continue;S.add(b);const k=u.subscribe(e,a,w=>{g.set(b,w),S.delete(b);const R=r();if(R!=="skip"&&(x(o(),R),S.size===0)){const _=o(),j=H(_,M());j&&(W(_,j,R),d(j))}},{shardKey:t});y.set(b,k)}};let K=!1,O=!1;const C=(s,c)=>{if(K){O=!0;return}K=!0;try{let p=s,i=c;do{O=!1,q(p,i);const a=r();if(a==="skip")break;p=o(),i=a}while(O)}finally{K=!1}},I=()=>{for(const s of y.values())s();y.clear(),g.clear(),S.clear()};$(F(r,s=>{I(),d(T(m)),N([]),s!=="skip"&&(C(o(),s),x(o(),s)),V(I)})),$(F(o,s=>{const c=r();c!=="skip"&&(C(s,c),x(s,c))}));const z=A(()=>{const s=r()==="skip";return B(s,M()).status});return{loadMore:s=>{const c=r();if(c==="skip")return;const{nextCursor:p,status:i}=B(!1,M());if(i!=="CanLoadMore")return;const a=G(o(),p,s);if(!a)return;const b=o().at(-1),k=a.at(-2);if(b&&k){const w=L(e.__lunoraRef,h(b,c)),R=L(e.__lunoraRef,h(k,c));if(w!==R){const _=g.get(w);_&&g.set(R,_)}}d(a)},pageResults:M,status:z}},oe=(e,n,l)=>{const{loadMore:u,pageResults:m,status:t}=Q(e,n,l),r=A(()=>m().flatMap(d=>d?.page??[]));return{isLoading:A(()=>t()==="LoadingFirstPage"||t()==="LoadingMore"),loadMore:u,results:r,status:t}},ie=(e,n,l)=>{const{initialNumItems:u}=l,{loadMore:m,pageResults:t,status:r}=Q(e,n,l),o=A(()=>t().flatMap(y=>y?[y.page]:[])),d=A(()=>r()==="LoadingFirstPage"),g=A(()=>r()==="CanLoadMore"),M=A(()=>r()==="LoadingMore");return{fetchNextPage:y=>{m(y??u)},hasNextPage:g,isFetchingNextPage:M,isLoading:d,pages:o,status:r}};export{ie as createInfiniteQuery,oe as createPaginatedQuery};
@@ -1 +0,0 @@
1
- import{createSignal as g,onMount as S,onCleanup as D}from"solid-js";import{useLunora as I}from"./LunoraContext-Ck27Dk1M.mjs";const U=()=>{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){const t=crypto.getRandomValues(new Uint8Array(16));return Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}}return Date.now().toString(36)},h=1e4,A=(t,e)=>{const i=I(),{heartbeat:d,intervalMs:u=h,listPresent:f,shardKey:r}=e,s=e.sessionId??U(),[l,y]=g(void 0);let a=e.data;const o=()=>{const n={roomId:t,sessionId:s,...a===void 0?{}:{data:a}};i.mutation(d,n,{shardKey:r}).catch(()=>{})},m=n=>{a=n,o()};return S(()=>{o();const n=setInterval(o,u),c=()=>{typeof document<"u"&&document.visibilityState==="visible"&&o()};typeof document<"u"&&document.addEventListener("visibilitychange",c);const p=i.acquireConnectionContext({roomId:t,sessionId:s},{shardKey:r}),v=i.subscribe(f,{roomId:t},b=>{y(()=>b)},{shardKey:r});D(()=>{clearInterval(n),typeof document<"u"&&document.removeEventListener("visibilitychange",c),p(),v()})}),{present:l,sessionId:s,setData:m}};export{A as createPresence};
@@ -1 +0,0 @@
1
- import{createQuerySubscription as f}from"@lunora/client/query";import{createSignal as l,createEffect as p,on as m,onCleanup as v}from"solid-js";import{useLunora as y}from"./LunoraContext-Ck27Dk1M.mjs";const S=(t,e,r={})=>{const n=y(),{shardKey:c}=r,[s,o]=l(void 0);return p(m(()=>typeof e=="function"?e():e,u=>{const i=f(n,t,u,{onData:a=>{o(()=>a)},onReset:()=>{o(()=>{})}},{shardKey:c});v(i)})),s};export{S as createQuery};
@@ -1 +0,0 @@
1
- import{createSignal as a,createEffect as x,on as C,onCleanup as d}from"solid-js";import{useLunora as b}from"./LunoraContext-Ck27Dk1M.mjs";const K=(h,c,s={})=>{const p=b(),[v,i]=a([]),[y,f]=a(void 0),[E,r]=a("idle"),k=typeof c=="function"?c:()=>c;let t;const l=()=>{t?.()};return x(C(k,u=>{if(i(()=>[]),f(()=>{}),u==="skip"){r("idle");return}r("streaming");let n=!0;const m=p.stream(h,u,{maxBuffer:s.maxBuffer,shardKey:s.shardKey}),o=()=>{m.cancel()};t=o,(async()=>{try{for await(const e of m){if(!n)return;i(S=>[...S,e])}n&&r("complete")}catch(e){if(!n)return;f(()=>e instanceof Error?e:new Error(String(e))),r("error")}})().catch(()=>{}),d(()=>{n=!1,o(),t===o&&(t=void 0)})})),d(()=>{l()}),{cancel:l,chunks:v,error:y,status:E}};export{K as createStream};
@@ -1 +0,0 @@
1
- import{createQuerySubscription as u}from"@lunora/client/query";import{LunoraError as p}from"@lunora/errors";import{createSignal as a,createEffect as l,on as y,onCleanup as S}from"solid-js";import{useLunora as g}from"./LunoraContext-Ck27Dk1M.mjs";const L=(s,r,i={})=>{const c=g(),[d,e]=a(void 0),[m,t]=a(void 0);return l(y(typeof r=="function"?r:()=>r,n=>{if(n==="skip"){e(()=>{}),t(()=>{});return}const f=u(c,s,n,{onData:o=>{e(()=>o),t(()=>{})},onError:o=>{const v=o.code?new p(o.code,o.message):new Error(o.message);t(()=>v),e(()=>{})},onReset:()=>{e(()=>{})}},{shardKey:i.shardKey});S(f)})),{data:d,error:m}};export{L as createSubscription};
@@ -1 +0,0 @@
1
- import{createSignal as l,createEffect as d,onCleanup as b}from"solid-js";import{useLunora as m}from"./LunoraContext-Ck27Dk1M.mjs";const g=t=>{const e=m(),{args:a,functionPath:n,shardKey:o,value:r}=t,[s,c]=l(r),u={__lunoraRef:n};return d(()=>{const f=e.subscribe(u,a,i=>c(()=>i),{shardKey:o});b(f)}),s};export{g as default};