@rpcbase/client 0.465.0 → 0.466.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.
@@ -1,41 +1,33 @@
1
- import { s as setClientExceptionReporter } from "./errorReporting-CVoUUKxW.js";
2
- const instrument = async ({
3
- posthogKey
4
- }) => {
5
- if (typeof posthogKey === "string" && posthogKey.length > 0) {
6
- try {
7
- const {
8
- default: posthog
9
- } = await import("posthog-js");
10
- posthog.init(posthogKey, {
11
- api_host: "/ingest",
12
- ui_host: "https://eu.posthog.com",
13
- person_profiles: "always",
14
- session_recording: {
15
- maskAllInputs: false
16
- },
17
- capture_exceptions: {
18
- capture_unhandled_errors: true,
19
- capture_unhandled_rejections: true,
20
- capture_console_errors: true
21
- },
22
- capture_pageview: true,
23
- autocapture: true,
24
- disable_session_recording: false,
25
- disable_surveys: true,
26
- disable_surveys_automatic_display: true
27
- });
28
- setClientExceptionReporter((error, context) => {
29
- posthog.captureException(error, context);
30
- });
31
- } catch (err) {
32
- console.warn("instrument: failed to load posthog-js", err);
33
- }
34
- } else {
35
- console.warn("instrument: missing posthogKey");
36
- }
1
+ import { n as setClientExceptionReporter } from "./errorReporting-BaPe0tII.js";
2
+ //#region src/instrument.ts
3
+ var instrument = async ({ posthogKey }) => {
4
+ if (typeof posthogKey === "string" && posthogKey.length > 0) try {
5
+ const { default: posthog } = await import("posthog-js");
6
+ posthog.init(posthogKey, {
7
+ api_host: "/ingest",
8
+ ui_host: "https://eu.posthog.com",
9
+ person_profiles: "always",
10
+ session_recording: { maskAllInputs: false },
11
+ capture_exceptions: {
12
+ capture_unhandled_errors: true,
13
+ capture_unhandled_rejections: true,
14
+ capture_console_errors: true
15
+ },
16
+ capture_pageview: true,
17
+ autocapture: true,
18
+ disable_session_recording: false,
19
+ disable_surveys: true,
20
+ disable_surveys_automatic_display: true
21
+ });
22
+ setClientExceptionReporter((error, context) => {
23
+ posthog.captureException(error, context);
24
+ });
25
+ } catch (err) {
26
+ console.warn("instrument: failed to load posthog-js", err);
27
+ }
28
+ else console.warn("instrument: missing posthogKey");
37
29
  };
38
- export {
39
- instrument
40
- };
41
- //# sourceMappingURL=instrument.js.map
30
+ //#endregion
31
+ export { instrument };
32
+
33
+ //# sourceMappingURL=instrument.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"instrument.js","sources":["../src/instrument.ts"],"sourcesContent":["import { setClientExceptionReporter } from \"./errorReporting\"\n\n\nexport const instrument = async ({posthogKey}: {posthogKey?: string}) => {\n if (typeof posthogKey === \"string\" && posthogKey.length > 0) {\n try {\n const { default: posthog } = await import(\"posthog-js\")\n\n posthog.init(posthogKey, {\n api_host: \"/ingest\",\n ui_host: \"https://eu.posthog.com\",\n person_profiles: \"always\",\n session_recording: {\n maskAllInputs: false\n },\n capture_exceptions: {\n capture_unhandled_errors: true,\n capture_unhandled_rejections: true,\n capture_console_errors: true,\n },\n capture_pageview: true,\n autocapture: true,\n disable_session_recording: false,\n disable_surveys: true,\n disable_surveys_automatic_display: true,\n })\n\n setClientExceptionReporter((error, context) => {\n posthog.captureException(error, context)\n })\n } catch (err) {\n console.warn(\"instrument: failed to load posthog-js\", err)\n }\n } else {\n console.warn(\"instrument: missing posthogKey\")\n }\n}\n"],"names":["instrument","posthogKey","length","default","posthog","init","api_host","ui_host","person_profiles","session_recording","maskAllInputs","capture_exceptions","capture_unhandled_errors","capture_unhandled_rejections","capture_console_errors","capture_pageview","autocapture","disable_session_recording","disable_surveys","disable_surveys_automatic_display","setClientExceptionReporter","error","context","captureException","err","console","warn"],"mappings":";AAGO,MAAMA,aAAa,OAAO;AAAA,EAACC;AAAiC,MAAM;AACvE,MAAI,OAAOA,eAAe,YAAYA,WAAWC,SAAS,GAAG;AAC3D,QAAI;AACF,YAAM;AAAA,QAAEC,SAASC;AAAAA,MAAAA,IAAY,MAAM,OAAO,YAAY;AAEtDA,cAAQC,KAAKJ,YAAY;AAAA,QACvBK,UAAU;AAAA,QACVC,SAAS;AAAA,QACTC,iBAAiB;AAAA,QACjBC,mBAAmB;AAAA,UACjBC,eAAe;AAAA,QAAA;AAAA,QAEjBC,oBAAoB;AAAA,UAClBC,0BAA0B;AAAA,UAC1BC,8BAA8B;AAAA,UAC9BC,wBAAwB;AAAA,QAAA;AAAA,QAE1BC,kBAAkB;AAAA,QAClBC,aAAa;AAAA,QACbC,2BAA2B;AAAA,QAC3BC,iBAAiB;AAAA,QACjBC,mCAAmC;AAAA,MAAA,CACpC;AAEDC,iCAA2B,CAACC,OAAOC,YAAY;AAC7ClB,gBAAQmB,iBAAiBF,OAAOC,OAAO;AAAA,MACzC,CAAC;AAAA,IACH,SAASE,KAAK;AACZC,cAAQC,KAAK,yCAAyCF,GAAG;AAAA,IAC3D;AAAA,EACF,OAAO;AACLC,YAAQC,KAAK,gCAAgC;AAAA,EAC/C;AACF;"}
1
+ {"version":3,"file":"instrument.js","names":["setClientExceptionReporter","instrument","posthogKey","length","default","posthog","init","api_host","ui_host","person_profiles","session_recording","maskAllInputs","capture_exceptions","capture_unhandled_errors","capture_unhandled_rejections","capture_console_errors","capture_pageview","autocapture","disable_session_recording","disable_surveys","disable_surveys_automatic_display","error","context","captureException","err","console","warn"],"sources":["../src/instrument.ts"],"sourcesContent":["import { setClientExceptionReporter } from \"./errorReporting\"\n\n\nexport const instrument = async ({posthogKey}: {posthogKey?: string}) => {\n if (typeof posthogKey === \"string\" && posthogKey.length > 0) {\n try {\n const { default: posthog } = await import(\"posthog-js\")\n\n posthog.init(posthogKey, {\n api_host: \"/ingest\",\n ui_host: \"https://eu.posthog.com\",\n person_profiles: \"always\",\n session_recording: {\n maskAllInputs: false\n },\n capture_exceptions: {\n capture_unhandled_errors: true,\n capture_unhandled_rejections: true,\n capture_console_errors: true,\n },\n capture_pageview: true,\n autocapture: true,\n disable_session_recording: false,\n disable_surveys: true,\n disable_surveys_automatic_display: true,\n })\n\n setClientExceptionReporter((error, context) => {\n posthog.captureException(error, context)\n })\n } catch (err) {\n console.warn(\"instrument: failed to load posthog-js\", err)\n }\n } else {\n console.warn(\"instrument: missing posthogKey\")\n }\n}\n"],"mappings":";;AAGA,IAAaC,aAAa,OAAO,EAACC,iBAAuC;CACvE,IAAI,OAAOA,eAAe,YAAYA,WAAWC,SAAS,GACxD,IAAI;EACF,MAAM,EAAEC,SAASC,YAAY,MAAM,OAAO;EAE1CA,QAAQC,KAAKJ,YAAY;GACvBK,UAAU;GACVC,SAAS;GACTC,iBAAiB;GACjBC,mBAAmB,EACjBC,eAAe,MACjB;GACAC,oBAAoB;IAClBC,0BAA0B;IAC1BC,8BAA8B;IAC9BC,wBAAwB;GAC1B;GACAC,kBAAkB;GAClBC,aAAa;GACbC,2BAA2B;GAC3BC,iBAAiB;GACjBC,mCAAmC;EACrC,CAAC;EAEDpB,4BAA4BqB,OAAOC,YAAY;GAC7CjB,QAAQkB,iBAAiBF,OAAOC,OAAO;EACzC,CAAC;CACH,SAASE,KAAK;EACZC,QAAQC,KAAK,yCAAyCF,GAAG;CAC3D;MAEAC,QAAQC,KAAK,gCAAgC;AAEjD"}
package/dist/rts/index.js CHANGED
@@ -1,317 +1,2 @@
1
- import { s as serializeRtsQueryValue, f as computeRtsQueryKey, g as useRtsSsrRuntime, p as peekHydratedRtsCount, a as consumeHydratedRtsCount, r as registerCount, i as reconnect, j as disconnect } from "../useQuery-DZqYIJog.js";
2
- import { R, S, k, c, l, m, n, o, q, t, v, w, h, x, y, z, b, d, e, A, B, C, D, E, F, G, H, I, u } from "../useQuery-DZqYIJog.js";
3
- import { c as c2 } from "react/compiler-runtime";
4
- import { useState, useRef, useEffect } from "react";
5
- const normalizeCount = (value) => {
6
- if (typeof value !== "number") return void 0;
7
- if (!Number.isFinite(value) || value < 0) return void 0;
8
- return Math.floor(value);
9
- };
10
- const useCountQuery = (modelName, t0, t1) => {
11
- const $ = c2(54);
12
- const query = t0 === void 0 ? {} : t0;
13
- let t2;
14
- if ($[0] !== t1) {
15
- t2 = t1 === void 0 ? {} : t1;
16
- $[0] = t1;
17
- $[1] = t2;
18
- } else {
19
- t2 = $[1];
20
- }
21
- const options = t2;
22
- if (typeof modelName !== "string" || modelName.trim().length === 0) {
23
- throw new Error("useCountQuery: modelName must be a non-empty string");
24
- }
25
- const enabled = options.enabled ?? true;
26
- const ssrEnabled = options.ssr !== false;
27
- const refreshOnMount = options.refreshOnMount === true;
28
- const key = options.key;
29
- const queryJson = serializeRtsQueryValue(query);
30
- let t3;
31
- if ($[2] !== key) {
32
- t3 = key ? {
33
- key
34
- } : {};
35
- $[2] = key;
36
- $[3] = t3;
37
- } else {
38
- t3 = $[3];
39
- }
40
- const runtimeOptions = t3;
41
- const queryKey = computeRtsQueryKey(query, runtimeOptions);
42
- const ssrRuntime = useRtsSsrRuntime();
43
- if (enabled && ssrEnabled && ssrRuntime) {
44
- ssrRuntime.registerCount({
45
- modelName,
46
- query,
47
- options: runtimeOptions,
48
- queryKey
49
- });
50
- }
51
- let t4;
52
- if ($[4] !== enabled || $[5] !== modelName || $[6] !== queryKey || $[7] !== ssrEnabled || $[8] !== ssrRuntime) {
53
- t4 = enabled && ssrEnabled ? ssrRuntime ? ssrRuntime.getCount(modelName, queryKey) : peekHydratedRtsCount(modelName, queryKey) : void 0;
54
- $[4] = enabled;
55
- $[5] = modelName;
56
- $[6] = queryKey;
57
- $[7] = ssrEnabled;
58
- $[8] = ssrRuntime;
59
- $[9] = t4;
60
- } else {
61
- t4 = $[9];
62
- }
63
- const seedCountRaw = t4;
64
- let t5;
65
- if ($[10] !== seedCountRaw) {
66
- t5 = normalizeCount(seedCountRaw);
67
- $[10] = seedCountRaw;
68
- $[11] = t5;
69
- } else {
70
- t5 = $[11];
71
- }
72
- const seedCount = t5;
73
- const seedCountStr = seedCount !== void 0 ? String(seedCount) : "";
74
- const hasSeedCount = seedCount !== void 0;
75
- let t6;
76
- if ($[12] !== seedCount) {
77
- t6 = () => seedCount;
78
- $[12] = seedCount;
79
- $[13] = t6;
80
- } else {
81
- t6 = $[13];
82
- }
83
- const [count, setCount] = useState(t6);
84
- let t7;
85
- if ($[14] !== hasSeedCount) {
86
- t7 = () => hasSeedCount ? "cache" : void 0;
87
- $[14] = hasSeedCount;
88
- $[15] = t7;
89
- } else {
90
- t7 = $[15];
91
- }
92
- const [source, setSource] = useState(t7);
93
- const [error, setError] = useState(void 0);
94
- const [loading, setLoading] = useState(enabled && !hasSeedCount);
95
- const lastCountRef = useRef(seedCount);
96
- let t8;
97
- if ($[16] !== enabled || $[17] !== hasSeedCount || $[18] !== modelName || $[19] !== queryKey || $[20] !== seedCount || $[21] !== ssrEnabled || $[22] !== ssrRuntime) {
98
- t8 = () => {
99
- if (!ssrRuntime && enabled && ssrEnabled && hasSeedCount) {
100
- consumeHydratedRtsCount(modelName, queryKey);
101
- }
102
- lastCountRef.current = seedCount;
103
- setError(void 0);
104
- if (!enabled) {
105
- setCount(void 0);
106
- setSource(void 0);
107
- setLoading(false);
108
- return;
109
- }
110
- if (hasSeedCount) {
111
- setCount(seedCount);
112
- setSource("cache");
113
- setLoading(false);
114
- return;
115
- }
116
- setCount(void 0);
117
- setSource(void 0);
118
- setLoading(true);
119
- };
120
- $[16] = enabled;
121
- $[17] = hasSeedCount;
122
- $[18] = modelName;
123
- $[19] = queryKey;
124
- $[20] = seedCount;
125
- $[21] = ssrEnabled;
126
- $[22] = ssrRuntime;
127
- $[23] = t8;
128
- } else {
129
- t8 = $[23];
130
- }
131
- let t9;
132
- if ($[24] !== enabled || $[25] !== hasSeedCount || $[26] !== modelName || $[27] !== queryKey || $[28] !== seedCount || $[29] !== seedCountStr || $[30] !== ssrEnabled || $[31] !== ssrRuntime) {
133
- t9 = [enabled, ssrEnabled, ssrRuntime, modelName, queryKey, hasSeedCount, seedCount, seedCountStr];
134
- $[24] = enabled;
135
- $[25] = hasSeedCount;
136
- $[26] = modelName;
137
- $[27] = queryKey;
138
- $[28] = seedCount;
139
- $[29] = seedCountStr;
140
- $[30] = ssrEnabled;
141
- $[31] = ssrRuntime;
142
- $[32] = t9;
143
- } else {
144
- t9 = $[32];
145
- }
146
- useEffect(t8, t9);
147
- let t10;
148
- if ($[33] !== enabled || $[34] !== hasSeedCount || $[35] !== modelName || $[36] !== query || $[37] !== refreshOnMount || $[38] !== runtimeOptions || $[39] !== seedCount) {
149
- t10 = () => {
150
- if (!enabled) {
151
- return;
152
- }
153
- const unsubscribe = registerCount(modelName, query, runtimeOptions, (err, nextCount, context) => {
154
- if (context.source === "cache" && context.reset) {
155
- lastCountRef.current = void 0;
156
- setCount(void 0);
157
- setSource(void 0);
158
- setError(void 0);
159
- setLoading(true);
160
- return;
161
- }
162
- setLoading(false);
163
- if (err) {
164
- setError(err);
165
- return;
166
- }
167
- if (nextCount === void 0) {
168
- return;
169
- }
170
- setError(void 0);
171
- if (lastCountRef.current === nextCount) {
172
- setSource(context.source);
173
- return;
174
- }
175
- lastCountRef.current = nextCount;
176
- setCount(nextCount);
177
- setSource(context.source);
178
- }, {
179
- runInitialNetworkQuery: refreshOnMount || !hasSeedCount,
180
- forceRefreshOnMount: refreshOnMount,
181
- ...hasSeedCount ? {
182
- seedSnapshot: {
183
- error: null,
184
- count: seedCount,
185
- context: {
186
- source: "cache"
187
- }
188
- }
189
- } : {}
190
- });
191
- return () => {
192
- unsubscribe?.();
193
- };
194
- };
195
- $[33] = enabled;
196
- $[34] = hasSeedCount;
197
- $[35] = modelName;
198
- $[36] = query;
199
- $[37] = refreshOnMount;
200
- $[38] = runtimeOptions;
201
- $[39] = seedCount;
202
- $[40] = t10;
203
- } else {
204
- t10 = $[40];
205
- }
206
- let t11;
207
- if ($[41] !== enabled || $[42] !== hasSeedCount || $[43] !== modelName || $[44] !== queryJson || $[45] !== queryKey || $[46] !== refreshOnMount || $[47] !== runtimeOptions) {
208
- t11 = [enabled, modelName, queryJson, queryKey, runtimeOptions, hasSeedCount, refreshOnMount];
209
- $[41] = enabled;
210
- $[42] = hasSeedCount;
211
- $[43] = modelName;
212
- $[44] = queryJson;
213
- $[45] = queryKey;
214
- $[46] = refreshOnMount;
215
- $[47] = runtimeOptions;
216
- $[48] = t11;
217
- } else {
218
- t11 = $[48];
219
- }
220
- useEffect(t10, t11);
221
- let t12;
222
- if ($[49] !== count || $[50] !== error || $[51] !== loading || $[52] !== source) {
223
- t12 = {
224
- count,
225
- source,
226
- error,
227
- loading
228
- };
229
- $[49] = count;
230
- $[50] = error;
231
- $[51] = loading;
232
- $[52] = source;
233
- $[53] = t12;
234
- } else {
235
- t12 = $[53];
236
- }
237
- return t12;
238
- };
239
- let activeConsumers = 0;
240
- let connectedKey = null;
241
- let pendingDisconnectTimer = null;
242
- const cancelPendingDisconnect = () => {
243
- if (pendingDisconnectTimer !== null) {
244
- clearTimeout(pendingDisconnectTimer);
245
- pendingDisconnectTimer = null;
246
- }
247
- };
248
- const useRtsConnection = (tenantId, uid, options = {}) => {
249
- const tenantIdValue = typeof tenantId === "string" ? tenantId.trim() : "";
250
- const uidValue = typeof uid === "string" ? uid.trim() : "";
251
- const optionsJson = serializeRtsQueryValue(options);
252
- const optionsRef = useRef(options);
253
- optionsRef.current = options;
254
- useEffect(() => {
255
- if (typeof window === "undefined") return;
256
- if (!tenantIdValue || !uidValue) return;
257
- activeConsumers += 1;
258
- cancelPendingDisconnect();
259
- const key = `${tenantIdValue}::${uidValue}::${optionsJson}`;
260
- if (connectedKey !== key) {
261
- connectedKey = key;
262
- void reconnect(tenantIdValue, uidValue, optionsRef.current).catch((error) => {
263
- connectedKey = null;
264
- console.error("RTS connection failed", error);
265
- });
266
- }
267
- return () => {
268
- activeConsumers -= 1;
269
- if (activeConsumers > 0) return;
270
- pendingDisconnectTimer = setTimeout(() => {
271
- pendingDisconnectTimer = null;
272
- if (activeConsumers > 0) return;
273
- connectedKey = null;
274
- disconnect();
275
- }, 0);
276
- };
277
- }, [tenantIdValue, uidValue, optionsJson]);
278
- };
279
- export {
280
- R as RtsSsrRuntimeProvider,
281
- S as STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY,
282
- k as addLocalTxn,
283
- c as clearHydratedRtsQueryData,
284
- l as configureRtsPouchStore,
285
- m as connect,
286
- consumeHydratedRtsCount,
287
- n as deleteDocs,
288
- o as destroyAllCollections,
289
- q as destroyCollection,
290
- disconnect,
291
- t as getCollection,
292
- v as getConnectionError,
293
- w as getConnectionStatus,
294
- h as hydrateRtsFromWindow,
295
- x as onConnectionStatusChange,
296
- y as onMessage,
297
- z as onRtsMessage,
298
- peekHydratedRtsCount,
299
- b as peekHydratedRtsQueryData,
300
- d as peekHydratedRtsQueryPageInfo,
301
- e as peekHydratedRtsQueryTotalCount,
302
- reconnect,
303
- registerCount,
304
- A as registerQuery,
305
- B as resetRtsPouchStore,
306
- C as runNetworkCount,
307
- D as runNetworkQuery,
308
- E as runQuery,
309
- F as sendMessage,
310
- G as sendRtsMessage,
311
- H as syncRtsChanges,
312
- I as updateDocs,
313
- useCountQuery,
314
- u as useQuery,
315
- useRtsConnection
316
- };
317
- //# sourceMappingURL=index.js.map
1
+ import { A as clearHydratedRtsQueryData, C as destroyCollection, D as updateDocs, E as runQuery, F as peekHydratedRtsQueryPageInfo, I as peekHydratedRtsQueryTotalCount, M as hydrateRtsFromWindow, N as peekHydratedRtsCount, O as RtsSsrRuntimeProvider, P as peekHydratedRtsQueryData, S as destroyAllCollections, T as resetRtsPouchStore, _ as sendMessage, a as connect, b as configureRtsPouchStore, c as getConnectionStatus, d as onRtsMessage, f as reconnect, g as runNetworkQuery, h as runNetworkCount, i as addLocalTxn, j as consumeHydratedRtsCount, k as STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY, l as onConnectionStatusChange, m as registerQuery, n as useQuery, o as disconnect, p as registerCount, r as useCountQuery, s as getConnectionError, t as useRtsConnection, u as onMessage, v as sendRtsMessage, w as getCollection, x as deleteDocs, y as syncRtsChanges } from "../rts-C9lvbdZX.js";
2
+ export { RtsSsrRuntimeProvider, STATIC_RPCBASE_RTS_HYDRATION_DATA_KEY, addLocalTxn, clearHydratedRtsQueryData, configureRtsPouchStore, connect, consumeHydratedRtsCount, deleteDocs, destroyAllCollections, destroyCollection, disconnect, getCollection, getConnectionError, getConnectionStatus, hydrateRtsFromWindow, onConnectionStatusChange, onMessage, onRtsMessage, peekHydratedRtsCount, peekHydratedRtsQueryData, peekHydratedRtsQueryPageInfo, peekHydratedRtsQueryTotalCount, reconnect, registerCount, registerQuery, resetRtsPouchStore, runNetworkCount, runNetworkQuery, runQuery, sendMessage, sendRtsMessage, syncRtsChanges, updateDocs, useCountQuery, useQuery, useRtsConnection };