@softistx/riva 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +168 -2
- package/dist/batch.d.ts +5 -0
- package/dist/batch.d.ts.map +1 -0
- package/dist/chunks/index-2g2s3y31.js +58 -0
- package/dist/chunks/index-2g2s3y31.js.map +10 -0
- package/dist/chunks/index-46sbdyt0.js +84 -0
- package/dist/chunks/index-46sbdyt0.js.map +12 -0
- package/dist/chunks/index-5xnfwj57.js +21 -0
- package/dist/chunks/index-5xnfwj57.js.map +10 -0
- package/dist/chunks/index-asz1gnp1.js +50 -0
- package/dist/chunks/index-asz1gnp1.js.map +10 -0
- package/dist/chunks/index-e4vzsfy1.js +253 -0
- package/dist/chunks/index-e4vzsfy1.js.map +11 -0
- package/dist/chunks/index-tn8ankny.js +137 -0
- package/dist/chunks/index-tn8ankny.js.map +10 -0
- package/dist/chunks/index-vz93xwnj.js +35 -0
- package/dist/chunks/index-vz93xwnj.js.map +10 -0
- package/dist/chunks/index-y6bzw104.js +53 -0
- package/dist/chunks/index-y6bzw104.js.map +11 -0
- package/dist/client.d.ts +48 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/computed.d.ts +21 -0
- package/dist/computed.d.ts.map +1 -0
- package/dist/data/index.d.ts +19 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +60 -0
- package/dist/data/index.js.map +10 -0
- package/dist/data/types.d.ts +12 -0
- package/dist/data/types.d.ts.map +1 -0
- package/dist/duration.d.ts +5 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/effect.d.ts +5 -0
- package/dist/effect.d.ts.map +1 -0
- package/dist/entities/api.d.ts +18 -0
- package/dist/entities/api.d.ts.map +1 -0
- package/dist/entities/denormalize.d.ts +13 -0
- package/dist/entities/denormalize.d.ts.map +1 -0
- package/dist/entities/identity.d.ts +11 -0
- package/dist/entities/identity.d.ts.map +1 -0
- package/dist/entities/index.d.ts +6 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +414 -0
- package/dist/entities/index.js.map +16 -0
- package/dist/entities/json.d.ts +15 -0
- package/dist/entities/json.d.ts.map +1 -0
- package/dist/entities/normalize.d.ts +11 -0
- package/dist/entities/normalize.d.ts.map +1 -0
- package/dist/entities/policy.d.ts +41 -0
- package/dist/entities/policy.d.ts.map +1 -0
- package/dist/entities/store.d.ts +47 -0
- package/dist/entities/store.d.ts.map +1 -0
- package/dist/env.d.ts +15 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/errors.d.ts +38 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/flush.d.ts +11 -0
- package/dist/flush.d.ts.map +1 -0
- package/dist/graph.d.ts +47 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +502 -0
- package/dist/index.js.map +18 -0
- package/dist/infinite/index.d.ts +3 -0
- package/dist/infinite/index.d.ts.map +1 -0
- package/dist/infinite/index.js +207 -0
- package/dist/infinite/index.js.map +13 -0
- package/dist/infinite/infinite.d.ts +8 -0
- package/dist/infinite/infinite.d.ts.map +1 -0
- package/dist/infinite/more.d.ts +19 -0
- package/dist/infinite/more.d.ts.map +1 -0
- package/dist/infinite/refetch.d.ts +16 -0
- package/dist/infinite/refetch.d.ts.map +1 -0
- package/dist/infinite/slots.d.ts +22 -0
- package/dist/infinite/slots.d.ts.map +1 -0
- package/dist/infinite/types.d.ts +68 -0
- package/dist/infinite/types.d.ts.map +1 -0
- package/dist/key.d.ts +3 -0
- package/dist/key.d.ts.map +1 -0
- package/dist/mutation-run.d.ts +5 -0
- package/dist/mutation-run.d.ts.map +1 -0
- package/dist/mutation.d.ts +53 -0
- package/dist/mutation.d.ts.map +1 -0
- package/dist/query-cache.d.ts +33 -0
- package/dist/query-cache.d.ts.map +1 -0
- package/dist/query-entry.d.ts +85 -0
- package/dist/query-entry.d.ts.map +1 -0
- package/dist/query-observe.d.ts +9 -0
- package/dist/query-observe.d.ts.map +1 -0
- package/dist/query-run.d.ts +12 -0
- package/dist/query-run.d.ts.map +1 -0
- package/dist/query.d.ts +100 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/retry.d.ts +18 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/scope.d.ts +16 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/signal.d.ts +22 -0
- package/dist/signal.d.ts.map +1 -0
- package/dist/ssr/codec.d.ts +10 -0
- package/dist/ssr/codec.d.ts.map +1 -0
- package/dist/ssr/dehydrate.d.ts +37 -0
- package/dist/ssr/dehydrate.d.ts.map +1 -0
- package/dist/ssr/hydrate.d.ts +20 -0
- package/dist/ssr/hydrate.d.ts.map +1 -0
- package/dist/ssr/index.d.ts +5 -0
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/index.js +136 -0
- package/dist/ssr/index.js.map +11 -0
- package/dist/store/def.d.ts +31 -0
- package/dist/store/def.d.ts.map +1 -0
- package/dist/store/index.d.ts +3 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +215 -0
- package/dist/store/index.js.map +14 -0
- package/dist/store/instance.d.ts +14 -0
- package/dist/store/instance.d.ts.map +1 -0
- package/dist/store/run.d.ts +12 -0
- package/dist/store/run.d.ts.map +1 -0
- package/dist/store/store.d.ts +10 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/types.d.ts +70 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/view.d.ts +10 -0
- package/dist/store/view.d.ts.map +1 -0
- package/docs/README.md +19 -0
- package/docs/guide/data.md +36 -0
- package/docs/guide/entities.md +90 -0
- package/docs/guide/errors.md +31 -0
- package/docs/guide/infinite.md +62 -0
- package/docs/guide/mutations.md +73 -0
- package/docs/guide/queries.md +93 -0
- package/docs/guide/signals.md +72 -0
- package/docs/guide/ssr.md +65 -0
- package/docs/guide/store.md +88 -0
- package/docs/troubleshooting.md +343 -0
- package/package.json +84 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AnyQuery, type Ctx, type State } from './query-entry';
|
|
2
|
+
import type { Listener, Unsubscribe } from './signal';
|
|
3
|
+
export interface ObserveOptions {
|
|
4
|
+
/** Replaces the definition's `staleTime` for this observer's first fetch decision only (ms). */
|
|
5
|
+
staleTime?: number;
|
|
6
|
+
}
|
|
7
|
+
/** Counts an observer, fetches when needed, polls; the returned function undoes it. */
|
|
8
|
+
export declare function observe(c: Ctx, def: AnyQuery, vars: unknown, listener: Listener<State>, opts?: ObserveOptions): Unsubscribe;
|
|
9
|
+
//# sourceMappingURL=query-observe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-observe.d.ts","sourceRoot":"","sources":["../src/query-observe.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,QAAQ,EAEb,KAAK,GAAG,EAMR,KAAK,KAAK,EAGV,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,WAAW,cAAc;IAC9B,gGAAgG;IAChG,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAuCD,uFAAuF;AACvF,wBAAgB,OAAO,CACtB,CAAC,EAAE,GAAG,EACN,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,EACzB,IAAI,CAAC,EAAE,cAAc,GACnB,WAAW,CA+Bb"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Ctx, type Entry, type Inflight } from './query-entry';
|
|
2
|
+
/** The fetch in flight, or a new one. Callers that do not await it ignore its rejection. */
|
|
3
|
+
export declare const join: (c: Ctx, e: Entry) => Inflight;
|
|
4
|
+
/** `join` for a fetch nobody awaits (prefetch, poll, refetch): pinned, so a caller's abort leaves it running. */
|
|
5
|
+
export declare const pin: (c: Ctx, e: Entry) => void;
|
|
6
|
+
/** Aborts the fetch, rejects its waiters and restores the previous state. */
|
|
7
|
+
export declare function cancel(c: Ctx, e: Entry): void;
|
|
8
|
+
/** Aborts the attempt and starts a fresh one; waiters get its result. */
|
|
9
|
+
export declare function restart(f: Inflight): void;
|
|
10
|
+
/** Cancels a fetch nobody waits for or observes any more. */
|
|
11
|
+
export declare function abandon(c: Ctx, e: Entry, f: Inflight | undefined): void;
|
|
12
|
+
//# sourceMappingURL=query-run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-run.d.ts","sourceRoot":"","sources":["../src/query-run.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,GAAG,EACR,KAAK,KAAK,EAEV,KAAK,QAAQ,EAOb,MAAM,eAAe,CAAC;AAwFvB,4FAA4F;AAC5F,eAAO,MAAM,IAAI,MAAO,GAAG,KAAK,KAAK,KAAG,QAAgC,CAAC;AAEzE,iHAAiH;AACjH,eAAO,MAAM,GAAG,MAAO,GAAG,KAAK,KAAK,KAAG,IAEtC,CAAC;AAEF,6EAA6E;AAC7E,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,GAAG,IAAI,CAO7C;AAED,yEAAyE;AACzE,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI,CAIzC;AAED,6DAA6D;AAC7D,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI,CAEvE"}
|
package/dist/query.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { RivaClient } from './client';
|
|
2
|
+
import { type Duration } from './duration';
|
|
3
|
+
export type QueryStatus = 'idle' | 'pending' | 'success' | 'error';
|
|
4
|
+
/**
|
|
5
|
+
* What a query entry holds. `status` stays `success` with the old data during
|
|
6
|
+
* a background refetch (`isFetching` is true); an error keeps the last data.
|
|
7
|
+
*/
|
|
8
|
+
export interface QueryState<Data> {
|
|
9
|
+
readonly status: QueryStatus;
|
|
10
|
+
readonly data: Data | undefined;
|
|
11
|
+
readonly error: unknown;
|
|
12
|
+
readonly isFetching: boolean;
|
|
13
|
+
/** Epoch milliseconds of the last success (0 when none). */
|
|
14
|
+
readonly updatedAt: number;
|
|
15
|
+
}
|
|
16
|
+
export interface FetchContext {
|
|
17
|
+
signal: AbortSignal;
|
|
18
|
+
client: RivaClient;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* How a query entry stores its data. The default keeps it as is; a policy such
|
|
22
|
+
* as `entities()` from `@softistx/riva/entities` normalizes it into shared
|
|
23
|
+
* entities. `read` runs in a computed, so what it reads is tracked.
|
|
24
|
+
*/
|
|
25
|
+
export interface CachePolicy<Stored = unknown> {
|
|
26
|
+
/** `prev` is what the entry stored before, so a policy can keep identities across writes; `vars` are the entry's variables. */
|
|
27
|
+
write(client: RivaClient, data: unknown, prev?: Stored, vars?: unknown): Stored;
|
|
28
|
+
/** `committed` skips the optimistic layers (the data a write must start from). */
|
|
29
|
+
read(client: RivaClient, stored: Stored, committed?: boolean): unknown;
|
|
30
|
+
/** The entry was replaced or collected: drop what `write` retained. */
|
|
31
|
+
release(client: RivaClient, stored: Stored): void;
|
|
32
|
+
/** Mutations: shows `data` over the committed data until `drop` (an optimistic layer). */
|
|
33
|
+
layer?(client: RivaClient, data: unknown, vars?: unknown): {
|
|
34
|
+
drop(): void;
|
|
35
|
+
};
|
|
36
|
+
/** Mutations: merges a server result into the committed data, notifying its readers. */
|
|
37
|
+
commit?(client: RivaClient, data: unknown, vars?: unknown): void;
|
|
38
|
+
}
|
|
39
|
+
export interface QueryOptions<Vars, Data> {
|
|
40
|
+
/** Identifies the definition; the cache key is the id plus the stable-serialized variables. */
|
|
41
|
+
id: string;
|
|
42
|
+
fetch: (vars: Vars, ctx: FetchContext) => Promise<Data>;
|
|
43
|
+
/** How long data stays fresh. Default 0. */
|
|
44
|
+
staleTime?: Duration;
|
|
45
|
+
/** How long an unobserved entry is kept. Default 5 min in a browser, `Infinity` on the server. */
|
|
46
|
+
gcTime?: Duration;
|
|
47
|
+
/** A count of retries, or a decision. `failures` is the number of failures before this one. Default 3 in a browser, 0 on the server. */
|
|
48
|
+
retry?: number | ((failures: number, error: unknown) => boolean);
|
|
49
|
+
/** Delay before a retry, in ms. Default `min(1000 * 2 ** failures, 30_000)`. */
|
|
50
|
+
retryDelay?: (failures: number) => number;
|
|
51
|
+
/** Default true. */
|
|
52
|
+
refetchOnFocus?: boolean;
|
|
53
|
+
/** Default true. */
|
|
54
|
+
refetchOnReconnect?: boolean;
|
|
55
|
+
/** Polls while the entry is observed. */
|
|
56
|
+
refetchEvery?: Duration;
|
|
57
|
+
/** How the data is stored. Default: as is (a keyed cache). */
|
|
58
|
+
cache?: CachePolicy;
|
|
59
|
+
/** @internal Shapes the state readers see, last (after the policy and the layers); read inside a computed. */
|
|
60
|
+
derive?: (client: RivaClient, state: QueryState<Data>, vars: Vars) => unknown;
|
|
61
|
+
}
|
|
62
|
+
export interface EnsureOptions {
|
|
63
|
+
signal?: AbortSignal;
|
|
64
|
+
}
|
|
65
|
+
/** The variables argument, optional when `Vars` is `void` or `undefined`. */
|
|
66
|
+
export type VarsArgs<Vars, Rest extends unknown[] = []> = [Vars] extends [
|
|
67
|
+
void | undefined
|
|
68
|
+
] ? [vars?: Vars, ...rest: Rest] : [vars: Vars, ...rest: Rest];
|
|
69
|
+
/** A stateless query definition: the data lives in a `RivaClient`. `S` is the state readers get (`QueryState<Data>` unless a module derives more). */
|
|
70
|
+
export interface Query<Vars, Data, S extends QueryState<unknown> = QueryState<Data>> {
|
|
71
|
+
/** @internal Phantom: carries `S` to `client.get` and `subscribe`. */
|
|
72
|
+
readonly '~state'?: S;
|
|
73
|
+
readonly kind: 'query';
|
|
74
|
+
readonly id: string;
|
|
75
|
+
/** @internal */
|
|
76
|
+
readonly options: {
|
|
77
|
+
readonly fetch: QueryOptions<Vars, Data>['fetch'];
|
|
78
|
+
readonly staleTime: number;
|
|
79
|
+
readonly gcTime: number | undefined;
|
|
80
|
+
readonly retry: QueryOptions<Vars, Data>['retry'];
|
|
81
|
+
readonly retryDelay: QueryOptions<Vars, Data>['retryDelay'];
|
|
82
|
+
readonly refetchOnFocus: boolean;
|
|
83
|
+
readonly refetchOnReconnect: boolean;
|
|
84
|
+
readonly refetchEvery: number | undefined;
|
|
85
|
+
readonly cache: CachePolicy | undefined;
|
|
86
|
+
readonly derive: QueryOptions<Vars, Data>['derive'];
|
|
87
|
+
};
|
|
88
|
+
/** Fetches when missing or stale and awaits; resolves the cache when fresh. */
|
|
89
|
+
ensure(client: RivaClient, ...args: VarsArgs<Vars, [opts?: EnsureOptions]>): Promise<Data>;
|
|
90
|
+
/** Fire and forget; never rejects. */
|
|
91
|
+
prefetch(client: RivaClient, ...args: VarsArgs<Vars>): void;
|
|
92
|
+
/** Marks stale (one entry, or every entry of the definition without variables); observed entries refetch. */
|
|
93
|
+
invalidate(client: RivaClient, vars?: Vars): void;
|
|
94
|
+
/** Writes a success with `updatedAt` now. */
|
|
95
|
+
setData(client: RivaClient, vars: Vars, data: Data | ((prev: Data | undefined) => Data)): void;
|
|
96
|
+
/** Aborts the in-flight fetch and restores the previous state. */
|
|
97
|
+
cancel(client: RivaClient, ...args: VarsArgs<Vars>): void;
|
|
98
|
+
}
|
|
99
|
+
export declare function query<Vars = void, Data = unknown>(opts: QueryOptions<Vars, Data>): Query<Vars, Data>;
|
|
100
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,KAAK,QAAQ,EAAQ,MAAM,YAAY,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG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AG,IAAI,CAAC;IAC5D,6GAA6G;IAC7G,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAClD,6CAA6C;IAC7C,OAAO,CACN,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC,GAC7C,IAAI,CAAC;IACR,kEAAkE;IAClE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC1D;AAKD,wBAAgB,KAAK,CAAC,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,OAAO,EAChD,IAAI,EAAE,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,GAC5B,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAsBnB"}
|
package/dist/retry.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Scheduler } from './env';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a failed fetch is tried again. `failures` counts the failures
|
|
4
|
+
* before this one (0 for the first). An abort and a non-retryable request
|
|
5
|
+
* error never retry; any other error (unknown) does.
|
|
6
|
+
*/
|
|
7
|
+
export declare function shouldRetry(retry: number | ((failures: number, error: unknown) => boolean) | undefined, failures: number, error: unknown): boolean;
|
|
8
|
+
export declare const retryDelay: (fn: ((failures: number) => number) | undefined, failures: number) => number;
|
|
9
|
+
/** Settles with `p`, or as soon as `signal` aborts (rejecting with `RivaAbortError`), even if `p` never settles. */
|
|
10
|
+
export declare function raceAbort<T>(p: Promise<T>, signal: AbortSignal): Promise<T>;
|
|
11
|
+
/** Waits `ms`, or until `signal` aborts (whichever comes first). */
|
|
12
|
+
export declare function sleep(sched: Scheduler, ms: number, signal: AbortSignal): Promise<void>;
|
|
13
|
+
/** Runs `fn` until it succeeds, retrying as `shouldRetry` decides, with backoff; stops with `RivaAbortError` once `signal` aborts. */
|
|
14
|
+
export declare function withRetry<T>(sched: Scheduler, opts: {
|
|
15
|
+
retry: number | ((failures: number, error: unknown) => boolean) | undefined;
|
|
16
|
+
retryDelay: ((failures: number) => number) | undefined;
|
|
17
|
+
}, signal: AbortSignal, fn: () => Promise<T>): Promise<T>;
|
|
18
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;GAIG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,SAAS,EAC3E,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,GACZ,OAAO,CAKT;AAED,eAAO,MAAM,UAAU,OAClB,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,YACpC,MAAM,KACd,MAAsE,CAAC;AAE1E,oHAAoH;AACpH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAS3E;AAED,oEAAoE;AACpE,wBAAgB,KAAK,CACpB,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,WAAW,GACjB,OAAO,CAAC,IAAI,CAAC,CASf;AAED,sIAAsI;AACtI,wBAAsB,SAAS,CAAC,CAAC,EAChC,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE;IACL,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG,SAAS,CAAC;IAC5E,UAAU,EAAE,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;CACvD,EACD,MAAM,EAAE,WAAW,EACnB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,CAAC,CAAC,CAUZ"}
|
package/dist/scope.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RivaClient } from './client';
|
|
2
|
+
/** Browser detection, in one place so tests can drive it through `globalThis.document`. */
|
|
3
|
+
export declare const isBrowser: () => boolean;
|
|
4
|
+
/** The client in scope, if any. */
|
|
5
|
+
export declare const active: () => RivaClient | undefined;
|
|
6
|
+
declare let resolver: (() => RivaClient | undefined) | undefined;
|
|
7
|
+
/** Sets the ambient resolver `@softistx/riva/ssr` exposes. @internal */
|
|
8
|
+
export declare const setResolver: (fn: typeof resolver) => void;
|
|
9
|
+
/** The client in scope, or a `RivaScopeError` naming the fix. */
|
|
10
|
+
export declare function resolve(): RivaClient;
|
|
11
|
+
/** Runs `fn` with `client` as the ambient scope, restoring the previous one after. */
|
|
12
|
+
export declare function withClient<R>(client: RivaClient, fn: () => R): R;
|
|
13
|
+
/** Sets the browser's default client. Throws on the server. */
|
|
14
|
+
export declare function setDefaultClient(client: RivaClient | undefined): void;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAS3C,2FAA2F;AAC3F,eAAO,MAAM,SAAS,QAAO,OAAmC,CAAC;AAEjE,mCAAmC;AACnC,eAAO,MAAM,MAAM,QAAO,UAAU,GAAG,SACyB,CAAC;AAEjE,QAAA,IAAI,QAAQ,EAAE,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;AAEzD,wEAAwE;AACxE,eAAO,MAAM,WAAW,OAAQ,OAAO,QAAQ,KAAG,IAEjD,CAAC;AAEF,iEAAiE;AACjE,wBAAgB,OAAO,IAAI,UAAU,CAOpC;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQhE;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI,CAMrE"}
|
package/dist/signal.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type Listener<T> = (value: T) => void;
|
|
2
|
+
export type Unsubscribe = () => void;
|
|
3
|
+
export interface SignalOptions<T> {
|
|
4
|
+
name?: string;
|
|
5
|
+
equals?: (a: T, b: T) => boolean;
|
|
6
|
+
/** Whether the value travels in an SSR snapshot (it needs a `name` too). Default false: opt in. */
|
|
7
|
+
ssr?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** A stateless definition: it holds no value, a `RivaClient` does. */
|
|
10
|
+
export interface Signal<T> {
|
|
11
|
+
readonly kind: 'signal';
|
|
12
|
+
readonly initial: T;
|
|
13
|
+
readonly name: string | undefined;
|
|
14
|
+
readonly ssr: boolean;
|
|
15
|
+
equals(a: T, b: T): boolean;
|
|
16
|
+
/** Reads through the ambient client. */
|
|
17
|
+
get(): T;
|
|
18
|
+
set(value: NoInfer<T> | ((prev: T) => T)): void;
|
|
19
|
+
subscribe(listener: Listener<T>): Unsubscribe;
|
|
20
|
+
}
|
|
21
|
+
export declare function signal<T>(initial: T, opts?: SignalOptions<T>): Signal<T>;
|
|
22
|
+
//# sourceMappingURL=signal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../src/signal.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;AAC7C,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC;AAErC,MAAM,WAAW,aAAa,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;IACjC,mGAAmG;IACnG,GAAG,CAAC,EAAE,OAAO,CAAC;CACd;AAED,sEAAsE;AACtE,MAAM,WAAW,MAAM,CAAC,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;IAC5B,wCAAwC;IACxC,GAAG,IAAI,CAAC,CAAC;IACT,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC;IAChD,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;CAC9C;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,GAAE,aAAa,CAAC,CAAC,CAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAY5E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RivaError } from '../errors';
|
|
2
|
+
/** The error of every refused snapshot. */
|
|
3
|
+
export declare const ssrError: (message: string) => RivaError;
|
|
4
|
+
/** `encode` with the path shown in a refusal's message. */
|
|
5
|
+
export declare function encodeAt(value: unknown, path?: string, seen?: object[]): unknown;
|
|
6
|
+
/** A JSON-safe copy of `value`: Dates and non-finite numbers are tagged, `$t` keys escaped. */
|
|
7
|
+
export declare const encode: (value: unknown) => unknown;
|
|
8
|
+
/** The inverse of `encode`. */
|
|
9
|
+
export declare function decode(value: unknown): unknown;
|
|
10
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/ssr/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,2CAA2C;AAC3C,eAAO,MAAM,QAAQ,YAAa,MAAM,KAAG,SACR,CAAC;AAWpC,2DAA2D;AAC3D,wBAAgB,QAAQ,CACvB,KAAK,EAAE,OAAO,EACd,IAAI,SAAM,EACV,IAAI,GAAE,MAAM,EAAO,GACjB,OAAO,CAsBT;AAED,+FAA+F;AAC/F,eAAO,MAAM,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAkB,CAAC;AAE5D,+BAA+B;AAC/B,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQ9C"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { RivaClient } from '../client';
|
|
2
|
+
/** The error of a failed entry: its code, status and retryability, never a message, a stack or a cause. */
|
|
3
|
+
export interface SnapshotError {
|
|
4
|
+
code: string;
|
|
5
|
+
status?: number | undefined;
|
|
6
|
+
retryable?: boolean | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface SnapshotEntry {
|
|
9
|
+
/** The entry's key. */
|
|
10
|
+
readonly k: string;
|
|
11
|
+
readonly s: 'success' | 'error';
|
|
12
|
+
/** The data, encoded. */
|
|
13
|
+
readonly d?: unknown;
|
|
14
|
+
readonly e?: SnapshotError | undefined;
|
|
15
|
+
/** Its age in ms when dehydrated. */
|
|
16
|
+
readonly u: number;
|
|
17
|
+
/** Set when the entry was invalidated. */
|
|
18
|
+
readonly i?: 1 | undefined;
|
|
19
|
+
}
|
|
20
|
+
declare const brand: unique symbol;
|
|
21
|
+
/**
|
|
22
|
+
* What `dehydrate` makes: JSON-safe, to be handed to `hydrate` as is. Its
|
|
23
|
+
* fields are an opaque format that may change: never build or edit one.
|
|
24
|
+
*/
|
|
25
|
+
export interface Snapshot {
|
|
26
|
+
/** Type-only: a hand-made literal does not compile. */
|
|
27
|
+
readonly [brand]: true;
|
|
28
|
+
readonly v: 1;
|
|
29
|
+
/** The clock of the dehydrating client, in ms. */
|
|
30
|
+
readonly t: number;
|
|
31
|
+
readonly q: readonly SnapshotEntry[];
|
|
32
|
+
readonly a: Readonly<Record<string, unknown>>;
|
|
33
|
+
}
|
|
34
|
+
/** The settled query entries and the changed named signals of a client, as a JSON-safe snapshot. */
|
|
35
|
+
export declare function dehydrate(client: RivaClient): Snapshot;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=dehydrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dehydrate.d.ts","sourceRoot":"","sources":["../../src/ssr/dehydrate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAK5C,2GAA2G;AAC3G,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC7B,uBAAuB;IACvB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC,yBAAyB;IACzB,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACvC,qCAAqC;IACrC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;CAC3B;AAED,OAAO,CAAC,MAAM,KAAK,EAAE,OAAO,MAAM,CAAC;AAEnC;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACxB,uDAAuD;IACvD,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;IACvB,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;IACd,kDAAkD;IAClD,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACrC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC9C;AASD,oGAAoG;AACpG,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,CA4BtD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RivaClient } from '../client';
|
|
2
|
+
import type { Snapshot, SnapshotEntry } from './dehydrate';
|
|
3
|
+
/** A snapshot entry waiting for its query entry; `defer` holds it back from entries read during a render. @internal */
|
|
4
|
+
export type SeedEntry = SnapshotEntry & {
|
|
5
|
+
at: number;
|
|
6
|
+
defer?: true;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Loads a snapshot into a client. Entries and signals the client does not have
|
|
10
|
+
* yet are seeded the moment their definition is first used; an entry it has
|
|
11
|
+
* is overwritten only by a newer snapshot, and never while it fetches or
|
|
12
|
+
* carries optimistic layers. With `deferObserved` (a render), nothing
|
|
13
|
+
* that could reach an observed entry is written: the entries something
|
|
14
|
+
* observes, those with a cache policy and those not created yet are returned
|
|
15
|
+
* as a snapshot to hand to `hydrate` later, outside the render.
|
|
16
|
+
*/
|
|
17
|
+
export declare function hydrate(client: RivaClient, snapshot: Snapshot, opts?: {
|
|
18
|
+
deferObserved?: boolean;
|
|
19
|
+
}): Snapshot | undefined;
|
|
20
|
+
//# sourceMappingURL=hydrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../../src/ssr/hydrate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAW5C,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAiB,MAAM,aAAa,CAAC;AAE1E,uHAAuH;AACvH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAwCrE;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CACtB,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,QAAQ,EAClB,IAAI,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,GAChC,QAAQ,GAAG,SAAS,CA0CtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ssr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {
|
|
2
|
+
peek,
|
|
3
|
+
committed,
|
|
4
|
+
putData
|
|
5
|
+
} from "../chunks/index-tn8ankny.js";
|
|
6
|
+
import {
|
|
7
|
+
nodeOf
|
|
8
|
+
} from "../chunks/index-e4vzsfy1.js";
|
|
9
|
+
import {
|
|
10
|
+
ssrError,
|
|
11
|
+
encodeAt,
|
|
12
|
+
encode2,
|
|
13
|
+
decode2
|
|
14
|
+
} from "../chunks/index-asz1gnp1.js";
|
|
15
|
+
import {
|
|
16
|
+
setResolver
|
|
17
|
+
} from "../chunks/index-y6bzw104.js";
|
|
18
|
+
import {
|
|
19
|
+
RivaError2,
|
|
20
|
+
RivaRequestError2,
|
|
21
|
+
RivaHttpError2,
|
|
22
|
+
RivaNetworkError2,
|
|
23
|
+
RivaAbortError2
|
|
24
|
+
} from "../chunks/index-2g2s3y31.js";
|
|
25
|
+
// src/ssr/dehydrate.ts
|
|
26
|
+
var errorOf = (e) => {
|
|
27
|
+
const { code, status, retryable } = e;
|
|
28
|
+
return e instanceof RivaError2 ? { code, status, retryable } : { code: "RIVA_UNKNOWN" };
|
|
29
|
+
};
|
|
30
|
+
function dehydrate(client) {
|
|
31
|
+
const c = client.queries.ctx;
|
|
32
|
+
const now = c.sched.now();
|
|
33
|
+
const q = [];
|
|
34
|
+
for (const e of c.entries.values()) {
|
|
35
|
+
const s = peek(c, e);
|
|
36
|
+
if (s.status !== "success" && s.status !== "error")
|
|
37
|
+
continue;
|
|
38
|
+
const data = committed(c, e);
|
|
39
|
+
if (s.status === "success" && data === undefined)
|
|
40
|
+
continue;
|
|
41
|
+
q.push({
|
|
42
|
+
k: e.key,
|
|
43
|
+
s: s.status,
|
|
44
|
+
d: encodeAt(data, `${e.key}.data`),
|
|
45
|
+
e: s.error === undefined ? undefined : errorOf(s.error),
|
|
46
|
+
u: now - s.updatedAt,
|
|
47
|
+
i: e.invalidated ? 1 : undefined
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const a = {};
|
|
51
|
+
for (const [name, n] of client.graph.named) {
|
|
52
|
+
if (n === null)
|
|
53
|
+
throw ssrError(`Cannot dehydrate: two signals are named "${name}". Give each SSR signal a unique name, or set ssr: false.`);
|
|
54
|
+
if (n.def.kind === "signal" && n.value !== n.def.initial)
|
|
55
|
+
a[name] = encodeAt(n.value, `signal "${name}"`);
|
|
56
|
+
}
|
|
57
|
+
return { v: 1, t: now, q, a };
|
|
58
|
+
}
|
|
59
|
+
// src/ssr/hydrate.ts
|
|
60
|
+
var errorOf2 = ({ code, status, retryable }) => {
|
|
61
|
+
if (code === "RIVA_NETWORK")
|
|
62
|
+
return new RivaNetworkError2("");
|
|
63
|
+
if (code === "RIVA_ABORT")
|
|
64
|
+
return new RivaAbortError2("");
|
|
65
|
+
if (code.startsWith("HTTP_") && status !== undefined)
|
|
66
|
+
return new RivaHttpError2(status, "");
|
|
67
|
+
return retryable === undefined ? new RivaError2(code, "") : new RivaRequestError2(code, "", {
|
|
68
|
+
retryable,
|
|
69
|
+
...status !== undefined && { status }
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
function apply(c, e, p) {
|
|
73
|
+
e.invalidated = !!p.i;
|
|
74
|
+
putData(c, e, {
|
|
75
|
+
status: p.s,
|
|
76
|
+
error: p.e && errorOf2(p.e),
|
|
77
|
+
...p.d !== undefined && { data: decode2(p.d), updatedAt: p.at }
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function seed(c, e) {
|
|
81
|
+
const pending = c.pending;
|
|
82
|
+
const p = pending.get(e.key);
|
|
83
|
+
if (p && !(p.defer && e.def.options.cache)) {
|
|
84
|
+
pending.delete(e.key);
|
|
85
|
+
apply(c, e, p);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function hydrate(client, snapshot, opts) {
|
|
89
|
+
const v = snapshot?.v;
|
|
90
|
+
if (v !== 1)
|
|
91
|
+
throw ssrError(`Cannot hydrate: this is not a snapshot dehydrate() made (version ${v}).`);
|
|
92
|
+
const c = client.queries.ctx;
|
|
93
|
+
const { graph: g } = client;
|
|
94
|
+
c.pending ??= new Map;
|
|
95
|
+
const { pending } = c;
|
|
96
|
+
c.seed = seed;
|
|
97
|
+
const now = c.sched.now();
|
|
98
|
+
const defer = opts?.deferObserved;
|
|
99
|
+
const deferred = [];
|
|
100
|
+
client.batch(() => {
|
|
101
|
+
for (const se of snapshot.q) {
|
|
102
|
+
const p = { ...se, at: now - se.u, ...defer && { defer } };
|
|
103
|
+
const e = c.entries.get(se.k);
|
|
104
|
+
if (!e) {
|
|
105
|
+
const old = pending.get(p.k);
|
|
106
|
+
if (!old || old.at <= p.at)
|
|
107
|
+
pending.set(p.k, p);
|
|
108
|
+
if (defer)
|
|
109
|
+
deferred.push(se);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const cur = peek(c, e);
|
|
113
|
+
if (e.run || nodeOf(g, e.lay).value.length || cur.updatedAt > p.at)
|
|
114
|
+
continue;
|
|
115
|
+
if (defer && (e.observers || e.def.options.cache))
|
|
116
|
+
deferred.push(se);
|
|
117
|
+
else
|
|
118
|
+
apply(c, e, p);
|
|
119
|
+
}
|
|
120
|
+
g.seeds ??= new Map;
|
|
121
|
+
for (const name in snapshot.a)
|
|
122
|
+
if (!g.named.has(name))
|
|
123
|
+
g.seeds.set(name, decode2(snapshot.a[name]));
|
|
124
|
+
});
|
|
125
|
+
return deferred.length ? { v: 1, t: snapshot.t, q: deferred, a: {} } : undefined;
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
decode2 as decode,
|
|
129
|
+
dehydrate,
|
|
130
|
+
encode2 as encode,
|
|
131
|
+
hydrate,
|
|
132
|
+
setResolver as setScopeResolver
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
//# debugId=DDED58FCB022391E64756E2164756E21
|
|
136
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/ssr/dehydrate.ts", "../src/ssr/hydrate.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { RivaClient } from '../client';\nimport { RivaError, type RivaRequestError } from '../errors';\nimport { committed, peek } from '../query-entry';\nimport { encodeAt, ssrError } from './codec';\n\n/** The error of a failed entry: its code, status and retryability, never a message, a stack or a cause. */\nexport interface SnapshotError {\n\tcode: string;\n\tstatus?: number | undefined;\n\tretryable?: boolean | undefined;\n}\n\nexport interface SnapshotEntry {\n\t/** The entry's key. */\n\treadonly k: string;\n\treadonly s: 'success' | 'error';\n\t/** The data, encoded. */\n\treadonly d?: unknown;\n\treadonly e?: SnapshotError | undefined;\n\t/** Its age in ms when dehydrated. */\n\treadonly u: number;\n\t/** Set when the entry was invalidated. */\n\treadonly i?: 1 | undefined;\n}\n\ndeclare const brand: unique symbol;\n\n/**\n * What `dehydrate` makes: JSON-safe, to be handed to `hydrate` as is. Its\n * fields are an opaque format that may change: never build or edit one.\n */\nexport interface Snapshot {\n\t/** Type-only: a hand-made literal does not compile. */\n\treadonly [brand]: true;\n\treadonly v: 1;\n\t/** The clock of the dehydrating client, in ms. */\n\treadonly t: number;\n\treadonly q: readonly SnapshotEntry[];\n\treadonly a: Readonly<Record<string, unknown>>;\n}\n\nconst errorOf = (e: unknown): SnapshotError => {\n\tconst { code, status, retryable } = e as RivaRequestError;\n\treturn e instanceof RivaError\n\t\t? { code, status, retryable }\n\t\t: { code: 'RIVA_UNKNOWN' };\n};\n\n/** The settled query entries and the changed named signals of a client, as a JSON-safe snapshot. */\nexport function dehydrate(client: RivaClient): Snapshot {\n\tconst c = client.queries.ctx;\n\tconst now = c.sched.now();\n\tconst q: SnapshotEntry[] = [];\n\tfor (const e of c.entries.values()) {\n\t\tconst s = peek(c, e);\n\t\tif (s.status !== 'success' && s.status !== 'error') continue;\n\t\tconst data = committed(c, e);\n\t\tif (s.status === 'success' && data === undefined) continue;\n\t\tq.push({\n\t\t\tk: e.key,\n\t\t\ts: s.status,\n\t\t\td: encodeAt(data, `${e.key}.data`),\n\t\t\te: s.error === undefined ? undefined : errorOf(s.error),\n\t\t\tu: now - s.updatedAt,\n\t\t\ti: e.invalidated ? 1 : undefined,\n\t\t});\n\t}\n\tconst a: Record<string, unknown> = {};\n\tfor (const [name, n] of client.graph.named) {\n\t\tif (n === null)\n\t\t\tthrow ssrError(\n\t\t\t\t`Cannot dehydrate: two signals are named \"${name}\". Give each SSR signal a unique name, or set ssr: false.`,\n\t\t\t);\n\t\tif (n.def.kind === 'signal' && n.value !== n.def.initial)\n\t\t\ta[name] = encodeAt(n.value, `signal \"${name}\"`);\n\t}\n\treturn { v: 1, t: now, q, a } as unknown as Snapshot;\n}\n",
|
|
6
|
+
"import type { RivaClient } from '../client';\nimport {\n\tRivaAbortError,\n\tRivaError,\n\tRivaHttpError,\n\tRivaNetworkError,\n\tRivaRequestError,\n} from '../errors';\nimport { nodeOf } from '../graph';\nimport { type Ctx, type Entry, type Lay, peek, putData } from '../query-entry';\nimport { decode, ssrError } from './codec';\nimport type { Snapshot, SnapshotEntry, SnapshotError } from './dehydrate';\n\n/** A snapshot entry waiting for its query entry; `defer` holds it back from entries read during a render. @internal */\nexport type SeedEntry = SnapshotEntry & { at: number; defer?: true };\n\n/** Rebuilds the error by its code, so `instanceof` still holds. The message is empty: it never travels. */\nconst errorOf = ({ code, status, retryable }: SnapshotError): unknown => {\n\tif (code === 'RIVA_NETWORK') return new RivaNetworkError('');\n\tif (code === 'RIVA_ABORT') return new RivaAbortError('');\n\tif (code.startsWith('HTTP_') && status !== undefined)\n\t\treturn new RivaHttpError(status, '');\n\treturn retryable === undefined\n\t\t? new RivaError(code, '')\n\t\t: new RivaRequestError(code, '', {\n\t\t\t\tretryable,\n\t\t\t\t...(status !== undefined && { status }),\n\t\t\t});\n};\n\n/** Writes a snapshot entry over an entry, through its definition's cache policy. */\nfunction apply(c: Ctx, e: Entry, p: SeedEntry): void {\n\te.invalidated = !!p.i;\n\tputData(c, e, {\n\t\tstatus: p.s,\n\t\terror: p.e && errorOf(p.e),\n\t\t...(p.d !== undefined && { data: decode(p.d), updatedAt: p.at }),\n\t});\n}\n\n/**\n * Called on each new entry: applies what a snapshot held for it. An entry\n * whose definition has a cache policy, hydrated for a render, is left for\n * the deferred pass: its write would reach entities other entries observe.\n */\nfunction seed(c: Ctx, e: Entry): void {\n\tconst pending = c.pending as Map<string, SeedEntry>;\n\tconst p = pending.get(e.key);\n\tif (p && !(p.defer && e.def.options.cache)) {\n\t\tpending.delete(e.key);\n\t\tapply(c, e, p);\n\t}\n}\n\n/**\n * Loads a snapshot into a client. Entries and signals the client does not have\n * yet are seeded the moment their definition is first used; an entry it has\n * is overwritten only by a newer snapshot, and never while it fetches or\n * carries optimistic layers. With `deferObserved` (a render), nothing\n * that could reach an observed entry is written: the entries something\n * observes, those with a cache policy and those not created yet are returned\n * as a snapshot to hand to `hydrate` later, outside the render.\n */\nexport function hydrate(\n\tclient: RivaClient,\n\tsnapshot: Snapshot,\n\topts?: { deferObserved?: boolean },\n): Snapshot | undefined {\n\tconst v = (snapshot as { v?: unknown } | undefined)?.v;\n\tif (v !== 1)\n\t\tthrow ssrError(\n\t\t\t`Cannot hydrate: this is not a snapshot dehydrate() made (version ${v}).`,\n\t\t);\n\tconst c = client.queries.ctx;\n\tconst { graph: g } = client;\n\tc.pending ??= new Map();\n\tconst { pending } = c;\n\tc.seed = seed;\n\tconst now = c.sched.now();\n\tconst defer = opts?.deferObserved;\n\tconst deferred: SnapshotEntry[] = [];\n\tclient.batch(() => {\n\t\tfor (const se of snapshot.q) {\n\t\t\t// A deferred snapshot is applied later, so its ages are understated by the delay.\n\t\t\tconst p: SeedEntry = { ...se, at: now - se.u, ...(defer && { defer }) };\n\t\t\tconst e = c.entries.get(se.k);\n\t\t\tif (!e) {\n\t\t\t\tconst old = pending.get(p.k);\n\t\t\t\tif (!old || old.at <= p.at) pending.set(p.k, p);\n\t\t\t\tif (defer) deferred.push(se);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst cur = peek(c, e);\n\t\t\tif (\n\t\t\t\te.run ||\n\t\t\t\t(nodeOf(g, e.lay).value as Lay[]).length ||\n\t\t\t\tcur.updatedAt > p.at\n\t\t\t)\n\t\t\t\tcontinue;\n\t\t\tif (defer && (e.observers || e.def.options.cache)) deferred.push(se);\n\t\t\telse apply(c, e, p);\n\t\t}\n\t\tg.seeds ??= new Map();\n\t\tfor (const name in snapshot.a)\n\t\t\tif (!g.named.has(name)) g.seeds.set(name, decode(snapshot.a[name]));\n\t});\n\treturn deferred.length\n\t\t? ({ v: 1, t: snapshot.t, q: deferred, a: {} } as unknown as Snapshot)\n\t\t: undefined;\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAM,UAAU,CAAC,MAA8B;AAAA,EAC9C,QAAQ,MAAM,QAAQ,cAAc;AAAA,EACpC,OAAO,aAAa,aACjB,EAAE,MAAM,QAAQ,UAAU,IAC1B,EAAE,MAAM,eAAe;AAAA;AAIpB,SAAS,SAAS,CAAC,QAA8B;AAAA,EACvD,MAAM,IAAI,OAAO,QAAQ;AAAA,EACzB,MAAM,MAAM,EAAE,MAAM,IAAI;AAAA,EACxB,MAAM,IAAqB,CAAC;AAAA,EAC5B,WAAW,KAAK,EAAE,QAAQ,OAAO,GAAG;AAAA,IACnC,MAAM,IAAI,KAAK,GAAG,CAAC;AAAA,IACnB,IAAI,EAAE,WAAW,aAAa,EAAE,WAAW;AAAA,MAAS;AAAA,IACpD,MAAM,OAAO,UAAU,GAAG,CAAC;AAAA,IAC3B,IAAI,EAAE,WAAW,aAAa,SAAS;AAAA,MAAW;AAAA,IAClD,EAAE,KAAK;AAAA,MACN,GAAG,EAAE;AAAA,MACL,GAAG,EAAE;AAAA,MACL,GAAG,SAAS,MAAM,GAAG,EAAE,UAAU;AAAA,MACjC,GAAG,EAAE,UAAU,YAAY,YAAY,QAAQ,EAAE,KAAK;AAAA,MACtD,GAAG,MAAM,EAAE;AAAA,MACX,GAAG,EAAE,cAAc,IAAI;AAAA,IACxB,CAAC;AAAA,EACF;AAAA,EACA,MAAM,IAA6B,CAAC;AAAA,EACpC,YAAY,MAAM,MAAM,OAAO,MAAM,OAAO;AAAA,IAC3C,IAAI,MAAM;AAAA,MACT,MAAM,S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AG,EAAE,MAAM,IAAI,MAAM,QAAO,SAAS,EAAE,KAAK,CAAC;AAAA,GACnE;AAAA,EACD,OAAO,SAAS,SACZ,EAAE,GAAG,GAAG,GAAG,SAAS,GAAG,GAAG,UAAU,GAAG,CAAC,EAAE,IAC3C;AAAA;",
|
|
9
|
+
"debugId": "DDED58FCB022391E64756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RivaClient } from '../client';
|
|
2
|
+
import type { Readable } from '../computed';
|
|
3
|
+
import { type Getter } from '../computed';
|
|
4
|
+
import { type Signal } from '../signal';
|
|
5
|
+
import type { Action } from './types';
|
|
6
|
+
/** The data of one store definition, shared by its action runner and its per-client instance. */
|
|
7
|
+
export interface StoreDef {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** The state keys' signals, named `<name>.<key>`. */
|
|
10
|
+
readonly sigs: Record<string, Signal<unknown>>;
|
|
11
|
+
/** The signals and computeds, by key. */
|
|
12
|
+
readonly members: Record<string, Readable<unknown>>;
|
|
13
|
+
readonly actions: Record<string, Action<any, any>>;
|
|
14
|
+
}
|
|
15
|
+
/** Keys a store cannot use: its own members, and `then` (a store is never thenable). */
|
|
16
|
+
export declare const RESERVED: string[];
|
|
17
|
+
/** Dev only: a stored value cannot be mutated in place, so a nested write throws. */
|
|
18
|
+
export declare const freeze: <T>(v: T) => T;
|
|
19
|
+
/** The browser keeps the newest of two stores with one name (hot reload); the server refuses. */
|
|
20
|
+
export declare const inBrowser: () => boolean;
|
|
21
|
+
/** Whether a write is allowed now: the guard the state signals' `equals` asks. */
|
|
22
|
+
export declare const writable: () => boolean;
|
|
23
|
+
/** Writes one state key through its signal, with the guard raised. */
|
|
24
|
+
export declare const put: (client: RivaClient, sig: Signal<unknown>, value: unknown) => void;
|
|
25
|
+
/** Refuses a state, computed or action key that is reserved or used twice. */
|
|
26
|
+
export declare const checkKeys: (name: string, keys: readonly string[]) => void;
|
|
27
|
+
/** The state keys' signals, named `<name>.<key>`, guarded against writes outside an action. */
|
|
28
|
+
export declare const stateSignals: (name: string, state: Record<string, unknown>, ssr: boolean) => Record<string, Signal<unknown>>;
|
|
29
|
+
/** The store's computeds, each reading the state through a read-only view. */
|
|
30
|
+
export declare const computeds: (name: string, state: Record<string, unknown>, derived: Record<string, (s: unknown, get: Getter) => unknown>, sigs: Record<string, Signal<unknown>>) => Record<string, Readable<unknown>>;
|
|
31
|
+
//# sourceMappingURL=def.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"def.d.ts","sourceRoot":"","sources":["../../src/store/def.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC,iGAAiG;AACjG,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/C,yCAAyC;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAEpD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;CACnD;AAED,wFAAwF;AACxF,eAAO,MAAM,QAAQ,UAA4C,CAAC;AAQlE,qFAAqF;AACrF,eAAO,MAAM,MAAM,GAAI,CAAC,KAAK,CAAC,KAAG,CAMhC,CAAC;AA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