@lunora/solid 1.0.0-alpha.6 → 1.0.0-alpha.7
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 +35 -3
- package/dist/index.d.ts +35 -3
- package/dist/index.mjs +1 -0
- package/dist/packem_shared/createMutator-foSnPJPt.mjs +24 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LunoraClient, User, ConnectionStatus, FunctionReference, ArgsOf, MutationCallOptions, ReturnOf, Preloaded } from '@lunora/client';
|
|
2
|
-
export type { ArgsOf, FunctionReference, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe } from '@lunora/client';
|
|
1
|
+
import { LunoraClient, User, ConnectionStatus, FunctionReference, ArgsOf, MutationCallOptions, ReturnOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
2
|
+
export type { ArgsOf, FunctionReference, MutatorHandle, MutatorTransaction, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe } from '@lunora/client';
|
|
3
3
|
import { Context, JSX, Accessor } from 'solid-js';
|
|
4
4
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
5
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
@@ -144,6 +144,38 @@ declare const createMutationForClient: <F extends FunctionReference>(client: Mut
|
|
|
144
144
|
* down, so `mutate` stays durable across reconnects.
|
|
145
145
|
*/
|
|
146
146
|
declare const createMutation: <F extends FunctionReference>(function_: F) => MutationHandle<F>;
|
|
147
|
+
/**
|
|
148
|
+
* The reactive handle returned by {@link createMutator} — the Solid counterpart
|
|
149
|
+
* to `@lunora/react`'s `useMutator`, re-expressed with signals.
|
|
150
|
+
* `error`/`isError`/`pending` are accessors and `mutate` is an awaitable that
|
|
151
|
+
* resolves once the write is persisted (or rejects).
|
|
152
|
+
*/
|
|
153
|
+
interface MutatorHook<TArgs> {
|
|
154
|
+
/** The latest invocation's error, or `undefined`. */
|
|
155
|
+
error: Accessor<Error | undefined>;
|
|
156
|
+
/** `true` when the latest invocation rejected. */
|
|
157
|
+
isError: Accessor<boolean>;
|
|
158
|
+
/** Run the mutator; resolves once the write is persisted, rejects on failure. */
|
|
159
|
+
mutate: (args: TArgs) => Promise<void>;
|
|
160
|
+
/** `true` while ANY invocation from this handle is in flight (ref-counted, so overlapping calls compose). */
|
|
161
|
+
pending: Accessor<boolean>;
|
|
162
|
+
/** Clear the latest `error` back to idle. */
|
|
163
|
+
reset: () => void;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Ergonomic `{ mutate, pending, error, isError, reset }` wrapper over a bound
|
|
167
|
+
* custom-mutator handle from `@lunora/db`'s `bindMutators` — the Solid
|
|
168
|
+
* equivalent of `@lunora/react`'s `useMutator`. The optimistic overlay and
|
|
169
|
+
* server-authoritative push are owned by the bound handle (and TanStack DB's
|
|
170
|
+
* optimistic-transaction layer rebases pending overlays on every sync tick);
|
|
171
|
+
* this primitive only surfaces signal state for the in-flight/error lifecycle.
|
|
172
|
+
* Reads stay on the existing TanStack `useLiveQuery`; no new query primitive is
|
|
173
|
+
* needed.
|
|
174
|
+
*
|
|
175
|
+
* `pending` is ref-counted across overlapping invocations of THIS handle, so it
|
|
176
|
+
* clears only once every concurrent call has settled.
|
|
177
|
+
*/
|
|
178
|
+
declare const createMutator: <TArgs = Record<string, unknown>>(handle: MutatorHandle<TArgs>) => MutatorHook<TArgs>;
|
|
147
179
|
/** The args a paginated query exposes minus the framework-supplied page cursor. */
|
|
148
180
|
type PaginatedArgs<F extends FunctionReference> = Omit<ArgsOf<F>, "paginationOpts">;
|
|
149
181
|
/** The element type of the `page` array a paginated query returns. */
|
|
@@ -373,4 +405,4 @@ interface LunoraProviderProps {
|
|
|
373
405
|
* ```
|
|
374
406
|
*/
|
|
375
407
|
declare const LunoraProvider: (props: LunoraProviderProps) => JSX.Element;
|
|
376
|
-
export { AuthLoading, Authenticated, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreatePaginatedQueryOptions, type CreatePaginatedQueryResult, type CreatePresenceOptions, type CreatePresenceResult, type CreateQueryOptions, type CreateRateLimitOptions, type CreateRateLimitResult, type CreateSubscriptionResult, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraContext, LunoraProvider, type LunoraProviderProps, type MutationClient, type MutationHandle, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, createAuth, createConnectionStatus, createFlag, createFlags, createInfiniteQuery, createMutation, createMutationForClient, createPaginatedQuery, createPresence, createQuery, createRateLimit, createSubscription, hydratePreloaded, useLunora };
|
|
408
|
+
export { AuthLoading, Authenticated, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreatePaginatedQueryOptions, type CreatePaginatedQueryResult, type CreatePresenceOptions, type CreatePresenceResult, type CreateQueryOptions, type CreateRateLimitOptions, type CreateRateLimitResult, type CreateSubscriptionResult, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraContext, LunoraProvider, type LunoraProviderProps, type MutationClient, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, createAuth, createConnectionStatus, createFlag, createFlags, createInfiniteQuery, createMutation, createMutationForClient, createMutator, createPaginatedQuery, createPresence, createQuery, createRateLimit, createSubscription, hydratePreloaded, useLunora };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LunoraClient, User, ConnectionStatus, FunctionReference, ArgsOf, MutationCallOptions, ReturnOf, Preloaded } from '@lunora/client';
|
|
2
|
-
export type { ArgsOf, FunctionReference, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe } from '@lunora/client';
|
|
1
|
+
import { LunoraClient, User, ConnectionStatus, FunctionReference, ArgsOf, MutationCallOptions, ReturnOf, MutatorHandle, Preloaded } from '@lunora/client';
|
|
2
|
+
export type { ArgsOf, FunctionReference, MutatorHandle, MutatorTransaction, OptimisticUpdate, Preloaded, ReturnOf, Unsubscribe } from '@lunora/client';
|
|
3
3
|
import { Context, JSX, Accessor } from 'solid-js';
|
|
4
4
|
import { PaginationStatus } from '@lunora/client/pagination';
|
|
5
5
|
import { RateLimitStatus, RateLimitConfig } from '@lunora/ratelimit';
|
|
@@ -144,6 +144,38 @@ declare const createMutationForClient: <F extends FunctionReference>(client: Mut
|
|
|
144
144
|
* down, so `mutate` stays durable across reconnects.
|
|
145
145
|
*/
|
|
146
146
|
declare const createMutation: <F extends FunctionReference>(function_: F) => MutationHandle<F>;
|
|
147
|
+
/**
|
|
148
|
+
* The reactive handle returned by {@link createMutator} — the Solid counterpart
|
|
149
|
+
* to `@lunora/react`'s `useMutator`, re-expressed with signals.
|
|
150
|
+
* `error`/`isError`/`pending` are accessors and `mutate` is an awaitable that
|
|
151
|
+
* resolves once the write is persisted (or rejects).
|
|
152
|
+
*/
|
|
153
|
+
interface MutatorHook<TArgs> {
|
|
154
|
+
/** The latest invocation's error, or `undefined`. */
|
|
155
|
+
error: Accessor<Error | undefined>;
|
|
156
|
+
/** `true` when the latest invocation rejected. */
|
|
157
|
+
isError: Accessor<boolean>;
|
|
158
|
+
/** Run the mutator; resolves once the write is persisted, rejects on failure. */
|
|
159
|
+
mutate: (args: TArgs) => Promise<void>;
|
|
160
|
+
/** `true` while ANY invocation from this handle is in flight (ref-counted, so overlapping calls compose). */
|
|
161
|
+
pending: Accessor<boolean>;
|
|
162
|
+
/** Clear the latest `error` back to idle. */
|
|
163
|
+
reset: () => void;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Ergonomic `{ mutate, pending, error, isError, reset }` wrapper over a bound
|
|
167
|
+
* custom-mutator handle from `@lunora/db`'s `bindMutators` — the Solid
|
|
168
|
+
* equivalent of `@lunora/react`'s `useMutator`. The optimistic overlay and
|
|
169
|
+
* server-authoritative push are owned by the bound handle (and TanStack DB's
|
|
170
|
+
* optimistic-transaction layer rebases pending overlays on every sync tick);
|
|
171
|
+
* this primitive only surfaces signal state for the in-flight/error lifecycle.
|
|
172
|
+
* Reads stay on the existing TanStack `useLiveQuery`; no new query primitive is
|
|
173
|
+
* needed.
|
|
174
|
+
*
|
|
175
|
+
* `pending` is ref-counted across overlapping invocations of THIS handle, so it
|
|
176
|
+
* clears only once every concurrent call has settled.
|
|
177
|
+
*/
|
|
178
|
+
declare const createMutator: <TArgs = Record<string, unknown>>(handle: MutatorHandle<TArgs>) => MutatorHook<TArgs>;
|
|
147
179
|
/** The args a paginated query exposes minus the framework-supplied page cursor. */
|
|
148
180
|
type PaginatedArgs<F extends FunctionReference> = Omit<ArgsOf<F>, "paginationOpts">;
|
|
149
181
|
/** The element type of the `page` array a paginated query returns. */
|
|
@@ -373,4 +405,4 @@ interface LunoraProviderProps {
|
|
|
373
405
|
* ```
|
|
374
406
|
*/
|
|
375
407
|
declare const LunoraProvider: (props: LunoraProviderProps) => JSX.Element;
|
|
376
|
-
export { AuthLoading, Authenticated, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreatePaginatedQueryOptions, type CreatePaginatedQueryResult, type CreatePresenceOptions, type CreatePresenceResult, type CreateQueryOptions, type CreateRateLimitOptions, type CreateRateLimitResult, type CreateSubscriptionResult, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraContext, LunoraProvider, type LunoraProviderProps, type MutationClient, type MutationHandle, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, createAuth, createConnectionStatus, createFlag, createFlags, createInfiniteQuery, createMutation, createMutationForClient, createPaginatedQuery, createPresence, createQuery, createRateLimit, createSubscription, hydratePreloaded, useLunora };
|
|
408
|
+
export { AuthLoading, Authenticated, type CreateInfiniteQueryOptions, type CreateInfiniteQueryResult, type CreatePaginatedQueryOptions, type CreatePaginatedQueryResult, type CreatePresenceOptions, type CreatePresenceResult, type CreateQueryOptions, type CreateRateLimitOptions, type CreateRateLimitResult, type CreateSubscriptionResult, type FlagContext, type FlagValue, type HeartbeatReference, type ListPresentReference, LunoraContext, LunoraProvider, type LunoraProviderProps, type MutationClient, type MutationHandle, type MutatorHook, type PageItemOf, type PaginatedArgs, Unauthenticated, type UseAuthResult, createAuth, createConnectionStatus, createFlag, createFlags, createInfiniteQuery, createMutation, createMutationForClient, createMutator, createPaginatedQuery, createPresence, createQuery, createRateLimit, createSubscription, hydratePreloaded, useLunora };
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,7 @@ export { AuthLoading, Authenticated, Unauthenticated, createAuth } from './packe
|
|
|
3
3
|
export { default as createConnectionStatus } from './packem_shared/createConnectionStatus-D8GPatZX.mjs';
|
|
4
4
|
export { createFlag, createFlags } from './packem_shared/createFlag-BDunYuaH.mjs';
|
|
5
5
|
export { createMutation, createMutationForClient } from './packem_shared/createMutation-C7BxzO0y.mjs';
|
|
6
|
+
export { createMutator } from './packem_shared/createMutator-foSnPJPt.mjs';
|
|
6
7
|
export { createInfiniteQuery, createPaginatedQuery } from './packem_shared/createInfiniteQuery-DyMvQ2Qy.mjs';
|
|
7
8
|
export { createPresence } from './packem_shared/createPresence-DiAak1Jw.mjs';
|
|
8
9
|
export { createQuery } from './packem_shared/createQuery-D8mdHfyQ.mjs';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createMutatorRunner } from '@lunora/client';
|
|
2
|
+
import { createSignal } from 'solid-js';
|
|
3
|
+
|
|
4
|
+
const createMutator = (handle) => {
|
|
5
|
+
const [error, setError] = createSignal(void 0);
|
|
6
|
+
const [pending, setPending] = createSignal(false);
|
|
7
|
+
const {
|
|
8
|
+
mutate,
|
|
9
|
+
reset
|
|
10
|
+
} = createMutatorRunner(handle, {
|
|
11
|
+
setError,
|
|
12
|
+
setPending
|
|
13
|
+
});
|
|
14
|
+
const isError = () => error() !== void 0;
|
|
15
|
+
return {
|
|
16
|
+
error,
|
|
17
|
+
isError,
|
|
18
|
+
mutate,
|
|
19
|
+
pending,
|
|
20
|
+
reset
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { createMutator };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/solid",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
4
|
"description": "SolidJS adapter for Lunora — live queries, optimistic mutations, and reactive loaders",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@lunora/client": "1.0.0-alpha.
|
|
53
|
+
"@lunora/client": "1.0.0-alpha.5",
|
|
54
54
|
"@lunora/ratelimit": "1.0.0-alpha.3"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|