@rpcbase/client 0.377.0 → 0.379.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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -12
- package/dist/index.js.map +1 -1
- package/dist/initWithRoutes.d.ts.map +1 -1
- package/dist/rts/index.d.ts +1 -0
- package/dist/rts/index.d.ts.map +1 -1
- package/dist/rts/index.js +8 -2
- package/dist/rts/queryKey.d.ts +5 -0
- package/dist/rts/queryKey.d.ts.map +1 -0
- package/dist/rts/ssrHydration.d.ts +41 -0
- package/dist/rts/ssrHydration.d.ts.map +1 -0
- package/dist/rts/useQuery.d.ts +2 -0
- package/dist/rts/useQuery.d.ts.map +1 -1
- package/dist/rts/wsClient.d.ts +16 -1
- package/dist/rts/wsClient.d.ts.map +1 -1
- package/dist/{useQuery-DnrhB9w2.js → useQuery-Bz5cpWp4.js} +217 -36
- package/dist/useQuery-Bz5cpWp4.js.map +1 -0
- package/package.json +1 -1
- package/dist/useQuery-DnrhB9w2.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initWithRoutes.d.ts","sourceRoot":"","sources":["../src/initWithRoutes.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAmC,MAAM,OAAO,CAAA;AAClE,OAAO,EAAsB,wBAAwB,EAAiB,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"initWithRoutes.d.ts","sourceRoot":"","sources":["../src/initWithRoutes.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAmC,MAAM,OAAO,CAAA;AAClE,OAAO,EAAsB,wBAAwB,EAAiB,MAAM,iBAAiB,CAAA;AAQ7F,OAAO,EAGL,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;AAiFxB,KAAK,qBAAqB,GAAG;IAC3B,0BAA0B,CAAC,EAAE,OAAO,CAAA;IACpC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,SAAS,CAAA;CAC9D,CAAA;AAED,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAA;AA0CnE,eAAO,MAAM,cAAc,GACzB,eAAe,aAAa,EAC5B,OAAO,qBAAqB,kBAqF7B,CAAA"}
|
package/dist/rts/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { configureRtsPouchStore, destroyAllCollections, destroyCollection, deleteDocs, getCollection, resetRtsPouchStore, runQuery, updateDocs, type RtsPouchQueryContext, type RtsPouchQueryOptions, type RtsPouchStoreConfig, } from './pouchStore';
|
|
2
2
|
export { addLocalTxn, connect, disconnect, onMessage, reconnect, registerQuery, sendMessage, syncRtsChanges, type RtsConnectOptions, type RtsQueryContext, type RtsQueryOptions, } from './wsClient';
|
|
3
|
+
export { hydrateRtsFromWindow, clearHydratedRtsQueryData, peekHydratedRtsQueryData, resolveRtsHydrationIdentityFromStaticRouterData, RtsSsrRuntimeProvider, STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY, type RtsSsrHydrationQueryData, type RtsSsrIdentity, type RtsSsrQueryRegistration, type RtsSsrRuntime, type StaticRpcbaseRtsHydrationData, } from './ssrHydration';
|
|
3
4
|
export { type RtsModelMap, type RtsModelName, } from './modelTypes';
|
|
4
5
|
export { useQuery, type UseRtsQueryOptions, type UseRtsQueryResult, } from './useQuery';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/rts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,WAAW,EACX,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,QAAQ,EACR,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,WAAW,EACX,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,+CAA+C,EAC/C,qBAAqB,EACrB,qCAAqC,EACrC,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,6BAA6B,GACnC,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,QAAQ,EACR,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,GACvB,MAAM,YAAY,CAAA"}
|
package/dist/rts/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { f, c, h, b, d, a, i, g, o, j, k, r, e, s, l, u,
|
|
1
|
+
import { R, S, f, n, c, h, b, d, a, i, g, m, o, p, j, k, r, q, e, s, l, u, t } from "../useQuery-Bz5cpWp4.js";
|
|
2
2
|
export {
|
|
3
|
+
R as RtsSsrRuntimeProvider,
|
|
4
|
+
S as STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY,
|
|
3
5
|
f as addLocalTxn,
|
|
6
|
+
n as clearHydratedRtsQueryData,
|
|
4
7
|
c as configureRtsPouchStore,
|
|
5
8
|
h as connect,
|
|
6
9
|
b as deleteDocs,
|
|
@@ -8,14 +11,17 @@ export {
|
|
|
8
11
|
a as destroyCollection,
|
|
9
12
|
i as disconnect,
|
|
10
13
|
g as getCollection,
|
|
14
|
+
m as hydrateRtsFromWindow,
|
|
11
15
|
o as onMessage,
|
|
16
|
+
p as peekHydratedRtsQueryData,
|
|
12
17
|
j as reconnect,
|
|
13
18
|
k as registerQuery,
|
|
14
19
|
r as resetRtsPouchStore,
|
|
20
|
+
q as resolveRtsHydrationIdentityFromStaticRouterData,
|
|
15
21
|
e as runQuery,
|
|
16
22
|
s as sendMessage,
|
|
17
23
|
l as syncRtsChanges,
|
|
18
24
|
u as updateDocs,
|
|
19
|
-
|
|
25
|
+
t as useQuery
|
|
20
26
|
};
|
|
21
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryKey.d.ts","sourceRoot":"","sources":["../../src/rts/queryKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAGjD,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEzC,eAAO,MAAM,kBAAkB,GAAI,OAAO,UAAU,EAAE,SAAS,eAAe,KAAG,MAOhF,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { RtsModelName } from './modelTypes';
|
|
3
|
+
import { RtsQueryOptions } from './wsClient';
|
|
4
|
+
type JsonObject = Record<string, unknown>;
|
|
5
|
+
export declare const STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY = "__staticRpcbaseRtsHydrationData";
|
|
6
|
+
export type RtsSsrHydrationQueryData = {
|
|
7
|
+
modelName: RtsModelName;
|
|
8
|
+
queryKey: string;
|
|
9
|
+
data: unknown[];
|
|
10
|
+
};
|
|
11
|
+
export type StaticRpcbaseRtsHydrationData = {
|
|
12
|
+
v: 1;
|
|
13
|
+
tenantId: string | null;
|
|
14
|
+
uid: string | null;
|
|
15
|
+
queries: RtsSsrHydrationQueryData[];
|
|
16
|
+
};
|
|
17
|
+
export type RtsSsrIdentity = {
|
|
18
|
+
tenantId: string | null;
|
|
19
|
+
uid: string | null;
|
|
20
|
+
};
|
|
21
|
+
export type RtsSsrQueryRegistration = {
|
|
22
|
+
modelName: RtsModelName;
|
|
23
|
+
query: JsonObject;
|
|
24
|
+
options: RtsQueryOptions;
|
|
25
|
+
queryKey: string;
|
|
26
|
+
};
|
|
27
|
+
export type RtsSsrRuntime = {
|
|
28
|
+
registerQuery: (query: RtsSsrQueryRegistration) => void;
|
|
29
|
+
getQueryData: (modelName: RtsModelName, queryKey: string) => unknown[] | undefined;
|
|
30
|
+
};
|
|
31
|
+
export declare const hydrateRtsFromWindow: (identity: RtsSsrIdentity) => void;
|
|
32
|
+
export declare const peekHydratedRtsQueryData: (modelName: RtsModelName, queryKey: string) => unknown[] | undefined;
|
|
33
|
+
export declare const clearHydratedRtsQueryData: () => void;
|
|
34
|
+
export declare const resolveRtsHydrationIdentityFromStaticRouterData: () => RtsSsrIdentity;
|
|
35
|
+
export declare const RtsSsrRuntimeProvider: ({ value, children, }: {
|
|
36
|
+
value: RtsSsrRuntime;
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare const useRtsSsrRuntime: () => RtsSsrRuntime | null;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=ssrHydration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssrHydration.d.ts","sourceRoot":"","sources":["../../src/rts/ssrHydration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAGjD,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEzC,eAAO,MAAM,qCAAqC,oCAAoC,CAAA;AAEtF,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,EAAE,YAAY,CAAA;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,OAAO,EAAE,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG;IAC1C,CAAC,EAAE,CAAC,CAAA;IACJ,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAClB,OAAO,EAAE,wBAAwB,EAAE,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,YAAY,CAAA;IACvB,KAAK,EAAE,UAAU,CAAA;IACjB,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAA;IACvD,YAAY,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,EAAE,GAAG,SAAS,CAAA;CACnF,CAAA;AAyDD,eAAO,MAAM,oBAAoB,GAAI,UAAU,cAAc,KAAG,IAkB/D,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,WAAW,YAAY,EACvB,UAAU,MAAM,KACf,OAAO,EAAE,GAAG,SAEd,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAO,IAE5C,CAAA;AA4BD,eAAO,MAAM,+CAA+C,QAAO,cAiBlE,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,sBAGnC;IACD,KAAK,EAAE,aAAa,CAAA;IACpB,QAAQ,EAAE,SAAS,CAAA;CACpB,4CAMA,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAO,aAAa,GAAG,IAEnD,CAAA"}
|
package/dist/rts/useQuery.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../src/rts/useQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../src/rts/useQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAGhD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIlE,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG,eAAe,GAAG;IACjD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACtB,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE,CAAC,EAAE,GAAG,SAAS,CAAA;IACrB,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAA;IAC7C,KAAK,EAAE,OAAO,GAAG,SAAS,CAAA;IAC1B,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClF,WAAW,YAAY,EACvB,QAAO,UAAe,EACtB,UAAS,kBAAuB,KAC/B,iBAAiB,CAAC,CAAC,CAiKrB,CAAA"}
|
package/dist/rts/wsClient.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { RtsModelName } from './modelTypes';
|
|
2
2
|
type JsonObject = Record<string, unknown>;
|
|
3
|
+
export type RtsPopulateObject = {
|
|
4
|
+
path: string;
|
|
5
|
+
model?: string;
|
|
6
|
+
select?: string | JsonObject;
|
|
7
|
+
match?: JsonObject;
|
|
8
|
+
options?: {
|
|
9
|
+
sort?: Record<string, 1 | -1>;
|
|
10
|
+
limit?: number;
|
|
11
|
+
};
|
|
12
|
+
populate?: RtsPopulateOption;
|
|
13
|
+
};
|
|
14
|
+
export type RtsPopulateOption = string | RtsPopulateObject | Array<string | RtsPopulateObject>;
|
|
3
15
|
export type RtsNetworkQueryContext = {
|
|
4
16
|
source: "network";
|
|
5
17
|
isLocal: boolean;
|
|
@@ -14,6 +26,7 @@ export type RtsQueryOptions = {
|
|
|
14
26
|
projection?: Record<string, 0 | 1>;
|
|
15
27
|
sort?: Record<string, 1 | -1>;
|
|
16
28
|
limit?: number;
|
|
29
|
+
populate?: RtsPopulateOption;
|
|
17
30
|
};
|
|
18
31
|
export type RtsConnectOptions = {
|
|
19
32
|
url?: string;
|
|
@@ -33,7 +46,9 @@ export declare const syncRtsChanges: (tenantId: string, uid: string, options?: P
|
|
|
33
46
|
export declare const connect: (tenantId: string, uid: string, options?: RtsConnectOptions) => Promise<void>;
|
|
34
47
|
export declare const disconnect: () => void;
|
|
35
48
|
export declare const reconnect: (tenantId: string, uid: string, options?: RtsConnectOptions) => Promise<void>;
|
|
36
|
-
export declare const registerQuery: (modelName: RtsModelName, query: JsonObject, optionsOrCallback?: RtsQueryOptions | QueryCallback, callbackMaybe?: QueryCallback
|
|
49
|
+
export declare const registerQuery: (modelName: RtsModelName, query: JsonObject, optionsOrCallback?: RtsQueryOptions | QueryCallback, callbackMaybe?: QueryCallback, behavior?: {
|
|
50
|
+
runInitialNetworkQuery?: boolean;
|
|
51
|
+
}) => (() => void) | undefined;
|
|
37
52
|
export declare const sendMessage: (event: string, payload?: unknown) => void;
|
|
38
53
|
export declare const onMessage: (event: string, callback: (payload: unknown) => void) => (() => void);
|
|
39
54
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wsClient.d.ts","sourceRoot":"","sources":["../../src/rts/wsClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"wsClient.d.ts","sourceRoot":"","sources":["../../src/rts/wsClient.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,102 @@
|
|
|
1
|
-
import { useId, useState, useRef, useEffect, useMemo } from "react";
|
|
1
|
+
import { createContext, useContext, useId, useState, useRef, useEffect, useMemo } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
const STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY = "__staticRpcbaseRtsHydrationData";
|
|
4
|
+
const RtsSsrRuntimeContext = createContext(null);
|
|
5
|
+
const hydrationDataStore = /* @__PURE__ */ new Map();
|
|
6
|
+
const makeStoreKey = (modelName, queryKey) => `${modelName}.${queryKey}`;
|
|
7
|
+
const normalizeStringOrNull = (value) => {
|
|
8
|
+
if (typeof value !== "string") return null;
|
|
9
|
+
const normalized = value.trim();
|
|
10
|
+
return normalized ? normalized : null;
|
|
11
|
+
};
|
|
12
|
+
const parseHydrationData = (value) => {
|
|
13
|
+
if (!value || typeof value !== "object") return null;
|
|
14
|
+
const raw = value;
|
|
15
|
+
if (raw.v !== 1) return null;
|
|
16
|
+
if (!Array.isArray(raw.queries)) return null;
|
|
17
|
+
const queries = [];
|
|
18
|
+
for (const entry of raw.queries) {
|
|
19
|
+
if (!entry || typeof entry !== "object") continue;
|
|
20
|
+
const query = entry;
|
|
21
|
+
const modelName = normalizeStringOrNull(query.modelName);
|
|
22
|
+
const queryKey = normalizeStringOrNull(query.queryKey);
|
|
23
|
+
if (!modelName || !queryKey) continue;
|
|
24
|
+
if (!Array.isArray(query.data)) continue;
|
|
25
|
+
queries.push({
|
|
26
|
+
modelName,
|
|
27
|
+
queryKey,
|
|
28
|
+
data: query.data
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
v: 1,
|
|
33
|
+
tenantId: normalizeStringOrNull(raw.tenantId),
|
|
34
|
+
uid: normalizeStringOrNull(raw.uid),
|
|
35
|
+
queries
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const hydrateRtsFromWindow = (identity) => {
|
|
39
|
+
if (typeof window === "undefined") return;
|
|
40
|
+
const browserWindow = window;
|
|
41
|
+
const raw = browserWindow[STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY];
|
|
42
|
+
delete browserWindow[STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY];
|
|
43
|
+
const parsed = parseHydrationData(raw);
|
|
44
|
+
if (!parsed) return;
|
|
45
|
+
if (parsed.tenantId !== identity.tenantId || parsed.uid !== identity.uid) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
hydrationDataStore.clear();
|
|
49
|
+
for (const query of parsed.queries) {
|
|
50
|
+
hydrationDataStore.set(makeStoreKey(query.modelName, query.queryKey), query.data);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const peekHydratedRtsQueryData = (modelName, queryKey) => {
|
|
54
|
+
return hydrationDataStore.get(makeStoreKey(modelName, queryKey));
|
|
55
|
+
};
|
|
56
|
+
const clearHydratedRtsQueryData = () => {
|
|
57
|
+
hydrationDataStore.clear();
|
|
58
|
+
};
|
|
59
|
+
const readRootLikeLoaderData = () => {
|
|
60
|
+
if (typeof window === "undefined") return null;
|
|
61
|
+
const hydration = window.__staticRouterHydrationData;
|
|
62
|
+
if (!hydration || typeof hydration !== "object") return null;
|
|
63
|
+
const loaderData = hydration.loaderData;
|
|
64
|
+
if (!loaderData || typeof loaderData !== "object") return null;
|
|
65
|
+
const entries = Object.entries(loaderData);
|
|
66
|
+
let fallback = null;
|
|
67
|
+
for (const [routeId, data] of entries) {
|
|
68
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) continue;
|
|
69
|
+
const obj = data;
|
|
70
|
+
const hasTenantId = Object.prototype.hasOwnProperty.call(obj, "tenantId");
|
|
71
|
+
const hasUser = Object.prototype.hasOwnProperty.call(obj, "user");
|
|
72
|
+
if (!hasTenantId && !hasUser) continue;
|
|
73
|
+
if (routeId === "root") return obj;
|
|
74
|
+
if (!fallback) fallback = obj;
|
|
75
|
+
}
|
|
76
|
+
return fallback;
|
|
77
|
+
};
|
|
78
|
+
const resolveRtsHydrationIdentityFromStaticRouterData = () => {
|
|
79
|
+
const rootData = readRootLikeLoaderData();
|
|
80
|
+
if (!rootData) {
|
|
81
|
+
return { tenantId: null, uid: null };
|
|
82
|
+
}
|
|
83
|
+
const tenantId = normalizeStringOrNull(rootData.tenantId);
|
|
84
|
+
const user = rootData.user;
|
|
85
|
+
const userId = user && typeof user === "object" ? normalizeStringOrNull(user.id) : null;
|
|
86
|
+
return {
|
|
87
|
+
tenantId,
|
|
88
|
+
uid: userId
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
const RtsSsrRuntimeProvider = ({
|
|
92
|
+
value,
|
|
93
|
+
children
|
|
94
|
+
}) => {
|
|
95
|
+
return /* @__PURE__ */ jsx(RtsSsrRuntimeContext.Provider, { value, children });
|
|
96
|
+
};
|
|
97
|
+
const useRtsSsrRuntime = () => {
|
|
98
|
+
return useContext(RtsSsrRuntimeContext);
|
|
99
|
+
};
|
|
2
100
|
const UNDERSCORE_PREFIX = "$_";
|
|
3
101
|
const DEFAULT_FIND_LIMIT = 4096;
|
|
4
102
|
let storeConfig = null;
|
|
@@ -322,9 +420,19 @@ const destroyAllCollections = async () => {
|
|
|
322
420
|
await Promise.all(dbs.map((db) => db.destroy()));
|
|
323
421
|
collections.clear();
|
|
324
422
|
};
|
|
423
|
+
const computeRtsQueryKey = (query, options) => {
|
|
424
|
+
const key = options.key ?? "";
|
|
425
|
+
const projection = options.projection ? JSON.stringify(options.projection) : "";
|
|
426
|
+
const sort = options.sort ? JSON.stringify(options.sort) : "";
|
|
427
|
+
const limit = typeof options.limit === "number" ? String(options.limit) : "";
|
|
428
|
+
const populate = options.populate ? JSON.stringify(options.populate) : "";
|
|
429
|
+
return `${key}${JSON.stringify(query)}${projection}${sort}${limit}${populate}`;
|
|
430
|
+
};
|
|
325
431
|
const TENANT_ID_QUERY_PARAM = "rb-tenant-id";
|
|
326
432
|
const RTS_CHANGES_ROUTE = "/api/rb/rts/changes";
|
|
327
433
|
const MAX_TXN_BUF = 2048;
|
|
434
|
+
const SERVER_RECONNECT_DELAY_MIN_MS = 1e4;
|
|
435
|
+
const SERVER_RECONNECT_DELAY_MAX_MS = 15e3;
|
|
328
436
|
let socket = null;
|
|
329
437
|
let connectPromise = null;
|
|
330
438
|
let explicitDisconnect = false;
|
|
@@ -337,6 +445,8 @@ const subscriptions = /* @__PURE__ */ new Map();
|
|
|
337
445
|
const messageCallbacks = /* @__PURE__ */ new Map();
|
|
338
446
|
let reconnectTimer = null;
|
|
339
447
|
let reconnectAttempts = 0;
|
|
448
|
+
let hasEstablishedConnection = false;
|
|
449
|
+
let pendingServerReconnectJitter = false;
|
|
340
450
|
let syncPromise = null;
|
|
341
451
|
let syncKey = null;
|
|
342
452
|
const ensureBrowser = () => {
|
|
@@ -358,33 +468,21 @@ const buildSocketUrl = (tenantId, _uid, options) => {
|
|
|
358
468
|
base.searchParams.set(TENANT_ID_QUERY_PARAM, tenantId);
|
|
359
469
|
return base.toString();
|
|
360
470
|
};
|
|
361
|
-
const computeQueryKey = (query, options) => {
|
|
362
|
-
const key = options.key ?? "";
|
|
363
|
-
const projection = options.projection ? JSON.stringify(options.projection) : "";
|
|
364
|
-
const sort = options.sort ? JSON.stringify(options.sort) : "";
|
|
365
|
-
const limit = typeof options.limit === "number" ? String(options.limit) : "";
|
|
366
|
-
return `${key}${JSON.stringify(query)}${projection}${sort}${limit}`;
|
|
367
|
-
};
|
|
368
471
|
const sendToServer = (message) => {
|
|
369
472
|
if (!socket) return;
|
|
370
473
|
if (socket.readyState !== WebSocket.OPEN) return;
|
|
371
474
|
socket.send(JSON.stringify(message));
|
|
372
475
|
};
|
|
373
|
-
const resubscribeAll = () => {
|
|
476
|
+
const resubscribeAll = ({ forceInitialQuery }) => {
|
|
374
477
|
for (const sub of subscriptions.values()) {
|
|
478
|
+
const runInitialQuery = forceInitialQuery || sub.runInitialNetworkQuery;
|
|
375
479
|
sendToServer({
|
|
376
480
|
type: "register-query",
|
|
377
481
|
modelName: sub.modelName,
|
|
378
482
|
queryKey: sub.queryKey,
|
|
379
483
|
query: sub.query,
|
|
380
|
-
options: sub.options
|
|
381
|
-
|
|
382
|
-
sendToServer({
|
|
383
|
-
type: "run-query",
|
|
384
|
-
modelName: sub.modelName,
|
|
385
|
-
queryKey: sub.queryKey,
|
|
386
|
-
query: sub.query,
|
|
387
|
-
options: sub.options
|
|
484
|
+
options: sub.options,
|
|
485
|
+
runInitialQuery
|
|
388
486
|
});
|
|
389
487
|
}
|
|
390
488
|
};
|
|
@@ -397,14 +495,22 @@ const clearReconnectTimer = () => {
|
|
|
397
495
|
};
|
|
398
496
|
const scheduleReconnect = () => {
|
|
399
497
|
clearReconnectTimer();
|
|
400
|
-
if (explicitDisconnect)
|
|
498
|
+
if (explicitDisconnect) {
|
|
499
|
+
pendingServerReconnectJitter = false;
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
401
502
|
if (!currentTenantId || !currentUid) return;
|
|
402
503
|
const cfg = connectOptions.reconnect ?? {};
|
|
403
504
|
const maxAttempts = cfg.attempts ?? 128;
|
|
404
505
|
const delayMs = cfg.delayMs ?? 400;
|
|
405
506
|
const delayMaxMs = cfg.delayMaxMs ?? 1e4;
|
|
406
507
|
if (reconnectAttempts >= maxAttempts) return;
|
|
407
|
-
|
|
508
|
+
let delay = Math.min(delayMaxMs, delayMs * Math.pow(2, reconnectAttempts));
|
|
509
|
+
if (pendingServerReconnectJitter) {
|
|
510
|
+
const span = SERVER_RECONNECT_DELAY_MAX_MS - SERVER_RECONNECT_DELAY_MIN_MS;
|
|
511
|
+
delay = SERVER_RECONNECT_DELAY_MIN_MS + Math.floor(Math.random() * (span + 1));
|
|
512
|
+
pendingServerReconnectJitter = false;
|
|
513
|
+
}
|
|
408
514
|
reconnectAttempts += 1;
|
|
409
515
|
reconnectTimer = window.setTimeout(() => {
|
|
410
516
|
void connectInternal(currentTenantId, currentUid, connectOptions, { resetReconnectAttempts: false });
|
|
@@ -415,6 +521,8 @@ const handleQueryPayload = (payload) => {
|
|
|
415
521
|
const cbKey = `${modelName}.${queryKey}`;
|
|
416
522
|
const callbacks = queryCallbacks.get(cbKey);
|
|
417
523
|
if (!callbacks || !callbacks.size) return;
|
|
524
|
+
const subscription = subscriptions.get(cbKey);
|
|
525
|
+
const hasPopulate = Boolean(subscription?.options?.populate);
|
|
418
526
|
const isLocal = !!(txnId && localTxnBuf.includes(txnId));
|
|
419
527
|
const context = { source: "network", isLocal, txnId };
|
|
420
528
|
if (error) {
|
|
@@ -428,6 +536,7 @@ const handleQueryPayload = (payload) => {
|
|
|
428
536
|
return typeof doc._id === "string";
|
|
429
537
|
}) : [];
|
|
430
538
|
if (!docs.length) return;
|
|
539
|
+
if (hasPopulate) return;
|
|
431
540
|
void updateDocs(modelName, docs, currentUid).catch(() => {
|
|
432
541
|
});
|
|
433
542
|
};
|
|
@@ -594,7 +703,10 @@ const connectInternal = (tenantId, uid, options, { resetReconnectAttempts }) =>
|
|
|
594
703
|
opened = true;
|
|
595
704
|
settled = true;
|
|
596
705
|
reconnectAttempts = 0;
|
|
597
|
-
|
|
706
|
+
pendingServerReconnectJitter = false;
|
|
707
|
+
const forceInitialQuery = hasEstablishedConnection;
|
|
708
|
+
resubscribeAll({ forceInitialQuery });
|
|
709
|
+
hasEstablishedConnection = true;
|
|
598
710
|
resolve();
|
|
599
711
|
});
|
|
600
712
|
socket.addEventListener("message", handleMessage);
|
|
@@ -603,6 +715,9 @@ const connectInternal = (tenantId, uid, options, { resetReconnectAttempts }) =>
|
|
|
603
715
|
settled = true;
|
|
604
716
|
reject(new Error(`RTS WebSocket closed before opening (code=${event.code})`));
|
|
605
717
|
}
|
|
718
|
+
if (!explicitDisconnect) {
|
|
719
|
+
pendingServerReconnectJitter = opened;
|
|
720
|
+
}
|
|
606
721
|
socket = null;
|
|
607
722
|
connectPromise = null;
|
|
608
723
|
scheduleReconnect();
|
|
@@ -621,6 +736,8 @@ const connect = (tenantId, uid, options = {}) => {
|
|
|
621
736
|
const disconnect = () => {
|
|
622
737
|
explicitDisconnect = true;
|
|
623
738
|
clearReconnectTimer();
|
|
739
|
+
hasEstablishedConnection = false;
|
|
740
|
+
pendingServerReconnectJitter = false;
|
|
624
741
|
if (socket) {
|
|
625
742
|
try {
|
|
626
743
|
socket.close();
|
|
@@ -631,10 +748,20 @@ const disconnect = () => {
|
|
|
631
748
|
connectPromise = null;
|
|
632
749
|
};
|
|
633
750
|
const reconnect = (tenantId, uid, options = {}) => {
|
|
634
|
-
|
|
751
|
+
explicitDisconnect = true;
|
|
752
|
+
clearReconnectTimer();
|
|
753
|
+
pendingServerReconnectJitter = false;
|
|
754
|
+
if (socket) {
|
|
755
|
+
try {
|
|
756
|
+
socket.close();
|
|
757
|
+
} catch {
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
socket = null;
|
|
761
|
+
connectPromise = null;
|
|
635
762
|
return connect(tenantId, uid, options);
|
|
636
763
|
};
|
|
637
|
-
const registerQuery = (modelName, query, optionsOrCallback, callbackMaybe) => {
|
|
764
|
+
const registerQuery = (modelName, query, optionsOrCallback, callbackMaybe, behavior) => {
|
|
638
765
|
let options;
|
|
639
766
|
let callback;
|
|
640
767
|
if (typeof optionsOrCallback === "function") {
|
|
@@ -648,12 +775,13 @@ const registerQuery = (modelName, query, optionsOrCallback, callbackMaybe) => {
|
|
|
648
775
|
if (typeof modelName !== "string" || modelName.trim().length === 0) {
|
|
649
776
|
throw new Error("registerQuery: modelName must be a non-empty string");
|
|
650
777
|
}
|
|
651
|
-
const queryKey =
|
|
778
|
+
const queryKey = computeRtsQueryKey(query, options);
|
|
652
779
|
const cbKey = `${modelName}.${queryKey}`;
|
|
780
|
+
const runInitialNetworkQuery = behavior?.runInitialNetworkQuery !== false;
|
|
653
781
|
const set = queryCallbacks.get(cbKey) ?? /* @__PURE__ */ new Set();
|
|
654
782
|
set.add(callback);
|
|
655
783
|
queryCallbacks.set(cbKey, set);
|
|
656
|
-
subscriptions.set(cbKey, { modelName, query, options, queryKey });
|
|
784
|
+
subscriptions.set(cbKey, { modelName, query, options, queryKey, runInitialNetworkQuery });
|
|
657
785
|
if (currentUid) {
|
|
658
786
|
void runQuery({
|
|
659
787
|
modelName,
|
|
@@ -669,8 +797,7 @@ const registerQuery = (modelName, query, optionsOrCallback, callbackMaybe) => {
|
|
|
669
797
|
}).catch(() => {
|
|
670
798
|
});
|
|
671
799
|
}
|
|
672
|
-
sendToServer({ type: "
|
|
673
|
-
sendToServer({ type: "register-query", modelName, queryKey, query, options });
|
|
800
|
+
sendToServer({ type: "register-query", modelName, queryKey, query, options, runInitialQuery: runInitialNetworkQuery });
|
|
674
801
|
return () => {
|
|
675
802
|
sendToServer({ type: "remove-query", modelName, queryKey });
|
|
676
803
|
const callbacks = queryCallbacks.get(cbKey);
|
|
@@ -700,21 +827,58 @@ const useQuery = (modelName, query = {}, options = {}) => {
|
|
|
700
827
|
}
|
|
701
828
|
const id = useId();
|
|
702
829
|
const enabled = options.enabled ?? true;
|
|
830
|
+
const ssrEnabled = options.ssr !== false;
|
|
831
|
+
const refreshOnMount = options.refreshOnMount === true;
|
|
703
832
|
const key = options.key ?? id;
|
|
833
|
+
const queryJson = JSON.stringify(query);
|
|
704
834
|
const projectionJson = options.projection ? JSON.stringify(options.projection) : "";
|
|
705
835
|
const sortJson = options.sort ? JSON.stringify(options.sort) : "";
|
|
706
836
|
const limitStr = typeof options.limit === "number" ? String(options.limit) : "";
|
|
707
|
-
const
|
|
708
|
-
const
|
|
837
|
+
const populateJson = options.populate ? JSON.stringify(options.populate) : "";
|
|
838
|
+
const queryKey = computeRtsQueryKey(query, {
|
|
839
|
+
key,
|
|
840
|
+
projection: options.projection,
|
|
841
|
+
sort: options.sort,
|
|
842
|
+
limit: options.limit,
|
|
843
|
+
populate: options.populate
|
|
844
|
+
});
|
|
845
|
+
const ssrRuntime = useRtsSsrRuntime();
|
|
846
|
+
if (enabled && ssrEnabled && ssrRuntime) {
|
|
847
|
+
ssrRuntime.registerQuery({
|
|
848
|
+
modelName,
|
|
849
|
+
query,
|
|
850
|
+
options: {
|
|
851
|
+
key,
|
|
852
|
+
projection: options.projection,
|
|
853
|
+
sort: options.sort,
|
|
854
|
+
limit: options.limit,
|
|
855
|
+
populate: options.populate
|
|
856
|
+
},
|
|
857
|
+
queryKey
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
const seedDataRaw = enabled && ssrEnabled ? ssrRuntime ? ssrRuntime.getQueryData(modelName, queryKey) : peekHydratedRtsQueryData(modelName, queryKey) : void 0;
|
|
861
|
+
const hasSeedData = Array.isArray(seedDataRaw);
|
|
862
|
+
const seedData = hasSeedData ? seedDataRaw : void 0;
|
|
863
|
+
const seedJson = (() => {
|
|
864
|
+
if (!hasSeedData) return "";
|
|
865
|
+
try {
|
|
866
|
+
return JSON.stringify(seedDataRaw);
|
|
867
|
+
} catch {
|
|
868
|
+
return "";
|
|
869
|
+
}
|
|
870
|
+
})();
|
|
871
|
+
const [data, setData] = useState(() => seedData);
|
|
872
|
+
const [source, setSource] = useState(() => hasSeedData ? "cache" : void 0);
|
|
709
873
|
const [error, setError] = useState(void 0);
|
|
710
|
-
const [loading, setLoading] = useState(enabled);
|
|
874
|
+
const [loading, setLoading] = useState(enabled && !hasSeedData);
|
|
711
875
|
const hasFirstReply = useRef(false);
|
|
712
876
|
const hasNetworkReply = useRef(false);
|
|
713
877
|
const lastDataJsonRef = useRef("");
|
|
714
878
|
useEffect(() => {
|
|
715
|
-
hasFirstReply.current =
|
|
879
|
+
hasFirstReply.current = hasSeedData;
|
|
716
880
|
hasNetworkReply.current = false;
|
|
717
|
-
lastDataJsonRef.current =
|
|
881
|
+
lastDataJsonRef.current = seedJson;
|
|
718
882
|
setError(void 0);
|
|
719
883
|
if (!enabled) {
|
|
720
884
|
setLoading(false);
|
|
@@ -722,10 +886,17 @@ const useQuery = (modelName, query = {}, options = {}) => {
|
|
|
722
886
|
setSource(void 0);
|
|
723
887
|
return;
|
|
724
888
|
}
|
|
889
|
+
if (hasSeedData) {
|
|
890
|
+
setLoading(false);
|
|
891
|
+
setData(seedData);
|
|
892
|
+
setSource("cache");
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
725
895
|
setLoading(true);
|
|
726
|
-
}, [enabled, modelName,
|
|
896
|
+
}, [enabled, modelName, queryKey, hasSeedData, seedData, seedJson]);
|
|
727
897
|
useEffect(() => {
|
|
728
898
|
if (!enabled) return;
|
|
899
|
+
const runInitialNetworkQuery = refreshOnMount || !hasSeedData;
|
|
729
900
|
const unsubscribe = registerQuery(
|
|
730
901
|
modelName,
|
|
731
902
|
query,
|
|
@@ -733,7 +904,8 @@ const useQuery = (modelName, query = {}, options = {}) => {
|
|
|
733
904
|
key,
|
|
734
905
|
projection: options.projection,
|
|
735
906
|
sort: options.sort,
|
|
736
|
-
limit: options.limit
|
|
907
|
+
limit: options.limit,
|
|
908
|
+
populate: options.populate
|
|
737
909
|
},
|
|
738
910
|
(err, result, context) => {
|
|
739
911
|
if (context.source === "cache" && hasNetworkReply.current) return;
|
|
@@ -763,12 +935,15 @@ const useQuery = (modelName, query = {}, options = {}) => {
|
|
|
763
935
|
lastDataJsonRef.current = nextJson;
|
|
764
936
|
setSource(context.source);
|
|
765
937
|
setData(result);
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
runInitialNetworkQuery
|
|
766
941
|
}
|
|
767
942
|
);
|
|
768
943
|
return () => {
|
|
769
944
|
unsubscribe?.();
|
|
770
945
|
};
|
|
771
|
-
}, [enabled, modelName,
|
|
946
|
+
}, [enabled, modelName, queryKey, queryJson, projectionJson, sortJson, limitStr, populateJson, hasSeedData, refreshOnMount]);
|
|
772
947
|
return useMemo(
|
|
773
948
|
() => ({
|
|
774
949
|
data,
|
|
@@ -780,6 +955,8 @@ const useQuery = (modelName, query = {}, options = {}) => {
|
|
|
780
955
|
);
|
|
781
956
|
};
|
|
782
957
|
export {
|
|
958
|
+
RtsSsrRuntimeProvider as R,
|
|
959
|
+
STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY as S,
|
|
783
960
|
destroyCollection as a,
|
|
784
961
|
deleteDocs as b,
|
|
785
962
|
configureRtsPouchStore as c,
|
|
@@ -792,10 +969,14 @@ export {
|
|
|
792
969
|
reconnect as j,
|
|
793
970
|
registerQuery as k,
|
|
794
971
|
syncRtsChanges as l,
|
|
795
|
-
|
|
972
|
+
hydrateRtsFromWindow as m,
|
|
973
|
+
clearHydratedRtsQueryData as n,
|
|
796
974
|
onMessage as o,
|
|
975
|
+
peekHydratedRtsQueryData as p,
|
|
976
|
+
resolveRtsHydrationIdentityFromStaticRouterData as q,
|
|
797
977
|
resetRtsPouchStore as r,
|
|
798
978
|
sendMessage as s,
|
|
979
|
+
useQuery as t,
|
|
799
980
|
updateDocs as u
|
|
800
981
|
};
|
|
801
|
-
//# sourceMappingURL=useQuery-
|
|
982
|
+
//# sourceMappingURL=useQuery-Bz5cpWp4.js.map
|