nowity 1.0.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/README.md +751 -0
- package/dist/api/contract.d.ts +186 -0
- package/dist/api/contract.d.ts.map +1 -0
- package/dist/api/contract.js +251 -0
- package/dist/api/errors.d.ts +50 -0
- package/dist/api/errors.d.ts.map +1 -0
- package/dist/api/errors.js +50 -0
- package/dist/api/index.d.ts +13 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +32 -0
- package/dist/client/confirmed-store.d.ts +33 -0
- package/dist/client/confirmed-store.d.ts.map +1 -0
- package/dist/client/confirmed-store.js +123 -0
- package/dist/client/connection.d.ts +102 -0
- package/dist/client/connection.d.ts.map +1 -0
- package/dist/client/connection.js +285 -0
- package/dist/client/list.d.ts +102 -0
- package/dist/client/list.d.ts.map +1 -0
- package/dist/client/list.js +257 -0
- package/dist/client/live-query.d.ts +153 -0
- package/dist/client/live-query.d.ts.map +1 -0
- package/dist/client/live-query.js +244 -0
- package/dist/client/nowity-client.d.ts +188 -0
- package/dist/client/nowity-client.d.ts.map +1 -0
- package/dist/client/nowity-client.js +580 -0
- package/dist/client/null-transport.d.ts +16 -0
- package/dist/client/null-transport.d.ts.map +1 -0
- package/dist/client/null-transport.js +17 -0
- package/dist/client/overlay.d.ts +44 -0
- package/dist/client/overlay.d.ts.map +1 -0
- package/dist/client/overlay.js +90 -0
- package/dist/client/query-source.d.ts +78 -0
- package/dist/client/query-source.d.ts.map +1 -0
- package/dist/client/query-source.js +57 -0
- package/dist/client/ssr-source.d.ts +70 -0
- package/dist/client/ssr-source.d.ts.map +1 -0
- package/dist/client/ssr-source.js +134 -0
- package/dist/client/transport.d.ts +19 -0
- package/dist/client/transport.d.ts.map +1 -0
- package/dist/client/transport.js +2 -0
- package/dist/client/ws-transport.d.ts +30 -0
- package/dist/client/ws-transport.d.ts.map +1 -0
- package/dist/client/ws-transport.js +89 -0
- package/dist/client.d.ts +47 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +80 -0
- package/dist/core/diff.d.ts +14 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/core/diff.js +56 -0
- package/dist/core/normalize.d.ts +16 -0
- package/dist/core/normalize.d.ts.map +1 -0
- package/dist/core/normalize.js +67 -0
- package/dist/core/protocol.d.ts +215 -0
- package/dist/core/protocol.d.ts.map +1 -0
- package/dist/core/protocol.js +14 -0
- package/dist/core/ssr-bridge.d.ts +69 -0
- package/dist/core/ssr-bridge.d.ts.map +1 -0
- package/dist/core/ssr-bridge.js +40 -0
- package/dist/core/types.d.ts +96 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +17 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +98 -0
- package/dist/ironbean/client.d.ts +7 -0
- package/dist/ironbean/client.d.ts.map +1 -0
- package/dist/ironbean/client.js +38 -0
- package/dist/ironbean/server.d.ts +42 -0
- package/dist/ironbean/server.d.ts.map +1 -0
- package/dist/ironbean/server.js +62 -0
- package/dist/ironbean/tokens.d.ts +26 -0
- package/dist/ironbean/tokens.d.ts.map +1 -0
- package/dist/ironbean/tokens.js +23 -0
- package/dist/next/config.d.ts +7 -0
- package/dist/next/config.d.ts.map +1 -0
- package/dist/next/config.js +77 -0
- package/dist/next/live.d.ts +69 -0
- package/dist/next/live.d.ts.map +1 -0
- package/dist/next/live.js +70 -0
- package/dist/next/serve.d.ts +44 -0
- package/dist/next/serve.d.ts.map +1 -0
- package/dist/next/serve.js +107 -0
- package/dist/next/server.d.ts +62 -0
- package/dist/next/server.d.ts.map +1 -0
- package/dist/next/server.js +127 -0
- package/dist/react/connection-context.d.ts +4 -0
- package/dist/react/connection-context.d.ts.map +1 -0
- package/dist/react/connection-context.js +28 -0
- package/dist/react/grid-list.d.ts +34 -0
- package/dist/react/grid-list.d.ts.map +1 -0
- package/dist/react/grid-list.js +62 -0
- package/dist/react/hydrate.d.ts +22 -0
- package/dist/react/hydrate.d.ts.map +1 -0
- package/dist/react/hydrate.js +18 -0
- package/dist/react/index.d.ts +35 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +51 -0
- package/dist/react/list.d.ts +31 -0
- package/dist/react/list.d.ts.map +1 -0
- package/dist/react/list.js +35 -0
- package/dist/react/prerendered.d.ts +33 -0
- package/dist/react/prerendered.d.ts.map +1 -0
- package/dist/react/prerendered.js +165 -0
- package/dist/react/provider.d.ts +64 -0
- package/dist/react/provider.d.ts.map +1 -0
- package/dist/react/provider.js +130 -0
- package/dist/react/refusals.d.ts +31 -0
- package/dist/react/refusals.d.ts.map +1 -0
- package/dist/react/refusals.js +51 -0
- package/dist/react/restricted.d.ts +76 -0
- package/dist/react/restricted.d.ts.map +1 -0
- package/dist/react/restricted.js +126 -0
- package/dist/react/use-list.d.ts +42 -0
- package/dist/react/use-list.d.ts.map +1 -0
- package/dist/react/use-list.js +56 -0
- package/dist/react/use-query.d.ts +66 -0
- package/dist/react/use-query.d.ts.map +1 -0
- package/dist/react/use-query.js +126 -0
- package/dist/react/virtual.d.ts +60 -0
- package/dist/react/virtual.d.ts.map +1 -0
- package/dist/react/virtual.js +131 -0
- package/dist/server/api/auth.d.ts +37 -0
- package/dist/server/api/auth.d.ts.map +1 -0
- package/dist/server/api/auth.js +54 -0
- package/dist/server/api/bridge.d.ts +28 -0
- package/dist/server/api/bridge.d.ts.map +1 -0
- package/dist/server/api/bridge.js +330 -0
- package/dist/server/api/collector.d.ts +25 -0
- package/dist/server/api/collector.d.ts.map +1 -0
- package/dist/server/api/collector.js +184 -0
- package/dist/server/api/configure.d.ts +31 -0
- package/dist/server/api/configure.d.ts.map +1 -0
- package/dist/server/api/configure.js +67 -0
- package/dist/server/api/execution.d.ts +77 -0
- package/dist/server/api/execution.d.ts.map +1 -0
- package/dist/server/api/execution.js +97 -0
- package/dist/server/api/list.d.ts +141 -0
- package/dist/server/api/list.d.ts.map +1 -0
- package/dist/server/api/list.js +281 -0
- package/dist/server/api/prerender.d.ts +32 -0
- package/dist/server/api/prerender.d.ts.map +1 -0
- package/dist/server/api/prerender.js +69 -0
- package/dist/server/api/read-keys.d.ts +128 -0
- package/dist/server/api/read-keys.d.ts.map +1 -0
- package/dist/server/api/read-keys.js +464 -0
- package/dist/server/api/read-set.d.ts +103 -0
- package/dist/server/api/read-set.d.ts.map +1 -0
- package/dist/server/api/read-set.js +210 -0
- package/dist/server/api/runtime.d.ts +36 -0
- package/dist/server/api/runtime.d.ts.map +1 -0
- package/dist/server/api/runtime.js +49 -0
- package/dist/server/api/tracked-client.d.ts +6 -0
- package/dist/server/api/tracked-client.d.ts.map +1 -0
- package/dist/server/api/tracked-client.js +56 -0
- package/dist/server/change-source/change-source.d.ts +41 -0
- package/dist/server/change-source/change-source.d.ts.map +1 -0
- package/dist/server/change-source/change-source.js +2 -0
- package/dist/server/change-source/outbox-change-source.d.ts +106 -0
- package/dist/server/change-source/outbox-change-source.d.ts.map +1 -0
- package/dist/server/change-source/outbox-change-source.js +237 -0
- package/dist/server/change-source/wal-change-source.d.ts +85 -0
- package/dist/server/change-source/wal-change-source.d.ts.map +1 -0
- package/dist/server/change-source/wal-change-source.js +193 -0
- package/dist/server/db.d.ts +51 -0
- package/dist/server/db.d.ts.map +1 -0
- package/dist/server/db.js +53 -0
- package/dist/server/evaluate.d.ts +39 -0
- package/dist/server/evaluate.d.ts.map +1 -0
- package/dist/server/evaluate.js +61 -0
- package/dist/server/invalidation-index.d.ts +64 -0
- package/dist/server/invalidation-index.d.ts.map +1 -0
- package/dist/server/invalidation-index.js +0 -0
- package/dist/server/mutator.d.ts +59 -0
- package/dist/server/mutator.d.ts.map +1 -0
- package/dist/server/mutator.js +77 -0
- package/dist/server/query.d.ts +113 -0
- package/dist/server/query.d.ts.map +1 -0
- package/dist/server/query.js +35 -0
- package/dist/server/setup.d.ts +30 -0
- package/dist/server/setup.d.ts.map +1 -0
- package/dist/server/setup.js +107 -0
- package/dist/server/sql/setup.sql +215 -0
- package/dist/server/ssr.d.ts +29 -0
- package/dist/server/ssr.d.ts.map +1 -0
- package/dist/server/ssr.js +43 -0
- package/dist/server/sync-engine.d.ts +256 -0
- package/dist/server/sync-engine.d.ts.map +1 -0
- package/dist/server/sync-engine.js +805 -0
- package/dist/server/ws-server.d.ts +56 -0
- package/dist/server/ws-server.d.ts.map +1 -0
- package/dist/server/ws-server.js +241 -0
- package/package.json +81 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfirmedStore = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The server-authoritative state of the client, as plain data.
|
|
6
|
+
*
|
|
7
|
+
* This is deliberately *not* the MobX layer. Optimistic mutations are replayed on
|
|
8
|
+
* top of this on every rebase, so it has to stay untouched by local writes —
|
|
9
|
+
* otherwise a rejected mutation could never be undone.
|
|
10
|
+
*
|
|
11
|
+
* Rows are shared between subscriptions and reference-counted: two live queries
|
|
12
|
+
* returning the same document hold one row, and the row survives until the last
|
|
13
|
+
* of them stops referencing it.
|
|
14
|
+
*/
|
|
15
|
+
class ConfirmedStore {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.rows = new Map();
|
|
18
|
+
this.refs = new Map();
|
|
19
|
+
/** subId → entity → referenced ids, so a snapshot can release the old set. */
|
|
20
|
+
this.bySub = new Map();
|
|
21
|
+
}
|
|
22
|
+
entities() {
|
|
23
|
+
return [...this.rows.keys()];
|
|
24
|
+
}
|
|
25
|
+
rowsOf(entity) {
|
|
26
|
+
return this.rows.get(entity) ?? new Map();
|
|
27
|
+
}
|
|
28
|
+
get(entity, id) {
|
|
29
|
+
return this.rows.get(entity)?.get(id);
|
|
30
|
+
}
|
|
31
|
+
/** Replace everything `subId` holds for `entity`. */
|
|
32
|
+
setSnapshot(subId, entity, rows, idField) {
|
|
33
|
+
const nextIds = new Set();
|
|
34
|
+
for (const row of rows) {
|
|
35
|
+
const id = String(row[idField]);
|
|
36
|
+
nextIds.add(id);
|
|
37
|
+
this.rowMap(entity).set(id, { ...row });
|
|
38
|
+
}
|
|
39
|
+
const previous = this.subEntity(subId, entity);
|
|
40
|
+
for (const id of previous) {
|
|
41
|
+
if (!nextIds.has(id))
|
|
42
|
+
this.release(subId, entity, id);
|
|
43
|
+
}
|
|
44
|
+
for (const id of nextIds)
|
|
45
|
+
this.retain(subId, entity, id);
|
|
46
|
+
this.bySub.get(subId).set(entity, nextIds);
|
|
47
|
+
}
|
|
48
|
+
applyUpsert(subId, entity, patches) {
|
|
49
|
+
for (const patch of patches) {
|
|
50
|
+
const map = this.rowMap(entity);
|
|
51
|
+
const existing = map.get(patch.id);
|
|
52
|
+
map.set(patch.id, existing ? { ...existing, ...patch.fields } : { ...patch.fields });
|
|
53
|
+
this.retain(subId, entity, patch.id);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
applyRemove(subId, entity, ids) {
|
|
57
|
+
for (const id of ids)
|
|
58
|
+
this.release(subId, entity, id);
|
|
59
|
+
}
|
|
60
|
+
/** Drop every row held only by this subscription. */
|
|
61
|
+
releaseSub(subId) {
|
|
62
|
+
const owned = this.bySub.get(subId);
|
|
63
|
+
if (!owned)
|
|
64
|
+
return;
|
|
65
|
+
for (const [entity, ids] of owned) {
|
|
66
|
+
for (const id of [...ids])
|
|
67
|
+
this.release(subId, entity, id);
|
|
68
|
+
}
|
|
69
|
+
this.bySub.delete(subId);
|
|
70
|
+
}
|
|
71
|
+
clear() {
|
|
72
|
+
this.rows.clear();
|
|
73
|
+
this.refs.clear();
|
|
74
|
+
this.bySub.clear();
|
|
75
|
+
}
|
|
76
|
+
rowMap(entity) {
|
|
77
|
+
let map = this.rows.get(entity);
|
|
78
|
+
if (!map) {
|
|
79
|
+
map = new Map();
|
|
80
|
+
this.rows.set(entity, map);
|
|
81
|
+
}
|
|
82
|
+
return map;
|
|
83
|
+
}
|
|
84
|
+
subEntity(subId, entity) {
|
|
85
|
+
let owned = this.bySub.get(subId);
|
|
86
|
+
if (!owned) {
|
|
87
|
+
owned = new Map();
|
|
88
|
+
this.bySub.set(subId, owned);
|
|
89
|
+
}
|
|
90
|
+
let ids = owned.get(entity);
|
|
91
|
+
if (!ids) {
|
|
92
|
+
ids = new Set();
|
|
93
|
+
owned.set(entity, ids);
|
|
94
|
+
}
|
|
95
|
+
return ids;
|
|
96
|
+
}
|
|
97
|
+
retain(subId, entity, id) {
|
|
98
|
+
this.subEntity(subId, entity).add(id);
|
|
99
|
+
let byEntity = this.refs.get(entity);
|
|
100
|
+
if (!byEntity) {
|
|
101
|
+
byEntity = new Map();
|
|
102
|
+
this.refs.set(entity, byEntity);
|
|
103
|
+
}
|
|
104
|
+
let holders = byEntity.get(id);
|
|
105
|
+
if (!holders) {
|
|
106
|
+
holders = new Set();
|
|
107
|
+
byEntity.set(id, holders);
|
|
108
|
+
}
|
|
109
|
+
holders.add(subId);
|
|
110
|
+
}
|
|
111
|
+
release(subId, entity, id) {
|
|
112
|
+
this.subEntity(subId, entity).delete(id);
|
|
113
|
+
const holders = this.refs.get(entity)?.get(id);
|
|
114
|
+
if (!holders)
|
|
115
|
+
return;
|
|
116
|
+
holders.delete(subId);
|
|
117
|
+
if (holders.size === 0) {
|
|
118
|
+
this.refs.get(entity).delete(id);
|
|
119
|
+
this.rows.get(entity)?.delete(id);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.ConfirmedStore = ConfirmedStore;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The client half of the class-based API.
|
|
3
|
+
*
|
|
4
|
+
* `container.getBean(DocumentApi)` hands back a proxy with the same methods the
|
|
5
|
+
* server implements and the same signatures, and calling one returns the same
|
|
6
|
+
* type the server method returns — except that the objects inside it are live.
|
|
7
|
+
*
|
|
8
|
+
* Two things are deliberately not in the returned value: loading and failure.
|
|
9
|
+
* Acquisition is asynchronous, so "not there yet" is a pending promise and "not
|
|
10
|
+
* allowed" is a rejected one. React's `<Suspense>` and error boundaries already
|
|
11
|
+
* know what to do with both, which is why no result carries a `status` field.
|
|
12
|
+
*/
|
|
13
|
+
import { type IObservableArray } from "mobx";
|
|
14
|
+
import type { HydrationPayload } from "../core/protocol";
|
|
15
|
+
import { NowityClient, type NowityClientOptions } from "./nowity-client";
|
|
16
|
+
import type { LiveQuery } from "./live-query";
|
|
17
|
+
import { type QueryError, type QuerySource } from "./query-source";
|
|
18
|
+
export type EndpointKind = "query" | "mutation" | "list";
|
|
19
|
+
export type { QueryError };
|
|
20
|
+
export interface NowityConnectionOptions extends Omit<NowityClientOptions, "onWelcome"> {
|
|
21
|
+
/**
|
|
22
|
+
* How long a query with no holders stays subscribed.
|
|
23
|
+
*
|
|
24
|
+
* It exists for the render that never commits. A component can acquire a
|
|
25
|
+
* query and then be thrown away by Suspense before its effects ever run, so
|
|
26
|
+
* nothing would be left to release it; the grace period collects exactly
|
|
27
|
+
* those, and doubles as the window that survives a remount.
|
|
28
|
+
*/
|
|
29
|
+
graceMs?: number;
|
|
30
|
+
}
|
|
31
|
+
/** One live query, shared by everyone who asked for it with the same arguments. */
|
|
32
|
+
declare class LiveEntry {
|
|
33
|
+
readonly key: string;
|
|
34
|
+
readonly live: LiveQuery<any>;
|
|
35
|
+
/** Stable array whose *contents* change — the identity never does. */
|
|
36
|
+
readonly rows: IObservableArray<any>;
|
|
37
|
+
readonly settled: Promise<void>;
|
|
38
|
+
refs: number;
|
|
39
|
+
timer: ReturnType<typeof setTimeout> | null;
|
|
40
|
+
single: boolean;
|
|
41
|
+
failure: Error | null;
|
|
42
|
+
private readonly stopSync;
|
|
43
|
+
private stopSettle;
|
|
44
|
+
private stopCardinality;
|
|
45
|
+
constructor(key: string, live: LiveQuery<any>);
|
|
46
|
+
/** Why this query cannot be read, or null — {@link problemOf}, live. */
|
|
47
|
+
get problem(): QueryError | null;
|
|
48
|
+
get loading(): boolean;
|
|
49
|
+
/** What the caller gets: the live list, or the single row the method returned. */
|
|
50
|
+
get value(): unknown;
|
|
51
|
+
/** Called once the server has said whether this endpoint returns one row. */
|
|
52
|
+
watchCardinality(isSingle: () => boolean | undefined): void;
|
|
53
|
+
dispose(): void;
|
|
54
|
+
}
|
|
55
|
+
export declare function activeConnection(): NowityConnection;
|
|
56
|
+
export declare function currentConnection(): NowityConnection | null;
|
|
57
|
+
export declare function setActiveConnection(connection: NowityConnection | null): void;
|
|
58
|
+
export declare class NowityConnection implements QuerySource {
|
|
59
|
+
readonly client: NowityClient;
|
|
60
|
+
/** {@link QuerySource.rendersOnce} — a browser renders as often as it likes. */
|
|
61
|
+
readonly rendersOnce = false;
|
|
62
|
+
private readonly entries;
|
|
63
|
+
private readonly proxies;
|
|
64
|
+
private readonly graceMs;
|
|
65
|
+
private kinds;
|
|
66
|
+
private manifest;
|
|
67
|
+
private resolveManifest;
|
|
68
|
+
private readonly manifestReady;
|
|
69
|
+
constructor(options: NowityConnectionOptions);
|
|
70
|
+
connect(): void;
|
|
71
|
+
/** {@link QuerySource.hydrate} — the store's own, so both sources seed alike. */
|
|
72
|
+
hydrate(payloads: HydrationPayload[]): void;
|
|
73
|
+
close(): void;
|
|
74
|
+
private adoptManifest;
|
|
75
|
+
/** The proxy for a service, by its token. */
|
|
76
|
+
service<T extends object>(token: abstract new (...args: any[]) => T): T;
|
|
77
|
+
/**
|
|
78
|
+
* The proxy bound to one contract.
|
|
79
|
+
*
|
|
80
|
+
* Methods are not enumerated from the class: an abstract method emits no
|
|
81
|
+
* runtime property, so there is nothing to enumerate. Every property access
|
|
82
|
+
* returns a callable instead, and the manifest decides at call time whether
|
|
83
|
+
* it opens a subscription or sends a write.
|
|
84
|
+
*/
|
|
85
|
+
contract<T extends object>(name: string): T;
|
|
86
|
+
private bind;
|
|
87
|
+
call(name: string, args: unknown[]): Promise<unknown>;
|
|
88
|
+
private kindOf;
|
|
89
|
+
/**
|
|
90
|
+
* Get or create the shared entry for one query.
|
|
91
|
+
*
|
|
92
|
+
* Does *not* take a reference: a render that never commits would otherwise
|
|
93
|
+
* leak one. The grace timer started here collects exactly that case, and
|
|
94
|
+
* {@link retain} cancels it when a component does commit.
|
|
95
|
+
*/
|
|
96
|
+
ensure(name: string, args: unknown[]): LiveEntry;
|
|
97
|
+
retain(entry: LiveEntry): void;
|
|
98
|
+
release(entry: LiveEntry): void;
|
|
99
|
+
private scheduleRelease;
|
|
100
|
+
private clearTimer;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/client/connection.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NowityConnection = void 0;
|
|
4
|
+
exports.activeConnection = activeConnection;
|
|
5
|
+
exports.currentConnection = currentConnection;
|
|
6
|
+
exports.setActiveConnection = setActiveConnection;
|
|
7
|
+
/**
|
|
8
|
+
* The client half of the class-based API.
|
|
9
|
+
*
|
|
10
|
+
* `container.getBean(DocumentApi)` hands back a proxy with the same methods the
|
|
11
|
+
* server implements and the same signatures, and calling one returns the same
|
|
12
|
+
* type the server method returns — except that the objects inside it are live.
|
|
13
|
+
*
|
|
14
|
+
* Two things are deliberately not in the returned value: loading and failure.
|
|
15
|
+
* Acquisition is asynchronous, so "not there yet" is a pending promise and "not
|
|
16
|
+
* allowed" is a rejected one. React's `<Suspense>` and error boundaries already
|
|
17
|
+
* know what to do with both, which is why no result carries a `status` field.
|
|
18
|
+
*/
|
|
19
|
+
const mobx_1 = require("mobx");
|
|
20
|
+
const contract_1 = require("../api/contract");
|
|
21
|
+
const nowity_client_1 = require("./nowity-client");
|
|
22
|
+
const query_source_1 = require("./query-source");
|
|
23
|
+
/** One live query, shared by everyone who asked for it with the same arguments. */
|
|
24
|
+
class LiveEntry {
|
|
25
|
+
constructor(key, live) {
|
|
26
|
+
this.key = key;
|
|
27
|
+
/** Stable array whose *contents* change — the identity never does. */
|
|
28
|
+
this.rows = mobx_1.observable.array([], { deep: false });
|
|
29
|
+
this.refs = 0;
|
|
30
|
+
this.timer = null;
|
|
31
|
+
this.single = false;
|
|
32
|
+
this.failure = null;
|
|
33
|
+
this.stopSettle = null;
|
|
34
|
+
this.stopCardinality = null;
|
|
35
|
+
this.live = live;
|
|
36
|
+
// Seed synchronously, *then* start reacting. An autorun created inside
|
|
37
|
+
// another reaction — which is exactly what happens when an `observer`
|
|
38
|
+
// component asks for a query during its render — does not run until the
|
|
39
|
+
// surrounding batch ends, so the render that created it would otherwise
|
|
40
|
+
// see an empty array and paint nothing.
|
|
41
|
+
(0, mobx_1.runInAction)(() => this.rows.replace(live.rows));
|
|
42
|
+
// A reaction that writes to an observable has to say so; MobX's strict
|
|
43
|
+
// mode is right to complain otherwise.
|
|
44
|
+
this.stopSync = (0, mobx_1.autorun)(() => {
|
|
45
|
+
const next = live.rows;
|
|
46
|
+
(0, mobx_1.runInAction)(() => this.rows.replace(next));
|
|
47
|
+
});
|
|
48
|
+
// `when`, not `autorun`: the condition is very often already true — a
|
|
49
|
+
// hydrated query is ready before anyone can await it — and a reaction that
|
|
50
|
+
// disposes itself on its first synchronous run cannot reach its own
|
|
51
|
+
// disposer yet.
|
|
52
|
+
this.settled = new Promise((resolve, reject) => {
|
|
53
|
+
this.stopSettle = (0, mobx_1.when)(() => this.live.status !== "loading", () => {
|
|
54
|
+
const problem = this.problem;
|
|
55
|
+
if (!problem)
|
|
56
|
+
return resolve();
|
|
57
|
+
this.failure = problem;
|
|
58
|
+
reject(problem);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
// Nobody may be waiting on it yet; an unhandled rejection here would be
|
|
62
|
+
// reported before the component that asked for the data even renders.
|
|
63
|
+
this.settled.catch(() => undefined);
|
|
64
|
+
}
|
|
65
|
+
/** Why this query cannot be read, or null — {@link problemOf}, live. */
|
|
66
|
+
get problem() {
|
|
67
|
+
return (0, query_source_1.problemOf)(this.live);
|
|
68
|
+
}
|
|
69
|
+
get loading() {
|
|
70
|
+
return this.live.status === "loading";
|
|
71
|
+
}
|
|
72
|
+
/** What the caller gets: the live list, or the single row the method returned. */
|
|
73
|
+
get value() {
|
|
74
|
+
return (0, query_source_1.valueOf)(this.rows, this.single);
|
|
75
|
+
}
|
|
76
|
+
/** Called once the server has said whether this endpoint returns one row. */
|
|
77
|
+
watchCardinality(isSingle) {
|
|
78
|
+
this.stopCardinality = (0, mobx_1.when)(() => isSingle() !== undefined, () => {
|
|
79
|
+
this.single = isSingle() === true;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
dispose() {
|
|
83
|
+
this.stopSync();
|
|
84
|
+
this.stopSettle?.();
|
|
85
|
+
this.stopCardinality?.();
|
|
86
|
+
this.live.dispose();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const ACTIVE = Symbol.for("nowity.activeConnection");
|
|
90
|
+
/**
|
|
91
|
+
* The connection this browser is using.
|
|
92
|
+
*
|
|
93
|
+
* A singleton rather than a React context, because there is exactly one per
|
|
94
|
+
* browser session and threading a provider through the tree bought nothing but a
|
|
95
|
+
* wrapper. Server-side rendering of client components configures its own, with
|
|
96
|
+
* no socket, so components there simply have no data yet.
|
|
97
|
+
*
|
|
98
|
+
* Held on `globalThis` rather than in a module variable: a development build
|
|
99
|
+
* re-evaluates modules, and a connection that lived in this one would vanish
|
|
100
|
+
* while the component that opened it stayed mounted — leaving every query with
|
|
101
|
+
* nowhere to ask.
|
|
102
|
+
*/
|
|
103
|
+
function slot() {
|
|
104
|
+
const global = globalThis;
|
|
105
|
+
return (global[ACTIVE] ?? (global[ACTIVE] = {}));
|
|
106
|
+
}
|
|
107
|
+
function activeConnection() {
|
|
108
|
+
const connection = slot().current;
|
|
109
|
+
if (!connection) {
|
|
110
|
+
throw new Error("No Nowity connection. Render <NowityProvider> above the components that " +
|
|
111
|
+
"read queries — the root layout is the usual place.");
|
|
112
|
+
}
|
|
113
|
+
return connection;
|
|
114
|
+
}
|
|
115
|
+
function currentConnection() {
|
|
116
|
+
return slot().current ?? null;
|
|
117
|
+
}
|
|
118
|
+
function setActiveConnection(connection) {
|
|
119
|
+
slot().current = connection;
|
|
120
|
+
}
|
|
121
|
+
class NowityConnection {
|
|
122
|
+
constructor(options) {
|
|
123
|
+
/** {@link QuerySource.rendersOnce} — a browser renders as often as it likes. */
|
|
124
|
+
this.rendersOnce = false;
|
|
125
|
+
this.entries = new Map();
|
|
126
|
+
this.proxies = new Map();
|
|
127
|
+
this.kinds = new Map();
|
|
128
|
+
this.manifestReady = new Promise((resolve) => {
|
|
129
|
+
this.resolveManifest = resolve;
|
|
130
|
+
});
|
|
131
|
+
this.graceMs = options.graceMs ?? 1000;
|
|
132
|
+
this.client = new nowity_client_1.NowityClient({
|
|
133
|
+
...options,
|
|
134
|
+
onWelcome: (api) => this.adoptManifest(api),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
connect() {
|
|
138
|
+
this.client.connect();
|
|
139
|
+
}
|
|
140
|
+
/** {@link QuerySource.hydrate} — the store's own, so both sources seed alike. */
|
|
141
|
+
hydrate(payloads) {
|
|
142
|
+
this.client.hydrate(payloads);
|
|
143
|
+
}
|
|
144
|
+
close() {
|
|
145
|
+
for (const entry of this.entries.values())
|
|
146
|
+
entry.dispose();
|
|
147
|
+
this.entries.clear();
|
|
148
|
+
this.client.close();
|
|
149
|
+
}
|
|
150
|
+
adoptManifest(api) {
|
|
151
|
+
this.manifest = api;
|
|
152
|
+
this.kinds = new Map();
|
|
153
|
+
for (const contract of api?.contracts ?? []) {
|
|
154
|
+
for (const endpoint of contract.endpoints) {
|
|
155
|
+
this.kinds.set(`${contract.name}.${endpoint.method}`, endpoint.kind);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
this.resolveManifest();
|
|
159
|
+
}
|
|
160
|
+
/** The proxy for a service, by its token. */
|
|
161
|
+
service(token) {
|
|
162
|
+
return this.contract((0, contract_1.contractNameOf)(token));
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The proxy bound to one contract.
|
|
166
|
+
*
|
|
167
|
+
* Methods are not enumerated from the class: an abstract method emits no
|
|
168
|
+
* runtime property, so there is nothing to enumerate. Every property access
|
|
169
|
+
* returns a callable instead, and the manifest decides at call time whether
|
|
170
|
+
* it opens a subscription or sends a write.
|
|
171
|
+
*/
|
|
172
|
+
contract(name) {
|
|
173
|
+
const existing = this.proxies.get(name);
|
|
174
|
+
if (existing)
|
|
175
|
+
return existing;
|
|
176
|
+
const connection = this;
|
|
177
|
+
const methods = new Map();
|
|
178
|
+
const proxy = new Proxy({}, {
|
|
179
|
+
get(_target, property) {
|
|
180
|
+
if (typeof property !== "string")
|
|
181
|
+
return undefined;
|
|
182
|
+
let method = methods.get(property);
|
|
183
|
+
if (!method) {
|
|
184
|
+
method = connection.bind(name, property);
|
|
185
|
+
methods.set(property, method);
|
|
186
|
+
}
|
|
187
|
+
return method;
|
|
188
|
+
},
|
|
189
|
+
has: () => true,
|
|
190
|
+
});
|
|
191
|
+
this.proxies.set(name, proxy);
|
|
192
|
+
return proxy;
|
|
193
|
+
}
|
|
194
|
+
bind(contract, method) {
|
|
195
|
+
const name = `${contract}.${method}`;
|
|
196
|
+
const fn = (...args) => this.call(name, args);
|
|
197
|
+
Object.defineProperty(fn, "name", { value: method });
|
|
198
|
+
return fn;
|
|
199
|
+
}
|
|
200
|
+
async call(name, args) {
|
|
201
|
+
const kind = await this.kindOf(name);
|
|
202
|
+
if (kind === "mutation") {
|
|
203
|
+
await this.client.mutate(name, args);
|
|
204
|
+
return undefined;
|
|
205
|
+
}
|
|
206
|
+
if (kind === "list") {
|
|
207
|
+
throw new Error(`"${name}" is a @list endpoint, so it has no single result to hand ` +
|
|
208
|
+
`back — it is read a window at a time. Use useList(...) for it.`);
|
|
209
|
+
}
|
|
210
|
+
const entry = this.ensure(name, args);
|
|
211
|
+
entry.refs += 1;
|
|
212
|
+
this.clearTimer(entry);
|
|
213
|
+
try {
|
|
214
|
+
await entry.settled;
|
|
215
|
+
}
|
|
216
|
+
finally {
|
|
217
|
+
// An awaited result nobody observes must not stay subscribed forever;
|
|
218
|
+
// the grace period gives a caller time to start observing it.
|
|
219
|
+
entry.refs -= 1;
|
|
220
|
+
this.scheduleRelease(entry);
|
|
221
|
+
}
|
|
222
|
+
return entry.value;
|
|
223
|
+
}
|
|
224
|
+
async kindOf(name) {
|
|
225
|
+
if (!this.manifest)
|
|
226
|
+
await this.manifestReady;
|
|
227
|
+
const kind = this.kinds.get(name);
|
|
228
|
+
if (!kind) {
|
|
229
|
+
throw new Error(`The server has no endpoint "${name}". ` +
|
|
230
|
+
`Either the contract is not implemented there, or client and ` +
|
|
231
|
+
`server were built from different versions of it.`);
|
|
232
|
+
}
|
|
233
|
+
return kind;
|
|
234
|
+
}
|
|
235
|
+
// ------------------------------------------------------- lifecycle of a query
|
|
236
|
+
/**
|
|
237
|
+
* Get or create the shared entry for one query.
|
|
238
|
+
*
|
|
239
|
+
* Does *not* take a reference: a render that never commits would otherwise
|
|
240
|
+
* leak one. The grace timer started here collects exactly that case, and
|
|
241
|
+
* {@link retain} cancels it when a component does commit.
|
|
242
|
+
*/
|
|
243
|
+
ensure(name, args) {
|
|
244
|
+
const key = (0, nowity_client_1.subscriptionKey)(name, args);
|
|
245
|
+
const existing = this.entries.get(key);
|
|
246
|
+
if (existing)
|
|
247
|
+
return existing;
|
|
248
|
+
const entry = new LiveEntry(key, this.client.subscribe(name, args));
|
|
249
|
+
this.entries.set(key, entry);
|
|
250
|
+
// Cardinality comes from the server, because only the server knows it:
|
|
251
|
+
// `findUnique` and `findMany` are both "rows" on the wire, and the
|
|
252
|
+
// snapshot is what says which one the method actually returned.
|
|
253
|
+
entry.watchCardinality(() => this.client.isSingle(entry.live.subId));
|
|
254
|
+
this.scheduleRelease(entry);
|
|
255
|
+
return entry;
|
|
256
|
+
}
|
|
257
|
+
retain(entry) {
|
|
258
|
+
entry.refs += 1;
|
|
259
|
+
this.clearTimer(entry);
|
|
260
|
+
}
|
|
261
|
+
release(entry) {
|
|
262
|
+
entry.refs = Math.max(0, entry.refs - 1);
|
|
263
|
+
this.scheduleRelease(entry);
|
|
264
|
+
}
|
|
265
|
+
scheduleRelease(entry) {
|
|
266
|
+
if (entry.refs > 0 || entry.timer)
|
|
267
|
+
return;
|
|
268
|
+
entry.timer = setTimeout(() => {
|
|
269
|
+
entry.timer = null;
|
|
270
|
+
if (entry.refs > 0)
|
|
271
|
+
return;
|
|
272
|
+
this.entries.delete(entry.key);
|
|
273
|
+
entry.dispose();
|
|
274
|
+
}, this.graceMs);
|
|
275
|
+
// A pending release must never hold the process open.
|
|
276
|
+
entry.timer.unref?.();
|
|
277
|
+
}
|
|
278
|
+
clearTimer(entry) {
|
|
279
|
+
if (!entry.timer)
|
|
280
|
+
return;
|
|
281
|
+
clearTimeout(entry.timer);
|
|
282
|
+
entry.timer = null;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
exports.NowityConnection = NowityConnection;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { QueryError, QuerySource } from "./query-source";
|
|
2
|
+
/** How many rows one window holds. */
|
|
3
|
+
export declare const DEFAULT_PAGE_SIZE = 50;
|
|
4
|
+
export declare class LiveList<T> {
|
|
5
|
+
private readonly source;
|
|
6
|
+
readonly endpoint: string;
|
|
7
|
+
readonly args: unknown[];
|
|
8
|
+
readonly pageSize: number;
|
|
9
|
+
/** Identity of this collection: the endpoint, its arguments, its page size. */
|
|
10
|
+
readonly key: string;
|
|
11
|
+
private readonly pageName;
|
|
12
|
+
private readonly countName;
|
|
13
|
+
/** Pages currently held open, by page number. */
|
|
14
|
+
private readonly held;
|
|
15
|
+
private holders;
|
|
16
|
+
constructor(source: QuerySource, endpoint: string, args: unknown[], pageSize: number);
|
|
17
|
+
/**
|
|
18
|
+
* How many rows the collection has. Observable, and it moves as rows are added.
|
|
19
|
+
*
|
|
20
|
+
* A row created here and not yet confirmed counts: the server's total cannot
|
|
21
|
+
* know about it, and without it the row would have nowhere to be — the last
|
|
22
|
+
* index of the collection would still be the last one.
|
|
23
|
+
*/
|
|
24
|
+
get total(): number;
|
|
25
|
+
/** How many rows the server says there are, before anything local. */
|
|
26
|
+
private get serverTotal();
|
|
27
|
+
/**
|
|
28
|
+
* How many rows the held windows differ from their own size by.
|
|
29
|
+
*
|
|
30
|
+
* Positive for a row created here, negative for one deleted here — the count
|
|
31
|
+
* came from the server and cannot know about either. Without it the
|
|
32
|
+
* collection would be the wrong length for as long as the write is in flight,
|
|
33
|
+
* and its last row would be unreachable or a blank.
|
|
34
|
+
*/
|
|
35
|
+
private localDrift;
|
|
36
|
+
/** How long a window is right now, or null while it cannot be read. */
|
|
37
|
+
private lengthOf;
|
|
38
|
+
/**
|
|
39
|
+
* How long a window would be with nothing local in it.
|
|
40
|
+
*
|
|
41
|
+
* Every window is full except the collection's last, which holds whatever is
|
|
42
|
+
* left — so a short window is only news when it is not that one.
|
|
43
|
+
*/
|
|
44
|
+
private expected;
|
|
45
|
+
/**
|
|
46
|
+
* The index, walked across the windows this list is holding.
|
|
47
|
+
*
|
|
48
|
+
* Needed when a window holds a different number of rows than its size —
|
|
49
|
+
* one more for a row created here, one fewer for one deleted here. Every
|
|
50
|
+
* index after it is then somewhere else than the arithmetic says, and
|
|
51
|
+
* walking the windows' *actual* lengths is what moves the rows instead of
|
|
52
|
+
* skipping one or leaving a blank where the deleted one was.
|
|
53
|
+
*
|
|
54
|
+
* Returns {@link SERVER_ORDER} when there is nothing local in play, which is
|
|
55
|
+
* every render but the few dozen milliseconds after a click.
|
|
56
|
+
*/
|
|
57
|
+
private local;
|
|
58
|
+
/** No answer yet about how big the collection is — what a list suspends on. */
|
|
59
|
+
get loading(): boolean;
|
|
60
|
+
/** Why the collection cannot be read: refused, or broken. */
|
|
61
|
+
get problem(): QueryError | null;
|
|
62
|
+
get settled(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* The row at an index, or `undefined` while its window is still loading.
|
|
65
|
+
*
|
|
66
|
+
* Asking is subscribing: the window covering the index is opened on the
|
|
67
|
+
* first ask, and every ask after that is a lookup. `undefined` is therefore
|
|
68
|
+
* an ordinary state and not an error — it is the cell a list renders as a
|
|
69
|
+
* skeleton, a moment before the row lands in it.
|
|
70
|
+
*
|
|
71
|
+
* Except while a page renders on a server, where a skeleton is not a moment
|
|
72
|
+
* before anything: that render is the HTML, so the window is waited for. It
|
|
73
|
+
* is also what the browser is about to hydrate against — a placeholder in the
|
|
74
|
+
* markup and a row in the store is a mismatch, and the row is the one both
|
|
75
|
+
* of them should have had.
|
|
76
|
+
*/
|
|
77
|
+
at(index: number): T | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Hold open exactly the windows covering `[from, to)`, and let the rest go.
|
|
80
|
+
*
|
|
81
|
+
* Called from an effect with what is on screen. Everything outside it is
|
|
82
|
+
* released — not dropped: the connection keeps a released subscription for a
|
|
83
|
+
* moment, which is what makes scrolling back up free.
|
|
84
|
+
*/
|
|
85
|
+
view(from: number, to: number): void;
|
|
86
|
+
/** Held for as long as a mounted component reads the collection. */
|
|
87
|
+
retain(): void;
|
|
88
|
+
release(): void;
|
|
89
|
+
private get count();
|
|
90
|
+
/**
|
|
91
|
+
* One window's subscription, asked of the source every time rather than
|
|
92
|
+
* remembered.
|
|
93
|
+
*
|
|
94
|
+
* The source is where a subscription's lifetime is decided — a window
|
|
95
|
+
* released a moment ago may already have been collected — so holding a
|
|
96
|
+
* reference here would mean reading rows from a subscription that no longer
|
|
97
|
+
* exists. Asking again is a lookup in a map, and it is always the live one.
|
|
98
|
+
*/
|
|
99
|
+
private page;
|
|
100
|
+
}
|
|
101
|
+
export declare function listFor<T>(source: QuerySource, endpoint: string, args: unknown[], pageSize?: number): LiveList<T>;
|
|
102
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/client/list.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAc,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE1E,sCAAsC;AACtC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AASpC,qBAAa,QAAQ,CAAC,CAAC;IAWf,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAb7B,+EAA+E;IAC/E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,iDAAiD;IACjD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiC;IACtD,OAAO,CAAC,OAAO,CAAK;gBAGC,MAAM,EAAE,WAAW,EAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EAAE,EACf,QAAQ,EAAE,MAAM;IAO7B;;;;;;OAMG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,sEAAsE;IACtE,OAAO,KAAK,WAAW,GAItB;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;IASlB,uEAAuE;IACvE,OAAO,CAAC,QAAQ;IAMhB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;IAMhB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,KAAK;IAmBb,+EAA+E;IAC/E,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,6DAA6D;IAC7D,IAAI,OAAO,IAAI,UAAU,GAAG,IAAI,CAE/B;IAED,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED;;;;;;;;;;;;;OAaG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAiBhC;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;IAqBpC,oEAAoE;IACpE,MAAM,IAAI,IAAI;IAKd,OAAO,IAAI,IAAI;IAQf,OAAO,KAAK,KAAK,GAEhB;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,IAAI;CAOf;AAWD,wBAAgB,OAAO,CAAC,CAAC,EACrB,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EAAE,EACf,QAAQ,GAAE,MAA0B,GACrC,QAAQ,CAAC,CAAC,CAAC,CAWb"}
|